Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Protocols

xrat supports 7 proxy protocols, each with specific URI formats, configuration fields, and engine routing.

Supported Protocols

ProtocolURI SchemeXraysing-boxParser
VLESSvless://YesNoYes
VMessvmess://YesNoYes
Shadowsocksss://YesNoYes
Trojantrojan://YesNoYes
HTTPhttp:// / https://YesNoYes
SOCKS5socks5://YesNoYes
Hysteria2hysteria2:// / hy2://NoYesYes

VLESS

Modern, lightweight protocol from the Xray project.

Scheme: vless://

Format:

vless://<uuid>@<address>:<port>?type=<network>&security=<tls>&sni=<sni>&host=<host>&path=<path>#<name>

Fields:

FieldLocationRequiredDescription
uuiduserinfoYesVLESS user ID
addresshostYesServer address
portportYesServer port
typequeryNoNetwork type (tcp, ws, grpc, xhttp), default tcp
securityqueryNoSecurity mode (tls, reality, none), default none
sniqueryNoSNI hostname
hostqueryNoHost header (WebSocket)
pathqueryNoPath (WebSocket, gRPC, TCP)
flowqueryNoFlow control, e.g. xtls-rprx-vision
fpqueryNouTLS fingerprint, e.g. chrome (REALITY defaults chrome)
alpnqueryNoComma-separated ALPN list (TLS)
modequeryNoxhttp/gRPC mode, e.g. packet-up
pbkqueryREALITYREALITY public key (required when security=reality)
sidqueryNoREALITY short ID
spxqueryNoREALITY spiderX path
namefragmentNoDisplay name

REALITY: when security=reality, xrat builds current Xray realitySettings from pbk/password, sid, spx, fp, and sni. The share-link public key is emitted as Xray’s current password field and is required. REALITY is accepted only with raw, xhttp, or gRPC transports.

All non-structural query parameters are preserved. xrat generates current raw, WebSocket, gRPC, xhttp, mKCP, and HTTPUpgrade settings when representable and fails with a named unsupported-parameter/transport error instead of silently dropping a wire-affecting value.

For xhttp, current flat parameters use Xray’s camelCase names, including xPaddingBytes, xPaddingObfsMode, noGRPCHeader, noSSEHeader, headers, xmux, and downloadSettings. The compatibility aliases x_padding_bytes and the URL-encoded x_padding%20bytes are also accepted for xPaddingBytes.

Newer Xray xhttp options can be passed in the URL-encoded extra query parameter as a JSON object. Fields inside extra are preserved so links can use options introduced by newer Xray versions. A canonical flat parameter overrides the same field in extra; extra overrides compatibility aliases. Unknown flat parameters, malformed values, repeated singular parameters, and conflicting aliases are rejected. Whether a future field works at runtime still depends on the installed Xray version.

Examples:

vless://uuid-123@example.com:443?type=ws&security=tls&sni=cdn.example.com&path=%2Fray#My%20Node
vless://uuid-456@example.com:443?type=tcp#Direct
vless://uuid-789@example.com:8443?type=grpc&serviceName=service#gRPC%20Node
vless://uuid-abc@example.com:8080?type=xhttp&security=reality&sni=www.example.com&pbk=PUBLICKEY&sid=SHORTID&fp=chrome&flow=xtls-rprx-vision#REALITY%20Node
vless://uuid-def@example.com:443?type=xhttp&mode=auto&xPaddingBytes=100-1000&extra=%7B%22noSSEHeader%22%3Atrue%7D#XHTTP%20Node

Engine: Xray (auto), Xray (explicit)


VMess

Legacy protocol with encryption, from V2Ray.

Scheme: vmess://

Format:

vmess://<base64-json>

Base64 JSON Fields:

{
  "add": "example.com",
  "port": "443",
  "id": "uuid-456",
  "net": "ws",
  "tls": "tls",
  "sni": "edge.example.com",
  "host": "host.example.com",
  "path": "/vmess",
  "ps": "VMess Node"
}
FieldKeyRequiredDescription
addJSONYesServer address
portJSONYesServer port
idJSONNoUUID
netJSONNoNetwork type (tcp, ws), default tcp
tlsJSONNoTLS mode (tls)
sniJSONNoSNI hostname
hostJSONNoHost header (WebSocket)
pathJSONNoPath (WebSocket)
psJSONNoDisplay name

Example:

vmess://eyJhZGQiOiJleGFtcGxlLmNvbSIsInBvcnQiOiI0NDMiLCJpZCI6InV1aWQtNDU2IiwibmV0Ijoid3MiLCJ0bHMiOiJ0bHMiLCJzbmkiOiJlZGdlLmV4YW1wbGUuY29tIiwiaG9zdCI6Imhvc3QuZXhhbXBsZS5jb20iLCJwYXRoIjoiL3ZtZXNzIiwicHMiOiJWTWVzcyBOb2RlIn0=

Engine: Xray (auto), Xray (explicit)


Shadowsocks

Simple, secure proxy protocol.

