{"record":{"id":"22ded333c9078987","repo":"shadowsocks/shadowsocks-rust","slug":"server-addr","errorCode":null,"errorMessage":"server-addr","messagePattern":"server-addr","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/local.rs","lineNumber":652,"sourceCode":"                .expect(\"`method` is required\");\n\n            let password = match matches.get_one::<String>(\"PASSWORD\") {\n                Some(pwd) => read_variable_field_value(pwd).into(),\n                None => {\n                    // NOTE: svr_addr should have been checked by crate::vparser\n                    if method.is_none() {\n                        // If method doesn't need a key (none, plain), then we can leave it empty\n                        String::new()\n                    } else {\n                        match crate::password::read_server_password(svr_addr) {\n                            Ok(pwd) => pwd,\n                            Err(..) => panic!(\"`password` is required for server {svr_addr}\"),\n                        }\n                    }\n                }\n            };\n\n            let svr_addr = svr_addr.parse::<ServerAddr>().expect(\"server-addr\");\n            let timeout = matches.get_one::<u64>(\"TIMEOUT\").map(|x| Duration::from_secs(*x));\n\n            let mut sc = match ServerConfig::new(svr_addr, password, method) {\n                Ok(sc) => sc,\n                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(),","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/local.rs#L634-L670","documentation":"The per-server SERVER_ADDR value is parsed into a ServerAddr via FromStr; an unparseable address makes .expect(\"server-addr\") panic. ServerAddr accepts host:port or domain:port (optionally with a URI-ish form), so the string must resolve to a valid target server.","triggerScenarios":"Passing a malformed SERVER_ADDR to sslocal, e.g. missing port (`example.com`), non-numeric port (`example.com:https`), empty string, or bracket mishandling for IPv6 (`::1:8388` instead of `[::1]:8388`).","commonSituations":"Hand-edited scripts; IPv6 addresses without brackets; whitespace or quotes captured into the argument; SIP002 URLs pasted into the wrong flag.","solutions":["Format the address as host:port, e.g. example.com:8388 or 1.2.3.4:8388.","Wrap IPv6 literals in brackets: [2001:db8::1]:8388.","Validate/trim the value in your launcher script before passing it."],"exampleFix":"// before\nsslocal -b 127.0.0.1:1080 -s \"example.com\" ...\n\n// after\nsslocal -b 127.0.0.1:1080 -s \"example.com:8388\" ...","handlingStrategy":"validation","validationCode":"fn validate_server_addr(s: &str) -> Result<(), String> {\n    s.parse::<shadowsocks::config::ServerAddr>()\n        .map(|_| ())\n        .map_err(|_| format!(\"invalid server-addr '{}': expected host:port\", s))\n}","typeGuard":null,"tryCatchPattern":"let addr = s.parse::<ServerAddr>().unwrap_or_else(|_| {\n    eprintln!(\"invalid server-addr: {}\", s);\n    std::process::exit(2);\n});","preventionTips":["Always include the port; bracket IPv6 literals like [::1]:8388.","Trim whitespace and stray quotes from values in scripts.","Use sip002 URLs only with the URL input path, not the -s flag."],"tags":["cli","rust","address-parsing","panic"],"backgroundTag":"invalid-argument-format","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"}