sing-box-kit 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -9
- package/dist/index.d.mts +2573 -596
- package/dist/index.mjs +612 -651
- package/docs/configuration.md +21 -43
- package/docs/dns-rules.md +43 -0
- package/docs/internal/README.md +31 -0
- package/docs/resources.md +47 -0
- package/docs/rules.md +38 -45
- package/docs/settings.md +36 -0
- package/package.json +1 -1
- package/schema/README.md +3 -3
- package/scripts/generate-schema.ts +153 -0
- package/src/compile.ts +35 -59
- package/src/factories.ts +315 -532
- package/src/generated/sbkit-inputs.ts +2671 -0
- package/src/input-schema.ts +299 -0
- package/src/resource.ts +30 -39
- package/src/rules.ts +82 -207
- package/src/schema.ts +15 -23
- package/src/settings.ts +155 -156
- package/src/type-utils.ts +15 -0
- package/vite.config.ts +2 -2
package/README.md
CHANGED
|
@@ -1,26 +1,44 @@
|
|
|
1
|
-
# sing-box
|
|
1
|
+
# sing-box-kit
|
|
2
2
|
|
|
3
3
|
Build and validate sing-box v1.14.4 configurations in TypeScript.
|
|
4
4
|
|
|
5
5
|
## Quick start
|
|
6
6
|
|
|
7
|
-
Install the package with `bun add sing-box-kit`, then
|
|
7
|
+
Install the package with `bun add sing-box-kit`, then save this local proxy configuration as `config.ts`.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
-
import { compile, outbound } from "sing-box-kit";
|
|
11
|
-
|
|
12
|
-
const
|
|
10
|
+
import { compile, inbound, outbound } from "sing-box-kit";
|
|
11
|
+
|
|
12
|
+
const proxy = inbound.mixed({ tag: "proxy" }).listen("127.0.0.1", { port: 1080 });
|
|
13
|
+
const direct = outbound.direct({ tag: "direct" });
|
|
14
|
+
const config = compile({
|
|
15
|
+
inbounds: [proxy],
|
|
16
|
+
outbounds: [direct],
|
|
17
|
+
route: { final: direct },
|
|
18
|
+
});
|
|
13
19
|
console.log(JSON.stringify(config, null, 2));
|
|
14
20
|
```
|
|
15
21
|
|
|
16
|
-
Generate
|
|
22
|
+
Generate and check the config with sing-box.
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
bun config.ts > config.json
|
|
26
|
+
sing-box check -c config.json
|
|
27
|
+
```
|
|
17
28
|
|
|
18
|
-
On Node.js 22.1 or later, save the same example as `config.mjs
|
|
29
|
+
On Node.js 22.1 or later, install with `npm install sing-box-kit`, save the same example as `config.mjs`, and generate JSON with `node config.mjs > config.json`.
|
|
19
30
|
|
|
20
31
|
To run the example from a source checkout, run `vp install --frozen-lockfile` and use `./index` as the import path.
|
|
21
32
|
|
|
22
33
|
## Documentation
|
|
23
34
|
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
35
|
+
- [Build and validate a configuration](docs/configuration.md)
|
|
36
|
+
- [Resource factories and registration](docs/resources.md)
|
|
37
|
+
- [Listen, dial, resolver, and TLS settings](docs/settings.md)
|
|
38
|
+
- [Routing rules and shared conditions](docs/rules.md)
|
|
39
|
+
- [DNS rules and response evaluation](docs/dns-rules.md)
|
|
40
|
+
|
|
41
|
+
## Contributing
|
|
42
|
+
|
|
43
|
+
- [SBKit internals](docs/internal/README.md)
|
|
26
44
|
- [Schema and type generation](schema/README.md)
|