add tcp-keep-alive command line option

- ref #546
This commit is contained in:
zonyitoo
2021-06-07 03:17:44 +08:00
parent 1271cc2ff8
commit d61d1028a5
5 changed files with 29 additions and 2 deletions

2
Cargo.lock generated
View File

@@ -1527,7 +1527,7 @@ dependencies = [
[[package]]
name = "shadowsocks-rust"
version = "1.11.1"
version = "1.11.2"
dependencies = [
"byte_string",
"byteorder",

View File

@@ -1,6 +1,6 @@
[package]
name = "shadowsocks-rust"
version = "1.11.1"
version = "1.11.2"
authors = ["Shadowsocks Contributors"]
description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls."
repository = "https://github.com/shadowsocks/shadowsocks-rust"

View File

@@ -67,6 +67,7 @@ fn main() {
(@arg TCP_NO_DELAY: --("tcp-no-delay") !takes_value alias("no-delay") "Set TCP_NODELAY option for socket")
(@arg TCP_FAST_OPEN: --("tcp-fast-open") !takes_value alias("fast-open") "Enable TCP Fast Open (TFO)")
(@arg TCP_KEEP_ALIVE: --("tcp-keep-alive") +takes_value {validator::validate_u64} "Set TCP keep alive timeout seconds")
(@arg UDP_TIMEOUT: --("udp-timeout") +takes_value {validator::validate_u64} "Timeout seconds for UDP relay")
(@arg UDP_MAX_ASSOCIATIONS: --("udp-max-associations") +takes_value {validator::validate_u64} "Maximum associations to be kept simultaneously for UDP relay")
@@ -348,6 +349,14 @@ fn main() {
config.fast_open = true;
}
if let Some(keep_alive) = matches.value_of("TCP_KEEP_ALIVE") {
config.keep_alive = Some(Duration::from_secs(
keep_alive
.parse::<u64>()
.expect("`tcp-keep-alive` is expecting an integer"),
));
}
#[cfg(any(target_os = "linux", target_os = "android"))]
if let Some(mark) = matches.value_of("OUTBOUND_FWMARK") {
config.outbound_fwmark = Some(mark.parse::<u32>().expect("an unsigned integer for `outbound-fwmark`"));

View File

@@ -60,6 +60,7 @@ fn main() {
(@arg TCP_NO_DELAY: --("tcp-no-delay") !takes_value alias("no-delay") "Set TCP_NODELAY option for socket")
(@arg TCP_FAST_OPEN: --("tcp-fast-open") !takes_value alias("fast-open") "Enable TCP Fast Open (TFO)")
(@arg TCP_KEEP_ALIVE: --("tcp-keep-alive") +takes_value {validator::validate_u64} "Set TCP keep alive timeout seconds")
(@arg UDP_TIMEOUT: --("udp-timeout") +takes_value {validator::validate_u64} "Timeout seconds for UDP relay")
(@arg UDP_MAX_ASSOCIATIONS: --("udp-max-associations") +takes_value {validator::validate_u64} "Maximum associations to be kept simultaneously for UDP relay")
@@ -158,6 +159,14 @@ fn main() {
config.fast_open = true;
}
if let Some(keep_alive) = matches.value_of("TCP_KEEP_ALIVE") {
config.keep_alive = Some(Duration::from_secs(
keep_alive
.parse::<u64>()
.expect("`tcp-keep-alive` is expecting an integer"),
));
}
#[cfg(any(target_os = "linux", target_os = "android"))]
if let Some(mark) = matches.value_of("OUTBOUND_FWMARK") {
config.outbound_fwmark = Some(mark.parse::<u32>().expect("an unsigned integer for `outbound-fwmark`"));

View File

@@ -62,6 +62,7 @@ fn main() {
(@arg TCP_NO_DELAY: --("tcp-no-delay") !takes_value alias("no-delay") "Set TCP_NODELAY option for socket")
(@arg TCP_FAST_OPEN: --("tcp-fast-open") !takes_value alias("fast-open") "Enable TCP Fast Open (TFO)")
(@arg TCP_KEEP_ALIVE: --("tcp-keep-alive") +takes_value {validator::validate_u64} "Set TCP keep alive timeout seconds")
(@arg UDP_TIMEOUT: --("udp-timeout") +takes_value {validator::validate_u64} "Timeout seconds for UDP relay")
(@arg UDP_MAX_ASSOCIATIONS: --("udp-max-associations") +takes_value {validator::validate_u64} "Maximum associations to be kept simultaneously for UDP relay")
@@ -199,6 +200,14 @@ fn main() {
config.fast_open = true;
}
if let Some(keep_alive) = matches.value_of("TCP_KEEP_ALIVE") {
config.keep_alive = Some(Duration::from_secs(
keep_alive
.parse::<u64>()
.expect("`tcp-keep-alive` is expecting an integer"),
));
}
#[cfg(any(target_os = "linux", target_os = "android"))]
if let Some(mark) = matches.value_of("OUTBOUND_FWMARK") {
config.outbound_fwmark = Some(mark.parse::<u32>().expect("an unsigned integer for `outbound-fwmark`"));