XTLS/Xray-core · error

Invalid applyTo, only ip/ipv4/ipv6 are supported

Error message

Invalid applyTo, only ip/ipv4/ipv6 are supported

What it means

Thrown when building the freedom noise config if noise.applyTo is not one of ip, ipv4, ipv6, all, or empty. The applyTo field controls whether the noise packet is sent to IPv4 destinations, IPv6 destinations, or both; an empty string or 'all' maps to 'ip' (both). Any other value reaches the default branch and is rejected.

Source

Thrown at infra/conf/freedom.go:247

		}

	default:
		return nil, errors.New("Invalid packet, only rand/str/hex/base64 are supported")
	}

	if noise.Delay != nil {
		NConfig.DelayMin = uint64(noise.Delay.From)
		NConfig.DelayMax = uint64(noise.Delay.To)
	}
	switch strings.ToLower(noise.ApplyTo) {
	case "", "ip", "all":
		NConfig.ApplyTo = "ip"
	case "ipv4":
		NConfig.ApplyTo = "ipv4"
	case "ipv6":
		NConfig.ApplyTo = "ipv6"
	default:
		return nil, errors.New("Invalid applyTo, only ip/ipv4/ipv6 are supported")
	}
	return NConfig, nil
}

func (c *FreedomFinalRuleConfig) Build() (*freedom.FinalRuleConfig, error) {
	rule := &freedom.FinalRuleConfig{}

	switch strings.ToLower(c.Action) {
	case "allow":
		rule.Action = freedom.RuleAction_Allow
	case "block":
		rule.Action = freedom.RuleAction_Block
	default:
		return nil, errors.New("unknown action: ", c.Action)
	}

	if c.Network != nil {
		rule.Networks = c.Network.Build()

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Set applyTo to one of: omit it, "ip", "all", "ipv4", or "ipv6"
  2. Use "ip" or omit the field when you want noise applied to both address families
  3. Split into two freedom outbounds with separate noise configs if you need different behavior per family

Example fix

// before
"noise": { "packet": "str:x", "applyTo": "both" }
// after
"noise": { "packet": "str:x", "applyTo": "ip" }
Defensive patterns

Strategy: validation

Validate before calling

func validApplyTo(s string) bool {
	switch strings.ToLower(s) {
	case "", "ip", "all", "ipv4", "ipv6":
		return true
	}
	return false
}

Prevention

When it happens

Trigger: Setting freedom.outboundSettings.noise.applyTo to values like 'both', 'tcp', 'domain', or 'IPV4' with unexpected casing/typos (values are lowercased before matching, so correct casing of ip/ipv4/ipv6 works).

Common situations: Users assuming 'both' is the way to cover both address families; copying configs from forks that accept extra applyTo values; typos such as 'ipv4v6' or 'v4'.

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/3cf9c9f2119eba28. Report an issue: GitHub.