From e0f25c675e64b250d1cb1bf1a6f8c31f16b7d31d Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Sun, 12 May 2024 18:55:48 +0800 Subject: [PATCH] fix(local): online_config checked only when feature enabled --- crates/shadowsocks-service/src/config.rs | 38 ++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/crates/shadowsocks-service/src/config.rs b/crates/shadowsocks-service/src/config.rs index 5ad67efc06f0..2b88ffa7488b 100644 --- a/crates/shadowsocks-service/src/config.rs +++ b/crates/shadowsocks-service/src/config.rs @@ -70,14 +70,7 @@ use serde::{Deserialize, Serialize}; use shadowsocks::relay::socks5::Address; use shadowsocks::{ config::{ - ManagerAddr, - Mode, - ReplayAttackPolicy, - ServerAddr, - ServerConfig, - ServerSource, - ServerUser, - ServerUserManager, + ManagerAddr, Mode, ReplayAttackPolicy, ServerAddr, ServerConfig, ServerSource, ServerUser, ServerUserManager, ServerWeight, }, crypto::CipherKind, @@ -2557,13 +2550,28 @@ impl Config { } } - if self.config_type.is_server() && self.server.is_empty() && self.online_config.is_none() { - let err = Error::new( - ErrorKind::MissingField, - "missing any valid servers in configuration", - None, - ); - return Err(err); + if self.config_type.is_server() && self.server.is_empty() { + #[cfg(feature = "local-online-config")] + if self.online_config.is_none() { + // It's Ok if online_config is not None. + // servers could be fetch from online configuration delivery (SIP008) + let err = Error::new( + ErrorKind::MissingField, + "missing any valid servers in configuration", + None, + ); + return Err(err); + } + + #[cfg(not(feature = "local-online-config"))] + { + let err = Error::new( + ErrorKind::MissingField, + "missing any valid servers in configuration", + None, + ); + return Err(err); + } } if self.config_type.is_manager() && self.manager.is_none() {