Skip to content

Freedom — Xray-core ​

Freedom is Xray's bypass outbound — it sends traffic to the real destination without any proxy protocol in the middle. Its own anti-DPI options — TCP/TLS fragmentation (fragment) and noise-packet injection (noises) — are deprecated: the same features are the fragment and noise masks of streamSettings.finalmask.

Outbound ​

settings for an outbound of "protocol": "freedom":

FieldTypeDefaultAllowed valuesDescription
targetStrategystringasisasis | useip | useipv4 | useipv6 | useipv4v6 | useipv6v4 | forceip | forceipv4 | forceipv6 | forceipv4v6 | forceipv6v4Deprecated — at startup a non-asis value is moved to streamSettings.sockopt.domainStrategy (same values) with a warning; set that instead. How the destination address is resolved before dial-out. asis passes through whatever the routing engine handed in; useip* resolves to IP only if needed; forceip* always resolves and replaces. The *v4v6 / *v6v4 suffixes control which family is tried first.
domainStrategystring(inherits targetStrategy)<same values>Legacy alias for targetStrategy. Read only when targetStrategy is empty. Deprecated together with targetStrategy.
redirectstring(unset)<host:port>Override the destination of every dial. Useful for forwarding to a local service regardless of routing.
userLeveluint320<uint32>Default policy level for connections passing through this outbound.
fragment*Fragment(disabled)FragmentDeprecated — use a fragment mask in streamSettings.finalmask.tcp; setting it logs a warning at startup. Per-segment TCP fragmentation for evading length-based DPI.
noise*Noise(unsupported)(use finalmask noise)Not supported — setting noise fails at startup. Use a noise mask in streamSettings.finalmask.udp.
noises[]*Noise(unset)[Noise]Deprecated — use a noise mask in streamSettings.finalmask.udp; setting it logs a warning at startup. Noise packets sent ahead of the first packet of each UDP flow to throw off pattern matching.
proxyProtocoluint3200 | 1 | 2Prepend a PROXY-protocol header on outgoing connections. 0 disables; 1 / 2 set v1 (text) or v2 (binary).
ipsBlocked*StringList(ignored)(use finalRules)Not supported — express IP blocks as finalRules; setting it only logs a warning and has no effect.
finalRules[]*FreedomFinalRuleConfig(unset)[FreedomFinalRuleConfig]Per-connection allow/block rules evaluated at dial time — a lightweight firewall on the outbound itself, matched by network / port / IP. Ignored (with a warning) when streamSettings.sockopt.dialerProxy is set.

Source: infra/conf/freedom.go:20-31 · pinned at v26.11.9 (676eaf6)

fragment ​

FieldTypeDefaultAllowed valuesDescription
packetsstring(all)tlshello | <from-to> | Which packets to fragment. tlshello fragments only the TLS ClientHello (subtler, useful for SNI obfuscation). A range like "1-3" fragments packets at that offset range. Empty fragments every packet — most aggressive.
length*Int32Range(required)<n> | "<min>-<max>"Range of bytes per fragment. Min must be > 0.
interval*Int32Range(required)<n> | "<min>-<max>"Range of milliseconds to delay between fragments.
maxSplit*Int32Range(unbounded)<n> | "<min>-<max>"Range of total splits per packet. Optional cap.

Source: infra/conf/freedom.go:33-38 · pinned at v26.11.9 (676eaf6)

noises[] ​

FieldTypeDefaultAllowed valuesDescription
typestring(required)rand | str | hex | base64Packet payload form. rand generates random bytes whose length comes from packet (a range string). str/hex/base64 interpret packet literally.
packetstring(required)<bytes or range>Payload content. Format depends on type.
delay*Int32Range(unset)<n> | "<min>-<max>"Range of milliseconds to wait after sending this noise packet.
applyTostringipip | all | ipv4 | ipv6Restrict noise injection to a single IP family. ip and all apply to both.

Source: infra/conf/freedom.go:40-45 · pinned at v26.11.9 (676eaf6)

finalRules[] ​

A small allow/block firewall the freedom outbound applies as it dials out. Rules are evaluated in order; the first match decides. IP blocking belongs here — the ipsBlocked field is ignored.

FieldTypeDefaultAllowed valuesDescription
actionstring(required)allow | blockWhat to do with a matching connection. block blackholes it — its data is discarded and the connection held open for delay, then closed; allow lets it through — list allow rules first to carve exceptions out of a broader block.
network*NetworkList(any)tcp | udp | tcp,udpMatch only these networks.
port*PortList(any)<port / range list>Match only these destination ports.
ip*StringList(any)<IP / CIDR / geoip:>Match only these destination IPs. Accepts geoip: categories.
delay*Int32Range30-90<seconds> | "<min>-<max>"block rules only — on an allow rule it fails at startup. Seconds a blocked connection is blackholed before it is closed; a range picks a random value, and 0 closes it at once.
logLevelstringinfodebug | info | warning | error | noneblock rules only — on an allow rule it fails at startup. Severity of the log lines written when this rule blocks a connection and when it closes it; none silences them. Unknown values fail at startup.
blockDelay*Int32Range(deprecated)(use delay)Deprecated — use delay. At startup a warning is logged and the value is copied into delay, replacing any delay on the same rule.

Source: infra/conf/freedom.go:47-55 · pinned at v26.11.9 (676eaf6)

Examples ​

Plain freedom outbound (passthrough):

