{"record":{"id":"0bd40b0f4daeebe8","repo":"shadowsocks/shadowsocks-rust","slug":"plugin-mode-must-be-one-of-tcp-only-default","errorCode":null,"errorMessage":"plugin-mode must be one of `tcp_only` (default), `udp_only` and `tcp_and_udp`","messagePattern":"plugin-mode must be one of `tcp_only` \\(default\\), `udp_only` and `tcp_and_udp`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/local.rs","lineNumber":675,"sourceCode":"                Err(err) => {\n                    panic!(\"failed to create ServerConfig, error: {}\", err);\n                }\n            };\n            sc.set_source(ServerSource::CommandLine);\n            if let Some(timeout) = timeout {\n                sc.set_timeout(timeout);\n            }\n\n            if let Some(p) = matches.get_one::<String>(\"PLUGIN\").cloned() {\n                let plugin = PluginConfig {\n                    plugin: p,\n                    plugin_opts: matches.get_one::<String>(\"PLUGIN_OPT\").cloned(),\n                    plugin_args: Vec::new(),\n                    plugin_mode: matches\n                        .get_one::<String>(\"PLUGIN_MODE\")\n                        .map(|x| {\n                            x.parse::<Mode>()\n                                .expect(\"plugin-mode must be one of `tcp_only` (default), `udp_only` and `tcp_and_udp`\")\n                        })\n                        .unwrap_or(Mode::TcpOnly),\n                };\n\n                sc.set_plugin(plugin);\n            }\n\n            config.server.push(ServerInstanceConfig::with_server_config(sc));\n        }\n\n        if let Some(mut svr_addr) = matches.get_one::<ServerConfig>(\"SERVER_URL\").cloned() {\n            svr_addr.set_source(ServerSource::CommandLine);\n            config.server.push(ServerInstanceConfig::with_server_config(svr_addr));\n        }\n\n        #[cfg(feature = \"local-flow-stat\")]\n        {\n            use shadowsocks_service::config::LocalFlowStatAddress;","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/local.rs#L657-L693","documentation":"When --plugin is configured, the optional PLUGIN_MODE value is parsed into the Mode enum (TcpOnly/UdpOnly/TcpAndUdp); an unknown string makes .parse fail and the expect panics with this message. It restricts plugin-mode to the three documented values, defaulting to tcp_only when the flag is absent.","triggerScenarios":"Running sslocal with --plugin and --plugin-mode set to something other than tcp_only, udp_only, or tcp_and_udp — e.g. \"both\", \"tcp\", \"TCP_ONLY\", or a mode supported only by ssserver.","commonSituations":"Case sensitivity mistakes; inventing mode names; copying server-side mode values that don't exist for the local plugin path; config generators emitting wrong keys.","solutions":["Use exactly one of: tcp_only, udp_only, tcp_and_udp (lowercase, underscores).","Omit --plugin-mode to get the tcp_only default.","Check the Mode enum's FromStr for the accepted spellings of your binary version."],"exampleFix":"// before\nsslocal --plugin v2ray-plugin --plugin-mode both ...\n\n// after\nsslocal --plugin v2ray-plugin --plugin-mode tcp_and_udp ...","handlingStrategy":"validation","validationCode":"const VALID_MODES: [&str; 3] = [\"tcp_only\", \"udp_only\", \"tcp_and_udp\"];\nif let Some(m) = matches.get_one::<String>(\"PLUGIN_MODE\") {\n    if !VALID_MODES.contains(&m.as_str()) {\n        return Err(format!(\"invalid plugin-mode: {}\", m));\n    }\n}","typeGuard":null,"tryCatchPattern":"let mode = m.parse::<Mode>().unwrap_or_else(|_| {\n    eprintln!(\"plugin-mode must be tcp_only, udp_only or tcp_and_udp\");\n    std::process::exit(2);\n});","preventionTips":["Only use the exact lowercase underscore forms: tcp_only, udp_only, tcp_and_udp.","Omit --plugin-mode to accept the tcp_only default.","Generate plugin flags from a checked template, not free text."],"tags":["cli","rust","plugin","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-14T11:17:12.474Z"}