shadowsocks/shadowsocks-rust · error
method
Error message
method
What it means
In the server service `create`, the `ENCRYPT_METHOD` CLI value is parsed with `x.parse::<CipherKind>().expect("method")`. The panic means the provided encryption method string is not a valid `CipherKind`. This occurs while constructing a server from `--server-addr` CLI arguments (rather than a config file).
Source
Thrown at src/service/server.rs:336
logging::init_with_file(path);
}
None => {
logging::init_with_config("ssserver", &service_config.log);
}
}
trace!("{:?}", service_config);
let mut config = match config_path_opt {
Some(cpath) => Config::load_from_file(&cpath, ConfigType::Server)
.map_err(|err| ShadowsocksError::LoadConfigFailure(format!("loading config {cpath:?}, {err}")))?,
None => Config::new(ConfigType::Server),
};
if let Some(svr_addr) = matches.get_one::<String>("SERVER_ADDR") {
let method = matches
.get_one::<String>("ENCRYPT_METHOD")
.map(|x| x.parse::<CipherKind>().expect("method"))
.expect("`method` is required");
let password = match matches.get_one::<String>("PASSWORD") {
Some(pwd) => read_variable_field_value(pwd).into(),
None => {
// NOTE: svr_addr should have been checked by crate::vparser
if method.is_none() {
// If method doesn't need a key (none, plain), then we can leave it empty
String::new()
} else {
match crate::password::read_server_password(svr_addr) {
Ok(pwd) => pwd,
Err(..) => panic!("`password` is required for server {svr_addr}"),
}
}
}
};
View on GitHub (pinned to 8eb0f0a65b)
Solutions
- Use an exact supported cipher: `aes-256-gcm`, `aes-128-gcm`, `chacha20-ietf-poly1305`, or SIP002 `2022-*` ciphers
- Keep the method string identical on both client and server
- Enable the required cargo feature if the cipher was compiled out
- Put the method in the config file instead of CLI to avoid quoting/casing issues
Example fix
// before --encrypt-method rc4-md5 // after --encrypt-method chacha20-ietf-poly1305
Defensive patterns
Strategy: validation
Validate before calling
const VALID: &[&str] = &["aes-128-gcm","aes-256-gcm","chacha20-ietf-poly1305"];
if let Some(m) = &cli.method {
assert!(VALID.contains(&m.as_str()), "unknown method {m}");
} Type guard
fn is_known_cipher(s: &str) -> bool {
matches!(s, "aes-128-gcm" | "aes-256-gcm" | "chacha20-ietf-poly1305")
} Try / catch
// parse with a clear message
let kind: CipherKind = m.parse().map_err(|_| anyhow!("unsupported --encrypt-method {m}"))?; Prevention
- Standardize on AEAD cipher names across deployments
- Validate flags in wrapper scripts before exec
- Match casing exactly: all lowercase
When it happens
Trigger: Running `ssserver` with `--encrypt-method` set to an unrecognized cipher name — legacy ciphers (e.g. `aes-256-cfb`), wrong casing, extra whitespace, or a cipher not enabled in the build's feature flags.
Common situations: Following outdated tutorials referencing stream ciphers; mismatched method strings shared between client and server; typo in long cipher names like `2022-blake3-aes-128-gcm`.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- method
- `method` is required
- server-addr
- not supported `protocol` "{p}"
- `password` is required for server {svr_addr}
AI-assisted analysis of shadowsocks/shadowsocks-rust@8eb0f0a65b (2026-09-09).
Data as JSON: /api/errors/089f30355ad59d3c.
Report an issue: GitHub.