Skip to content

Commit

Permalink
setting manager's method from configuration
Browse files Browse the repository at this point in the history
fixes #542
  • Loading branch information
zonyitoo committed May 29, 2021
1 parent b23bbf2 commit 6c2a173
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ impl Config {

// Standard config
// Server
match (config.server, config.server_port, config.password, config.method) {
match (config.server, config.server_port, config.password, &config.method) {
(Some(address), Some(port), Some(pwd), Some(m)) => {
let addr = match address.parse::<Ipv4Addr>() {
Ok(v4) => ServerAddr::SocketAddr(SocketAddr::V4(SocketAddrV4::new(v4, port))),
Expand Down Expand Up @@ -1191,6 +1191,9 @@ impl Config {

nconfig.server.push(nsvr);
}
(None, None, None, Some(_)) if config_type.is_manager() => {
// Set the default method for manager
}
(None, None, None, None) => (),
_ => {
let err = Error::new(
Expand Down Expand Up @@ -1326,6 +1329,21 @@ impl Config {

let mut manager_config = ManagerConfig::new(manager);
manager_config.mode = global_mode;

if let Some(ref m) = config.method {
match m.parse::<CipherKind>() {
Ok(method) => manager_config.method = Some(method),
Err(..) => {
let err = Error::new(
ErrorKind::Invalid,
"unsupported method",
Some(format!("`{}` is not a supported method", m)),
);
return Err(err);
}
}
}

nconfig.manager = Some(manager_config);
}

Expand Down

0 comments on commit 6c2a173

Please sign in to comment.