{"record":{"id":"8f32e9ba77177ba0","repo":"shadowsocks/shadowsocks-rust","slug":"tcp-redir","errorCode":null,"errorMessage":"tcp-redir","messagePattern":"tcp-redir","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/local.rs","lineNumber":761,"sourceCode":"            if let Some(udp_bind_addr) = matches.get_one::<ServerAddr>(\"UDP_BIND_ADDR\").cloned() {\n                local_config.udp_addr = Some(udp_bind_addr);\n            }\n\n            if let Some(udp_associate_addr) = matches.get_one::<ServerAddr>(\"UDP_ASSOCIATE_ADDR\").cloned() {\n                local_config.udp_associate_addr = Some(udp_associate_addr);\n            }\n\n            #[cfg(feature = \"local-tunnel\")]\n            if let Some(addr) = matches.get_one::<Address>(\"FORWARD_ADDR\").cloned() {\n                local_config.forward_addr = Some(addr);\n            }\n\n            #[cfg(feature = \"local-redir\")]\n            {\n                if RedirType::tcp_default() != RedirType::NotSupported\n                    && let Some(tcp_redir) = matches.get_one::<String>(\"TCP_REDIR\")\n                {\n                    local_config.tcp_redir = tcp_redir.parse::<RedirType>().expect(\"tcp-redir\");\n                }\n\n                if RedirType::udp_default() != RedirType::NotSupported\n                    && let Some(udp_redir) = matches.get_one::<String>(\"UDP_REDIR\")\n                {\n                    local_config.udp_redir = udp_redir.parse::<RedirType>().expect(\"udp-redir\");\n                }\n            }\n\n            #[cfg(feature = \"local-dns\")]\n            {\n                use shadowsocks_service::local::dns::NameServerAddr;\n\n                use self::local_value_parser::RemoteDnsAddress;\n\n                if let Some(addr) = matches.get_one::<NameServerAddr>(\"LOCAL_DNS_ADDR\").cloned() {\n                    local_config.local_dns_addr = Some(addr);\n                }","sourceCodeStart":743,"sourceCodeEnd":779,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/local.rs#L743-L779","documentation":"Under the local-redir feature, the TCP_REDIR value is parsed into a RedirType (e.g. redirect, tproxy, not-supported per platform); an unknown name makes .expect(\"tcp-redir\") panic. Parsing is guarded so it only runs when the platform supports a TCP redirect mode at all.","triggerScenarios":"Running sslocal with --tcp-redir set to a value RedirType::from_str doesn't recognize on this platform — e.g. \"tproxy\" on a build/platform where only \"redirect\" is valid, or misspelled names like \"tpproxy\".","commonSituations":"Copying Linux tproxy examples onto a macOS/BSD build; feature flags compiled out; case/typo errors; using names from other proxy tools (e.g. \"nftables\").","solutions":["Use a valid RedirType for your platform: typically \"redirect\" or \"tproxy\" on Linux; check RedirType docs for the compiled feature set.","Verify the local-redir feature and OS support before using the flag; omit --tcp-redir if redirect is unsupported.","Log RedirType::tcp_default() in a debug build to see the accepted default for the platform."],"exampleFix":"// before\nsslocal --tcp-redir tproxy ...   # on a platform without tproxy\n\n// after\nsslocal --tcp-redir redirect ...   # or omit --tcp-redir","handlingStrategy":"validation","validationCode":"if let Some(s) = matches.get_one::<String>(\"TCP_REDIR\") {\n    if s.parse::<shadowsocks::local::net::RedirType>().is_err() {\n        return Err(format!(\"invalid tcp-redir for this platform: {}\", s));\n    }\n}","typeGuard":null,"tryCatchPattern":"let t = s.parse::<RedirType>().unwrap_or_else(|_| {\n    eprintln!(\"invalid tcp-redir: {}\", s);\n    std::process::exit(2);\n});","preventionTips":["Check platform support (RedirType::tcp_default() != NotSupported) before enabling the flag.","Use \"redirect\" or \"tproxy\" only, spelled exactly, on Linux.","Guard feature-dependent flags behind OS checks in deployment scripts."],"tags":["cli","rust","redirect","enum","panic"],"backgroundTag":"invalid-enum-value","analyzedSha":"8eb0f0a65b1d976ab6bed5787327ef86529b0435","analyzedAt":"2026-09-09T12:20:43.168Z","contentChangedAt":"2026-09-09T12:20:43.168Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}