Common Types & Transports¶
This page documents reusable scalar types, certificate formats, and transport blocks shared across multiple sections of a ClashRS configuration.
Scalar Types¶
BindAddress¶
Used by top-level bind-address and listeners[].listen. Accepted forms:
| Value | Parsed IP | Notes |
|---|---|---|
"*" |
0.0.0.0 |
All IPv4 interfaces |
"localhost" |
127.0.0.1 |
IPv4 loopback |
"::" or "[::]" |
:: |
Dual-stack / all IPv6 interfaces |
"127.0.0.1", "192.168.1.10", "::1" |
Exact IP literal | Any valid IPv4 or IPv6 address |
Port¶
Used by top-level port shortcuts (port, socks-port, mixed-port, redir-port, tproxy-port). Accepts either a YAML integer (7890) or a numeric string ("7890") in the u16 range (0..=65535).
Note
Inside listeners[] and proxies[], port must be a YAML integer (u16).
SocketMark¶
Unsigned 32-bit integer (u32) applied via SO_MARK on Linux (and Android builds with the tproxy feature). Ignored on other platforms.
- Linux: Directly sets
SO_MARK(0clears the mark). - Android (
socket_mark): Validated against mask0x7ce0_0000(bits 21–23 and 26–30 only) and bitwise-ORed onto the existing socket mark.
SocksAddr¶
Target address in host:port format (e.g. example.com:443, 192.0.2.53:53, [2001:db8::1]:443), where port must be non-zero. Used by tunnels, listeners (type: tunnel), and the /providers/rules/{name}/match API.
TLS Certificates (tls-cert / tls-key / certificate / private-key)¶
Where ClashRS accepts PEM certificates or private keys (outbound mTLS tls-cert/tls-key, inbound anytls/hysteria2 certificate/private-key, naive ca-cert), you may pass either:
- A file path (relative to
-d, validated bySafePaths), or - Inline PEM text containing
-----BEGIN(for example using a YAML block scalar|).
tls-cert: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
tls-key: |
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
Paired Requirement
tls-cert and tls-key (and inbound certificate and private-key) must both be set or both be omitted; specifying only one causes a configuration error.
Shared Outbound Transport Blocks¶
ws-opts¶
Used by trojan, vmess, and vless when network: ws (required when network: ws).
| Key | Type | Default | Description |
|---|---|---|---|
path |
string |
"" |
HTTP upgrade path (e.g. "/ws"). |
headers |
map[string -> string] |
{} |
Extra HTTP headers (commonly Host). |
max-early-data |
i32 |
0 |
Enables WebSocket 0-RTT early data when > 0. |
early-data-header-name |
string |
"" |
Header carrying early data (e.g. "Sec-WebSocket-Protocol"). |
h2-opts¶
Used by vmess and vless when network: h2 (required when network: h2).
| Key | Type | Default | Description |
|---|---|---|---|
host |
list[string] |
[server] |
List of HTTP/2 :authority hosts. |
path |
string |
"" |
HTTP/2 request path (e.g. "/h2"). |
grpc-opts¶
Used by trojan, vmess, and vless when network: grpc (required when network: grpc).
| Key | Type | Default | Description |
|---|---|---|---|
grpc-service-name |
string |
"" |
gRPC service name (sent as path "/{grpc-service-name}"). |
xhttp-opts (alias splithttp-opts)¶
Used by vmess and vless when network: xhttp or network: splithttp (optional; defaults apply if omitted).
| Key | Type | Default | Description |
|---|---|---|---|
path |
string |
"/" |
Request path (leading/trailing / normalized while preserving ?query). |
host |
string |
headers.Host or server |
Request host header. |
mode |
string |
"auto" |
Accepted for compatibility; ClashRS currently always streams over HTTP/2 POST. |
headers |
map[string -> string] |
{} |
Extra headers (Host and Referer are managed internally). |
x-padding-bytes |
string |
Random 100..=1000 bytes in Referer query |
Padding rule: "0" or "0-0" disables padding; accepts "min-max", a fixed integer, or a literal string (also sends X-Padding header when explicitly set). |
reality-opts¶
Used exclusively by vless to enable TLS REALITY (takes precedence over plain tls: true).
| Key | Type | Required | Description |
|---|---|---|---|
public-key |
string |
Yes | URL-safe unpadded Base64-encoded 32-byte X25519 public key. |
short-id |
string |
Yes | Hexadecimal short ID (may be empty ""). |