From 0cf4291d6785bef4388ad294438ab51aca5fff72 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Sun, 12 May 2024 23:34:22 +0800 Subject: [PATCH] fix(server): "users" should be empty for method not support EIH (#1525) --- crates/shadowsocks-service/src/config.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/shadowsocks-service/src/config.rs b/crates/shadowsocks-service/src/config.rs index 7db2de114483..873ef4eddde7 100644 --- a/crates/shadowsocks-service/src/config.rs +++ b/crates/shadowsocks-service/src/config.rs @@ -2621,6 +2621,19 @@ impl Config { // Users' key must match key length if let Some(user_manager) = server.user_manager() { + #[cfg(feature = "aead-cipher-2022")] + if server.method().is_aead_2022() { + use shadowsocks::config::method_support_eih; + if user_manager.user_count() > 0 && !method_support_eih(server.method()) { + let err = Error::new( + ErrorKind::Invalid, + "server method doesn't support Extended Identity Header (EIH), remove `users`", + Some(format!("method {}", server.method())), + ); + return Err(err); + } + } + let key_len = server.method().key_len(); for user in user_manager.users_iter() { if user.key().len() != key_len {