Skip to content

Commit

Permalink
add launchd_udp_socket_name / launchd_tcp_socket_name to basic config
Browse files Browse the repository at this point in the history
  • Loading branch information
liudongmiao authored and zonyitoo committed Apr 12, 2024
1 parent b37c6e4 commit 7b4a0a1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ struct SSConfig {
#[serde(skip_serializing_if = "Option::is_none")]
local_port: Option<u16>,

/// macOS launch activate socket for local_port
#[cfg(target_os = "macos")]
#[serde(skip_serializing_if = "Option::is_none")]
launchd_udp_socket_name: Option<String>,
#[cfg(target_os = "macos")]
#[serde(skip_serializing_if = "Option::is_none")]
launchd_tcp_socket_name: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
protocol: Option<String>,

Expand Down Expand Up @@ -1501,6 +1509,11 @@ impl Config {
}
},
};
#[cfg(target_os = "macos")]
{
local_config.launchd_tcp_socket_name = config.launchd_tcp_socket_name.clone();

Check warning on line 1514 in crates/shadowsocks-service/src/config.rs

View workflow job for this annotation

GitHub Actions / clippy-check (macos-latest)

assigning the result of `Clone::clone()` may be inefficient

warning: assigning the result of `Clone::clone()` may be inefficient --> crates/shadowsocks-service/src/config.rs:1514:25 | 1514 | local_config.launchd_tcp_socket_name = config.launchd_tcp_socket_name.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `local_config.launchd_tcp_socket_name.clone_from(&config.launchd_tcp_socket_name)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones = note: `#[warn(clippy::assigning_clones)]` on by default
local_config.launchd_udp_socket_name = config.launchd_udp_socket_name.clone();

Check warning on line 1515 in crates/shadowsocks-service/src/config.rs

View workflow job for this annotation

GitHub Actions / clippy-check (macos-latest)

assigning the result of `Clone::clone()` may be inefficient

warning: assigning the result of `Clone::clone()` may be inefficient --> crates/shadowsocks-service/src/config.rs:1515:25 | 1515 | local_config.launchd_udp_socket_name = config.launchd_udp_socket_name.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `local_config.launchd_udp_socket_name.clone_from(&config.launchd_udp_socket_name)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones
}

let local_instance = LocalInstanceConfig {
config: local_config,
Expand Down Expand Up @@ -2545,6 +2558,12 @@ impl fmt::Display for Config {
});
}

#[cfg(target_os = "macos")]
{
jconf.launchd_tcp_socket_name = local.launchd_tcp_socket_name.clone();

Check warning on line 2563 in crates/shadowsocks-service/src/config.rs

View workflow job for this annotation

GitHub Actions / clippy-check (macos-latest)

assigning the result of `Clone::clone()` may be inefficient

warning: assigning the result of `Clone::clone()` may be inefficient --> crates/shadowsocks-service/src/config.rs:2563:21 | 2563 | jconf.launchd_tcp_socket_name = local.launchd_tcp_socket_name.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `jconf.launchd_tcp_socket_name.clone_from(&local.launchd_tcp_socket_name)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones
jconf.launchd_udp_socket_name = local.launchd_udp_socket_name.clone();

Check warning on line 2564 in crates/shadowsocks-service/src/config.rs

View workflow job for this annotation

GitHub Actions / clippy-check (macos-latest)

assigning the result of `Clone::clone()` may be inefficient

warning: assigning the result of `Clone::clone()` may be inefficient --> crates/shadowsocks-service/src/config.rs:2564:21 | 2564 | jconf.launchd_udp_socket_name = local.launchd_udp_socket_name.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `jconf.launchd_udp_socket_name.clone_from(&local.launchd_udp_socket_name)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones
}

if local.protocol != ProtocolType::Socks {
jconf.protocol = Some(local.protocol.as_str().to_owned());
}
Expand Down

0 comments on commit 7b4a0a1

Please sign in to comment.