{"record":{"id":"bc9875b9060378a2","repo":"shadowsocks/shadowsocks-rust","slug":"not-supported-protocol-p","errorCode":null,"errorMessage":"not supported `protocol` \"{p}\"","messagePattern":"not supported `protocol` \"(.+?)\"","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/local.rs","lineNumber":726,"sourceCode":"            // A socket `protect_path` in CWD\n            // Same as shadowsocks-libev's android.c\n            config.outbound_vpn_protect_path = Some(From::from(\"protect_path\"));\n        }\n\n        if matches.get_raw(\"LOCAL_ADDR\").is_some() || matches.get_raw(\"PROTOCOL\").is_some() {\n            let protocol = match matches.get_one::<String>(\"PROTOCOL\").map(|s| s.as_str()) {\n                Some(\"socks\") => ProtocolType::Socks,\n                #[cfg(feature = \"local-http\")]\n                Some(\"http\") => ProtocolType::Http,\n                #[cfg(feature = \"local-tunnel\")]\n                Some(\"tunnel\") => ProtocolType::Tunnel,\n                #[cfg(feature = \"local-redir\")]\n                Some(\"redir\") => ProtocolType::Redir,\n                #[cfg(feature = \"local-dns\")]\n                Some(\"dns\") => ProtocolType::Dns,\n                #[cfg(feature = \"local-tun\")]\n                Some(\"tun\") => ProtocolType::Tun,\n                Some(p) => panic!(\"not supported `protocol` \\\"{p}\\\"\"),\n                None => ProtocolType::Socks,\n            };\n\n            let mut local_config = LocalConfig::new(protocol);\n            match matches.get_one::<ServerAddr>(\"LOCAL_ADDR\").cloned() {\n                Some(local_addr) => local_config.addr = Some(local_addr),\n                None => {\n                    #[cfg(feature = \"local-tun\")]\n                    if protocol == ProtocolType::Tun {\n                        // `tun` protocol doesn't need --local-addr\n                    } else {\n                        panic!(\"`local-addr` is required for protocol {}\", protocol.as_str());\n                    }\n                }\n            }\n\n            if let Some(udp_bind_addr) = matches.get_one::<ServerAddr>(\"UDP_BIND_ADDR\").cloned() {\n                local_config.udp_addr = Some(udp_bind_addr);","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/local.rs#L708-L744","documentation":"The shadowsocks local server's CLI `create` fn maps the `--protocol` flag value to a ProtocolType enum. If the value is not one of the compiled-in variants (socks, http, tunnel, redir, dns, tun — some behind cargo features), it panics with this message. Note that protocols gated behind disabled features also land here, so a valid name can still panic if the feature isn't compiled in.","triggerScenarios":"Running `sslocal --protocol <p> ...` with a misspelled protocol name (e.g. `sock`, `tunn`), or with a valid name (http/tunnel/redir/dns/tun) whose cargo feature (local-http, local-tunnel, local-redir, local-dns, local-tun) was not enabled at build time, so the match arm doesn't exist.","commonSituations":"Typo in a shell alias or systemd unit; using a binary from a package manager built with default features while the docs show feature-gated protocols; copying examples that use `tun` into an environment with a minimal build.","solutions":["Fix the `--protocol` value to one of: socks, http, tunnel, redir, dns, tun","Rebuild sslocal with the matching feature enabled, e.g. `cargo build --features local-tun` for `--protocol tun`","Check `sslocal --help` / build features to see which protocols the installed binary supports","Drop the `--protocol` flag entirely to get the default SOCKS5 local server"],"exampleFix":"// before\nsslocal --protocol tun -b 127.0.0.1:1080 -s example.com:8388 -p pass\n// after (build with feature first)\ncargo build --features local-tun\nsslocal --protocol tun -s example.com:8388 -p pass","handlingStrategy":"validation","validationCode":"let supported = [\"socks\", \"http\", \"tunnel\", \"redir\", \"dns\", \"tun\"];\nlet p = std::env::args().nth(/* protocol position */ 0).unwrap_or_default();\nif !supported.contains(&p.as_str()) {\n    eprintln!(\"unsupported protocol {p}; supported: {supported:?}\");\n    std::process::exit(2);\n}","typeGuard":null,"tryCatchPattern":"// panic is not catchable in stable Rust; wrap process spawn instead:\nlet status = Command::new(\"sslocal\").args(&args).status()?;\nif !status.success() { /* inspect stderr for 'not supported `protocol`' */ }","preventionTips":["Validate the --protocol value against the supported list in your launcher script before exec","Build the binary with the cargo features for every protocol you plan to use (local-http, local-tun, local-redir, local-dns, local-tunnel)","Pin deployment scripts to the exact protocol strings from `sslocal --help`"],"tags":["cli","configuration","shadowsocks"],"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-14T11:17:12.474Z"}