Scheme: ss://

Format:

ss://<base64(method:password)>@<address>:<port>#<name>

Fields:

FieldLocationRequiredDescription
methodbase64 userinfoYesEncryption method
passwordbase64 userinfoYesPassword
addresshostYesServer address
portportYesServer port
namefragmentNoDisplay name

Encryption methods: aes-128-gcm, aes-256-gcm, chacha20-ietf-poly1305, xchacha20-ietf-poly1305, aes-128-cfb, aes-256-cfb, rc4-md5

Example:

ss://YWVzLTI1Ni1nY206c2VjcmV0@example.com:8388#SS%20Node

Engine: Xray (auto), Xray (explicit)


Trojan

TLS-based proxy that mimics HTTPS traffic.

Scheme: trojan://

Format:

trojan://<password>@<address>:<port>?type=<network>&sni=<sni>&host=<host>&path=<path>#<name>

Fields:

FieldLocationRequiredDescription
passworduserinfoYesTrojan password
addresshostYesServer address
portportYesServer port
typequeryNoNetwork type (tcp, ws, grpc), default tcp
sniqueryNoSNI hostname
hostqueryNoHost header (WebSocket)
pathqueryNoPath (WebSocket, gRPC)
namefragmentNoDisplay name

Default TLS: Trojan always uses TLS (security=tls is added automatically).

Examples:

trojan://password@example.com:443?type=ws&sni=cdn.example.com&path=%2Ftrojan#Trojan%20Node

Engine: Xray (auto), Xray (explicit)


HTTP

Standard HTTP/HTTPS proxy.

Scheme: http:// / https://

Format:

http://<username>:<password>@<address>:<port>#<name>
https://<username>:<password>@<address>:<port>#<name>

Fields:

FieldLocationRequiredDescription
usernameuserinfoNoUsername
passworduserinfoNoPassword
addresshostYesServer address
portportYesServer port
namefragmentNoDisplay name

TLS: https:// scheme automatically sets tls=tls.

Examples:

http://user:pass@example.com:8080#HTTP%20Node
https://example.com:443#HTTPS%20Node

Engine: Xray (auto), Xray (explicit)


SOCKS5

Standard SOCKS5 proxy.

Scheme: socks5://

Format:

socks5://<username>:<password>@<address>:<port>#<name>

Fields:

FieldLocationRequiredDescription
usernameuserinfoNoUsername
passworduserinfoNoPassword
addresshostYesServer address
portportYesServer port
namefragmentNoDisplay name

Examples:

socks5://user:pass@example.com:1080#SOCKS%20Node
socks5://example.com:1080#Anonymous

Engine: Xray (auto), Xray (explicit)


Hysteria2

QUIC-based protocol designed for high-speed connections.

Scheme: hysteria2:// / hy2://

Format:

hysteria2://<password>@<address>:<port>?sni=<sni>&obfs=<type>&obfs-password=<pass>#<name>
hy2://<password>@<address>:<port>?sni=<sni>&obfs=<type>&obfs-password=<pass>#<name>

Fields:

FieldLocationRequiredDescription
passworduserinfoYesAuthentication password
addresshostYesServer address
portportYesServer port
sniqueryNoSNI hostname
obfsqueryNoObfuscation type
obfs-passwordqueryNoObfuscation password
alpnqueryNoALPN protocol
insecurequeryNoAllow insecure TLS
upmbpsqueryNoUpload Mbps
downmbpsqueryNoDownload Mbps
namefragmentNoDisplay name

Default network: udp (not configurable) Default TLS: tls (always enabled)

Examples:

hy2://password@example.com:443?sni=cdn.example.com&obfs=salamander&obfs-password=secret#HY2%20Node
hy2://password@example.com:8443#Simple%20HY2
hysteria2://password@example.com:443#Alias

Engine: sing-box (auto), sing-box (explicit)


Engine Routing

Engine selection is automatic but configurable.

Auto Mode (Default)

ProtocolEngine
VLESSXray
VMessXray
ShadowsocksXray
TrojanXray
HTTPXray
SOCKS5Xray
Hysteria2sing-box

Xray Mode

All protocols except Hysteria2. Errors on Hysteria2.

sing-box Mode

All protocols use sing-box (currently only Hysteria2 fully implemented).

Checking Engine

xrat parse --engine auto "vless://uuid@example.com:443"
xrat parse --engine sing-box "hy2://password@example.com:443"

Normalized Fields

All protocols are normalized to a common Node structure:

FieldVLESSVMessSSTrojanHTTPSOCKS5HY2
protocolvlessvmesssstrojanhttpsocks5hy2
addresshostaddhosthosthosthosthost
portportportportportport/80/443portport
uuiduserinfoid-----
password--base64userinfouserinfouserinfouserinfo
method--base64----
networktypenettcptypetcptcpudp
tlssecuritytls-tlsscheme-tls
snisnisni-sni--sni
hosthosthost-host---
pathpathpath-path---
namefragmentpsfragmentfragmentfragmentfragmentfragment