{"record":{"id":"e9cbea895171cb78","repo":"XTLS/Xray-core","slug":"unsupported-address-and-port-strategy","errorCode":null,"errorMessage":"unsupported address and port strategy: ","messagePattern":"unsupported address and port strategy: ","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/transport_sockopt.go","lineNumber":154,"sourceCode":"\n\taddressPortStrategy := internet.AddressPortStrategy_None\n\tswitch strings.ToLower(c.AddressPortStrategy) {\n\tcase \"none\", \"\":\n\t\taddressPortStrategy = internet.AddressPortStrategy_None\n\tcase \"srvportonly\":\n\t\taddressPortStrategy = internet.AddressPortStrategy_SrvPortOnly\n\tcase \"srvaddressonly\":\n\t\taddressPortStrategy = internet.AddressPortStrategy_SrvAddressOnly\n\tcase \"srvportandaddress\":\n\t\taddressPortStrategy = internet.AddressPortStrategy_SrvPortAndAddress\n\tcase \"txtportonly\":\n\t\taddressPortStrategy = internet.AddressPortStrategy_TxtPortOnly\n\tcase \"txtaddressonly\":\n\t\taddressPortStrategy = internet.AddressPortStrategy_TxtAddressOnly\n\tcase \"txtportandaddress\":\n\t\taddressPortStrategy = internet.AddressPortStrategy_TxtPortAndAddress\n\tdefault:\n\t\treturn nil, errors.New(\"unsupported address and port strategy: \", c.AddressPortStrategy)\n\t}\n\n\thappyEyeballs := &internet.HappyEyeballsConfig{Interleave: 1, PrioritizeIpv6: false, TryDelayMs: 0, MaxConcurrentTry: 4}\n\tif c.HappyEyeballsSettings != nil {\n\t\thappyEyeballs.PrioritizeIpv6 = c.HappyEyeballsSettings.PrioritizeIPv6\n\t\thappyEyeballs.Interleave = c.HappyEyeballsSettings.Interleave\n\t\thappyEyeballs.TryDelayMs = c.HappyEyeballsSettings.TryDelayMs\n\t\thappyEyeballs.MaxConcurrentTry = c.HappyEyeballsSettings.MaxConcurrentTry\n\t}\n\n\treturn &internet.SocketConfig{\n\t\tMark:                 c.Mark,\n\t\tTfo:                  tfo,\n\t\tTproxy:               tproxy,\n\t\tDomainStrategy:       dStrategy,\n\t\tAcceptProxyProtocol:  c.AcceptProxyProtocol,\n\t\tDialerProxy:          c.DialerProxy,\n\t\tTcpKeepAliveInterval: c.TCPKeepAliveInterval,","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/transport_sockopt.go#L136-L172","documentation":"Thrown while building SocketConfig when the 'addressPortStrategy' string inside 'sockopt' does not match any supported value. Accepted values (lowercase, as handled by the switch) include srvportonly, srvaddressonly, srvportandaddress, txtportonly, txtaddressonly, txtportandaddress (plus the other branches above the shown region). Any other string hits the default branch and fails the whole config build.","triggerScenarios":"Setting \"sockopt\": { \"addressPortStrategy\": \"srv\" }, \"SrvPortOnly\" (wrong case), or \"txt\" in streamSettings, then starting Xray or reloading config.","commonSituations":"Guessing/abbreviating the strategy name instead of copying the documented literal, using uppercase from documentation prose, or trailing spaces from copy-paste.","solutions":["Use an exact literal: \"srvportonly\", \"srvaddressonly\", \"srvportandaddress\", \"txtportonly\", \"txtaddressonly\", \"txtportandaddress\" (lowercase)","Remove the addressPortStrategy key if SRV/TXT-based resolution is not intended"],"exampleFix":"// before\n\"sockopt\": { \"addressPortStrategy\": \"SrvPortOnly\" }\n// after\n\"sockopt\": { \"addressPortStrategy\": \"srvportonly\" }","handlingStrategy":"validation","validationCode":"var addressPortStrategies = map[string]bool{\n    \"\": true, \"srvportonly\": true, \"srvaddressonly\": true, \"srvportandaddress\": true,\n    \"txtportonly\": true, \"txtaddressonly\": true, \"txtportandaddress\": true,\n}\nif s, ok := sockopt[\"addressPortStrategy\"]; ok {\n    if !addressPortStrategies[s.(string)] {\n        return fmt.Errorf(\"invalid sockopt.addressPortStrategy: %q\", s)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy the exact lowercase literal from the Xray docs","Add a lint step that checks enum-like strings against allow-lists"],"tags":["config","dns","srv","socket"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}