{"record":{"id":"0fb83543a11468a9","repo":"shadowsocks/shadowsocks-rust","slug":"create-local","errorCode":null,"errorMessage":"create local","messagePattern":"create local","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/service/local.rs","lineNumber":1004,"sourceCode":"            RuntimeMode::MultiThread => {\n                let mut builder = Builder::new_multi_thread();\n                if let Some(worker_threads) = service_config.runtime.worker_count {\n                    builder.worker_threads(worker_threads);\n                }\n\n                builder\n            }\n        };\n\n        let runtime = builder.enable_all().build().expect(\"create tokio Runtime\");\n\n        (config, service_config, runtime)\n    };\n\n    let main_fut = async move {\n        let config_path = config.config_path.clone();\n\n        let instance = Server::new(config).await.expect(\"create local\");\n\n        let reload_task = match config_path {\n            Some(config_path) => ServerReloader {\n                config_path: config_path.clone(),\n                balancer: instance.server_balancer().clone(),\n            }\n            .launch_reload_server_task()\n            .boxed(),\n            None => future::pending().boxed(),\n        };\n\n        let abort_signal = monitor::create_signal_monitor();\n        let server = instance.run();\n\n        let reload_task = reload_task.fuse();\n        let abort_signal = abort_signal.fuse();\n        let server = server.fuse();\n","sourceCodeStart":986,"sourceCodeEnd":1022,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/local.rs#L986-L1022","documentation":"After building the tokio runtime, `create` calls `Server::new(config).await.expect(\"create local\")` to construct the local server instance. The panic means the server could not be created from the supplied configuration — typically invalid listener addresses, failed binding-related setup, or bad config values rejected by `Server::new`. Process exits immediately at startup.","triggerScenarios":"`Server::new(config)` returning Err inside `create`, called from `main`: unparseable or unusable server configuration (bad local address, invalid plugin/balancer config, failed ACL/DNS setup).","commonSituations":"Malformed `-b`/`--bind-addr` values, invalid server address strings in the local forward config, config-file entries that `Server::new` cannot materialize, plugin paths that don't exist.","solutions":["Validate the server config (addresses, ports, method/password) before starting","Check the underlying error logged before the panic — fix the offending config field","Test the config with `sslocal --check-config` if available","Ensure bind addresses are valid IP:port and not already restricted"],"exampleFix":"// before\nsslocal -b \"localhost:notaport\" -s ... \n// after\nsslocal -b \"127.0.0.1:1080\" -s ...","handlingStrategy":"validation","validationCode":"// validate bind address before starting\nlet addr: std::net::SocketAddr = args.bind_addr\n    .parse().expect(\"bind-addr must be host:port\");\nassert!(addr.port() > 0, \"port must be > 0\");","typeGuard":"fn is_valid_socket_addr(s: &str) -> bool { s.parse::<std::net::SocketAddr>().is_ok() }","tryCatchPattern":"// run the server future and inspect its error instead of panicking\nmatch Server::new(config).await {\n    Ok(srv) => srv.serve().await,\n    Err(e) => eprintln!(\"failed to create local server: {e}\"),\n}","preventionTips":["Run with --check-config / validate configs in CI before deploy","Use explicit IP:port for -b values","Keep plugin paths absolute and executable"],"tags":["startup","server","config","panic"],"backgroundTag":"invalid-config-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"}