{"record":{"id":"3cf9c9f2119eba28","repo":"XTLS/Xray-core","slug":"invalid-applyto-only-ip-ipv4-ipv6-are-supported","errorCode":null,"errorMessage":"Invalid applyTo, only ip/ipv4/ipv6 are supported","messagePattern":"Invalid applyTo, only ip/ipv4/ipv6 are supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/freedom.go","lineNumber":247,"sourceCode":"\t\t}\n\n\tdefault:\n\t\treturn nil, errors.New(\"Invalid packet, only rand/str/hex/base64 are supported\")\n\t}\n\n\tif noise.Delay != nil {\n\t\tNConfig.DelayMin = uint64(noise.Delay.From)\n\t\tNConfig.DelayMax = uint64(noise.Delay.To)\n\t}\n\tswitch strings.ToLower(noise.ApplyTo) {\n\tcase \"\", \"ip\", \"all\":\n\t\tNConfig.ApplyTo = \"ip\"\n\tcase \"ipv4\":\n\t\tNConfig.ApplyTo = \"ipv4\"\n\tcase \"ipv6\":\n\t\tNConfig.ApplyTo = \"ipv6\"\n\tdefault:\n\t\treturn nil, errors.New(\"Invalid applyTo, only ip/ipv4/ipv6 are supported\")\n\t}\n\treturn NConfig, nil\n}\n\nfunc (c *FreedomFinalRuleConfig) Build() (*freedom.FinalRuleConfig, error) {\n\trule := &freedom.FinalRuleConfig{}\n\n\tswitch strings.ToLower(c.Action) {\n\tcase \"allow\":\n\t\trule.Action = freedom.RuleAction_Allow\n\tcase \"block\":\n\t\trule.Action = freedom.RuleAction_Block\n\tdefault:\n\t\treturn nil, errors.New(\"unknown action: \", c.Action)\n\t}\n\n\tif c.Network != nil {\n\t\trule.Networks = c.Network.Build()","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/freedom.go#L229-L265","documentation":"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.","triggerScenarios":"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).","commonSituations":"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'.","solutions":["Set applyTo to one of: omit it, \"ip\", \"all\", \"ipv4\", or \"ipv6\"","Use \"ip\" or omit the field when you want noise applied to both address families","Split into two freedom outbounds with separate noise configs if you need different behavior per family"],"exampleFix":"// before\n\"noise\": { \"packet\": \"str:x\", \"applyTo\": \"both\" }\n// after\n\"noise\": { \"packet\": \"str:x\", \"applyTo\": \"ip\" }","handlingStrategy":"validation","validationCode":"func validApplyTo(s string) bool {\n\tswitch strings.ToLower(s) {\n\tcase \"\", \"ip\", \"all\", \"ipv4\", \"ipv6\":\n\t\treturn true\n\t}\n\treturn false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict applyTo in config templates to a dropdown of ip/ipv4/ipv6","Remember 'all' and empty both mean both families"],"tags":["xray","config","freedom","noise","validation"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}