Skip to content

Repository files navigation

xray-schema

The main idea of this project is to make some typescript utilities for xray-core json config

Ideas:

  • Runtime config validation (using zod)
  • JSON schema + docs + default snippets
    • More default snippets need to be added for different properties (inbounds, outbounds, dns, routing, etc)
    • More elegant Monaco editor integration
      • Improve JSON schema to provider better auto complete for discriminated unions
      • Higher priority for required fields
  • Link generator -> inbound to link (Logic ported from v2rayNG)
  • Link parser -> link to outbound (Logic ported from v2rayNG)
  • Wasm of xray-core to validate config in browser

Details

  • To include docs in JSON schema, the official doc is chunked and is imported to the schema. During build it generates 3 different bundles

    • @gozargah/xray-schema - the main package, which includes the zod schema without any docs or snippets
    • @gozargah/xray-schema/with-docs - the documentation bundle, which includes markdown description for each field in the schema, extracted from the official docs
    • @gozargah/xray-schema/full - the full bundle, which includes both the schema and the docs, and also includes default snippets for some protocols/transports. Its JSON schema is compatible with Monaco editor, which allows for autocompletion and validation in the editor.
  • Link parser/generator is exported under @gozargah/xray-schema/link. to have per protocol import: @gozargah/xray-schema/link/[protocol].

Usage

Install the package:

pnpm i @gozargah/xray-schema

License

Published under the LGPL3 license.

Releases

Packages

Contributors

Languages