json
{
  "outbounds": [
    { "tag": "direct", "protocol": "freedom", "settings": {} }
  ]
}

Force IPv4-then-IPv6 resolution:

json
{
  "outbounds": [
    {
      "tag": "direct-v4",
      "protocol": "freedom",
      "settings": {},
      "streamSettings": { "sockopt": { "domainStrategy": "forceipv4v6" } }
    }
  ]
}

TLS-hello fragmentation (good first try for SNI obfuscation) — a fragment mask in streamSettings.finalmask.tcp replaces the deprecated settings.fragment (the pause between fragments is called delay there):

json
{
  "outbounds": [
    {
      "tag": "frag",
      "protocol": "freedom",
      "settings": {},
      "streamSettings": {
        "finalmask": {
          "tcp": [
            {
              "type": "fragment",
              "settings": {
                "packets": "tlshello",
                "length": "10-20",
                "delay": "10-20"
              }
            }
          ]
        }
      }
    }
  ]
}

Noise injection — a noise mask in streamSettings.finalmask.udp replaces the deprecated settings.noises (here: 4 random bytes, then a 5–10 ms pause, before the first packet to each UDP destination):

json
{
  "outbounds": [
    {
      "tag": "noisy",
      "protocol": "freedom",
      "settings": {},
      "streamSettings": {
        "finalmask": {
          "udp": [
            {
              "type": "noise",
              "settings": {
                "noise": [
                  { "rand": 4, "delay": "5-10" }
                ]
              }
            }
          ]
        }
      }
    }
  ]
}

Blackhole QUIC (UDP/443) without logging it, and stall connections to private ranges for 2–5 minutes to slow down probing, logging them as warnings:

json
{
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {
        "finalRules": [
          { "action": "block", "network": "udp", "port": "443", "logLevel": "none" },
          { "action": "block", "ip": ["geoip:private"], "delay": "120-300", "logLevel": "warning" }
        ]
      }
    }
  ]
}

Forward everything to a local service (testing helper):

json
{
  "outbounds": [
    {
      "tag": "redir",
      "protocol": "freedom",
      "settings": { "redirect": "127.0.0.1:8080" }
    }
  ]
}

Notes ​

  • targetStrategy / domainStrategy in freedom settings are deprecated. At startup Xray moves a non-asis value into streamSettings.sockopt.domainStrategy and logs a warning; an outbound-level targetStrategy on a freedom outbound is migrated the same way (infra/conf/xray.go:410-433). The migrated value overwrites a sockopt.domainStrategy you set yourself, so configure only one of them. domainStrategy is still read only as a fallback when targetStrategy is empty (infra/conf/freedom.go:65-68).
  • With finalRules and a domain destination, freedom first resolves the domain (via sockopt.domainStrategy, or the system resolver when that is AsIs) to check block rules, then re-checks the address it actually connected to.
  • When streamSettings.sockopt.dialerProxy is set, freedom is not the final hop: finalRules are ignored (a warning is logged) and the domain is not pre-resolved.
  • Freedom rejects streamSettings.sockopt.addressPortStrategy at startup.
  • Unknown strategy strings produce a startup error rather than a silent fallback (infra/conf/freedom.go:92-93).
  • noise (singular) is not supported: setting it fails at startup with a message pointing to noises = [ { ... } ] (infra/conf/freedom.go:149-151), and noises itself is deprecated in favour of a noise mask in streamSettings.finalmask.udp.
  • ipsBlocked is not supported — express it as a { "action": "block", "ip": [...] } rule in finalRules; the field itself only logs a warning and is otherwise ignored.
  • finalRules actions are allow / block only (unknown actions error at startup). ip accepts geoip: categories. delay and logLevel are valid only on block rules — on an allow rule they fail at startup (infra/conf/freedom.go:290-295).
  • Default policy. When no finalRules entry matches, freedom falls back to a built-in block rule picked by the inbound the connection came through: traffic from vless, vmess, trojan, shadowsocks, hysteria, wireguard and masque inbounds is blocked when it targets a private / LAN address, and traffic arriving through a VLESS reverse tunnel is blocked entirely (both logged at warning). A matching allow rule wins, e.g. { "action": "allow", "ip": ["geoip:private"] }. The default does not apply when sockopt.dialerProxy is set.
  • fragment and noises still work but log a deprecation warning at startup. Their replacements are a fragment mask in streamSettings.finalmask.tcp (the pause between fragments is called delay there) and a noise mask in streamSettings.finalmask.udp (see the examples above).
  • fragment.packets: "tlshello" is the recommended starting point — fragmenting only the TLS ClientHello breaks SNI-based DPI but leaves the rest of the connection untouched (the byte-overhead is one-time).
  • fragment.length (with a non-zero minimum) and fragment.interval are required when fragment is present (infra/conf/freedom.go:122-139). The maxSplit range is optional. Ranges are written as a number or a "min-max" string — { "from": …, "to": … } objects are rejected.
  • proxyProtocol outside 1..2 is silently ignored — only those two values produce header output (infra/conf/freedom.go:186-188).

Cross-core notes ​

  • sing-box calls this Direct and the outbound has almost no options of its own — it has no destination-override fields; use route actions for that behavior. See Direct — sing-box.
  • mihomo has a similarly minimal Direct type; the built-in DIRECT proxy is implicit in every config. See Direct — mihomo.

Source: infra/conf/freedom.go:20-55 · v26.11.9 (676eaf6)

Core Tutorial by Argsment