MASQUE — Xray-core
Xray-core implements MASQUE CONNECT-IP (RFC 9484): an IP tunnel carried inside an HTTP/3 request — or an HTTP/2 extended CONNECT (RFC 8441) — over TLS. masque is both an outbound and an inbound protocol and comes with a transport of its own: both sides set streamSettings.network to "masque" and security to "tls", and the tunnel options live in streamSettings.masqueSettings. The outbound runs Xray's built-in lightweight TCP/IP stack on top of the tunnel, so any TCP or UDP target is reachable through it; it can also connect to Cloudflare WARP. The inbound gives each client tunnel addresses from its address prefixes and hands the traffic to routing.
Outbound — settings
settings for an outbound of "protocol": "masque":
| Field | Type | Default | Allowed values | Description |
|---|---|---|---|---|
address | *Address | (required) | <host> | MASQUE server hostname or IP. Missing → startup error MASQUE: "address" is not set. |
port | uint16 | (required) | <port> | Server port — UDP for HTTP/3, TCP for HTTP/2. |
remoteDNS | []string | [1.1.1.1, 1.0.0.1, 2606:4700:4700::1111, 2606:4700:4700::1001] | [<IP>, …] | DNS servers queried through the tunnel when a target is a domain name. Entries must be IP literals — anything else (including "local") fails at startup. Only servers of an address family the tunnel was assigned are used; when none matches, Xray logs a warning that domain names will fail to resolve. |
Source: infra/conf/masque.go:14-18 · pinned at v26.11.9 (676eaf6)
There is no credential here: the client's user name and password go in streamSettings.masqueSettings (below).
Inbound — settings
settings for an inbound of "protocol": "masque":
| Field | Type | Default | Allowed values | Description |
|---|---|---|---|---|
users | []*MasqueUserConfig | [] | [MasqueUserConfig] | Accepted users. users and clients are interchangeable keys with the same shape; clients wins when both are set. |
clients | []*MasqueUserConfig | [] | [MasqueUserConfig] | Accepted users (alternative key; same shape as users). |
address | []string | (required) | ["<IPv4>/<len>", "<IPv6>/<len>"] | Tunnel subnets: at most one IPv4 and one IPv6 prefix, each written as the server's own tunnel address plus prefix length (e.g. 10.14.0.1/24). The server keeps that address and gives every client one other host address of each prefix. It must be a host address (not the network address, nor the IPv4 broadcast address), and the prefix must leave addresses to assign. A client still gets a tunnel when only one family has a free address; with none left, the request is answered 503. |
mtu | uint32 | 1280 | 1280–65535 | MTU of the server-side TCP/IP stack. 0 means 1280; any other value outside 1280–65535 fails at startup. |
Source: infra/conf/masque.go:47-52 · pinned at v26.11.9 (676eaf6)
clients[]
| Field | Type | Default | Allowed values | Description |
|---|---|---|---|---|
pass | string | (required) | <string> | Password — the client sends it as the HTTP Basic password (masqueSettings.pass). |
level | uint32 | 0 | <uint32> | Policy level for this user. |
email | string | (required) | <string without :> | User name — the client sends it as the HTTP Basic user (masqueSettings.user); matched case-insensitively. Must be non-empty, unique (ignoring case) and free of :. Also labels the user in stats and logs. |
Source: infra/conf/masque.go:41-45 · pinned at v26.11.9 (676eaf6)
Transport — masqueSettings
Set under streamSettings.masqueSettings. The inbound only reads path; everything else is client-side.
| Field | Type | Default | Allowed values | Description |
|---|---|---|---|---|
host | string | (TLS server name) | <host>[:<port>] | Client: the :authority of the CONNECT-IP request. Empty → the TLS server name (tlsSettings.serverName, else the outbound address) plus :port when the port isn't 443; with warp, empty → cloudflareaccess.com. Must be a bare host with an optional port. Ignored by the inbound. |
path | string | /.well-known/masque/ip/*/*/ | /<path> | <RFC 9484 URI template> | Request path; must start with /. The RFC 9484 template variables {target} and {ipproto} (including the {?target,ipproto} and {&target,ipproto} forms) are replaced with *; any other {…} fails at startup. The inbound answers 404 unless path and query match exactly, so set the same value on both sides. With warp, empty → /. |
user | string | (unset) | <string without :> | Client: HTTP Basic user name, sent as an Authorization: Basic header — an Xray inbound matches it against the user's email. Can't be combined with warp or with an Authorization entry in headers. |
pass | string | (unset) | <string> | Client: HTTP Basic password — the inbound user's pass. Can't be combined with warp. |
headers | map[string]string | {} | {<header>: <value>} | Client: extra request headers. Host and Capsule-Protocol are rejected, and so is Authorization when user / pass is set. User-Agent defaults to Chrome's; the values chrome, firefox, safari, edge and curl select that client's string, golang keeps the HTTP library's default and an empty string sends no User-Agent at all. |
warp | *MasqueWarpConfig | (unset) | MasqueWarpConfig | Client: connect to Cloudflare WARP instead of a Basic-auth server — see the warp table below. |
xmux | XmuxConfig | {maxConnections: 1, hMaxReusableSecs: 1800-3000} | XmuxConfig | Client: pool of CONNECT-IP tunnels. Each XMUX connection is one tunnel with its own HTTP/3 or HTTP/2 connection and its own assigned addresses. Empty → one tunnel, replaced after 1800–3000 s. maxConnections (tunnels) and maxConcurrency (proxied connections per tunnel) can't both be set. hKeepAlivePeriod is the keep-alive interval in seconds (QUIC keep-alive or HTTP/2 PING); a negative value turns it off. |
Source: infra/conf/transport_method.go:806-814 · pinned at v26.11.9 (676eaf6)
warp
With warp set, the client authenticates to Cloudflare WARP with a client certificate instead of user / pass, pins the endpoint's public key, uses the cf-connect-ip request protocol and takes its addresses from address.
| Field | Type | Default | Allowed values | Description |
|---|---|---|---|---|
privateKey | string | (required) | <PEM> | <base64 DER> | The WARP device's ECDSA P-256 private key, PKCS #8 or SEC 1, as PEM or base64 DER. Xray presents a fresh self-signed client certificate made from it on every connection. |
publicKey | string | (required) | <PEM> | <base64 DER> | The WARP endpoint's public key (PKIX, PEM or base64 DER); the server certificate must carry exactly this key. Always required, but ignored when tlsSettings sets pinnedPeerCertSha256 or verifyPeerCertByName — those then verify the server instead, which allows domain fronting. |
address | []string | (required) | ["<IPv4>", "<IPv6>"] | Tunnel addresses WARP assigned to this device: at most one IPv4 and one IPv6, as plain IPs or CIDR. They become the tunnel's local addresses; no address is requested from the server. |
Source: infra/conf/transport_method.go:800-804 · pinned at v26.11.9 (676eaf6)
Examples
Server — HTTP/3 on UDP 443, one user, an IPv4 and an IPv6 pool:
{
"inbounds": [
{
"tag": "masque-in",
"listen": "0.0.0.0",
"port": 443,
"protocol": "masque",
"settings": {
"clients": [
{ "email": "alice", "pass": "<password>" }
],
"address": ["10.14.0.1/24", "fd14::1/64"]
},
"streamSettings": {
"network": "masque",
"security": "tls",
"tlsSettings": {
"certificates": [
{ "certificateFile": "/etc/ssl/cert.pem", "keyFile": "/etc/ssl/key.pem" }
]
}
}
}
],
"outbounds": [
{ "protocol": "freedom" }
]
}Client for that server:
{
"outbounds": [
{
"tag": "masque-out",
"protocol": "masque",
"settings": {
"address": "masque.example.com",
"port": 443
},
"streamSettings": {
"network": "masque",
"security": "tls",
"tlsSettings": { "serverName": "masque.example.com" },
"masqueSettings": {
"user": "alice",
"pass": "<password>"
}
}
}
]
}To use HTTP/2 instead, give the server "alpn": ["h3", "h2"] (it then also listens on TCP 443) or ["h2"] (TCP only), and the client "alpn": ["h2"] in tlsSettings.
Client for Cloudflare WARP (key pair, endpoint key and addresses come from an existing WARP registration — Xray doesn't register devices):
{
"outbounds": [
{
"tag": "warp",
"protocol": "masque",
"settings": {
"address": "<WARP endpoint IP>",
"port": 443
},
"streamSettings": {
"network": "masque",
"security": "tls",
"tlsSettings": { "serverName": "consumer-masque.cloudflareclient.com" },
"masqueSettings": {
"warp": {
"privateKey": "<base64 EC private key>",
"publicKey": "<base64 endpoint public key>",
"address": ["<IPv4 from WARP>", "<IPv6 from WARP>"]
}
}
}
}
]
}Notes
- Both sides need
"network": "masque"and"security": "tls". Themasqueprotocol refuses other transports, themasquetransport refuses other protocols (the masque transport can only be used by the masque inbound/outbound), and a missing TLS layer fails withMASQUE requires "security": "tls"— all at startup. REALITY can't carry MASQUE. - HTTP/3 or HTTP/2. The client uses HTTP/3 (QUIC over UDP) unless
tlsSettings.alpncontainsh2but noth3; then it sends an HTTP/2 extended CONNECT over TCP. The server listens for HTTP/3 on UDP by default;alpn: ["h2"]switches it to HTTP/2 on TCP, and["h3", "h2"]serves both on the same port. Every tunnel is its own QUIC connection, or its own TCP connection carrying a single CONNECT-IP stream. - Over HTTP/3,
finalmask.quicParamstunes QUIC (BBR unlesscongestionisrenoorforce-brutal; itskeepAlivePeriodoverridesxmux.hKeepAlivePeriod). Over HTTP/2, the TLSfingerprintshapes the ClientHello (Chrome when unset).finalmaskUDP masks wrap the QUIC packets, TCP masks the HTTP/2 connection. - Client side. The outbound asks the server for an IPv4 and an IPv6 address (or takes
warp.address) and runs Xray's built-in lightweight TCP/IP stack on the tunnel, much like the WireGuard outbound: TCP and UDP targets are dialed through that stack, and domain targets are resolved through the tunnel viaremoteDNS. The tunnel must carry IP packets of at least 1280 bytes, otherwise it isn't established. - Server side. The inbound checks the
Authorization: Basiccredentials againstemail/pass(a wrong path gets404, wrong credentials401withWWW-Authenticate: Basic realm="masque"), assigns addresses, advertises full IPv4 / IPv6 routes and feeds the packets into the built-in TCP/IP stack. The resulting TCP / UDP connections reach routing as coming from this inbound, with the user'semailandleveland the inbound'ssniffingsettings. Packets for another connected client's tunnel address go straight to that client; packets for unassigned addresses of the prefixes are dropped. - Private destinations are blocked by default. Connections that arrive through a MASQUE inbound and leave through a freedom outbound get freedom's default safe policy: private and LAN addresses are blocked unless a
finalRulesentry matches them first. - Users can be added and removed at runtime through the API (
xray api adu/xray api rmu); removing a user closes that user's tunnels.
Cross-core notes
- sing-box has no MASQUE / CONNECT-IP protocol. Its IP-level tunnels are endpoints such as WireGuard — sing-box.
- mihomo has a client-only
type: masqueproxy aimed at Cloudflare WARP: a base64 ECDSAprivate-key, the endpoint'spublic-key, fixedip/ipv6addresses, HTTP/3 by default ornetwork: h2. It has no user name / password option and no MASQUE listener, so it neither serves MASQUE nor logs in to an Xray MASQUE inbound; Xray's counterpart to that setup is thewarpblock above.
Source: infra/conf/masque.go:14-103 · v26.11.9 (676eaf6)
