Constructors

Properties

child: null | ChildProcessWithoutNullStreams
config: V2RayConf
uuid: string

Methods

  • Generates share links for all outbounds in the current config. Returns one link per outbound, VMess or VLess depending on the protocol.

    Parameters

    • name: string = "sentinel-js-sdk"

      Optional display name prefix (default: "sentinel-js-sdk")

    Returns string[]

    Array of share link strings

  • Generates a VLess share link in the standard URI format. Format: vless://{uuid}@{address}:{port}?{params}#{name} Compatible with: v2rayNG, NekoBox, Shadowrocket.

    Parameters

    • address: string

      Node IP or hostname

    • port: number

      Node port

    • network: Network

      Transport network (grpc, tcp, ws, etc.)

    • security: undefined | Security

      Transport security ("tls" or "none")

    • name: string = "sentinel-js-sdk"

      Optional display name shown in the app (default: "sentinel-js-sdk")

    Returns string

    vless:// share link string

  • Generates a VMess share link in the standard v2rayNG format. Format: vmess:// + base64(JSON config) Compatible with: v2rayNG, NekoBox, Shadowrocket, Quantumult X.

    Parameters

    • address: string

      Node IP or hostname

    • port: number

      Node port

    • network: Network

      Transport network (grpc, tcp, ws, etc.)

    • security: undefined | Security

      Transport security ("tls" or "none")

    • aid: string = "0"
    • name: string = "sentinel-js-sdk"

      Optional display name shown in the app (default: "sentinel-js-sdk")

    Returns string

    vmess:// share link string

  • Starts the v2ray process with the current configuration. The process is kept as this.child for later termination via disconnect().

    Parameters

    • Optional configFile: string

      Optional path to an existing config JSON file. If omitted, writes the current config to a temp file first.

    Returns undefined | number

    The PID of the spawned v2ray process, or undefined if spawn failed.

  • Stops the v2ray process by sending SIGINT.

    Returns boolean

    true if the signal was sent successfully, false if no process is running.

  • Returns the v2ray-encoded key for this client's UUID. Format: base64( [0x01] + uuid_bytes )

    Returns number[]

    base64 string used as handshake data.uid

  • Parses the JSON response from the node handshake and builds the v2ray configuration. Replaces the old 7-byte binary buffer parsing.

    Picks the first available metadata entry. If multiple are present (the node supports multiple transports), the first is used — you can extend this to let the caller choose.

    Parameters

    • handshakeData: V2RayHandshakeData

      Parsed result.data from the handshake response

    • nodeAddrs: string[]

      result.addrs from the handshake response (public IPs of the node)

    Returns Promise<void>

    Example

    const raw: V2RayHandshakeData = JSON.parse(
    Buffer.from(result.data, 'base64').toString('utf8')
    );
    await v2ray.parseConfig(raw, result.addrs);
  • Prints QR codes for all share links to the terminal. Each QR code can be scanned directly by v2rayNG or similar apps. Requires qrcode package: npm install qrcode @types/qrcode

    Parameters

    • name: string = "sentinel-js-sdk"

      Optional display name for the links (default: "sentinel-js-sdk")

    Returns Promise<void>

    Example

    await v2ray.printShareQRCodes();
    // Prints one QR code per outbound to stdout
  • Serializes the current v2ray configuration to a JSON file on disk.

    Parameters

    • Optional output: string

      Optional output file path. If omitted, a temp file is created.

    Returns string

    The path of the written config file.

Generated using TypeDoc