mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 01:59:16 +08:00
remove deprecated code for clap 3.1.0 (#774)
This commit is contained in:
@@ -144,7 +144,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
json5 = "0.4"
|
||||
thiserror = "1.0"
|
||||
|
||||
clap = { version = "3", features = ["wrap_help", "suggestions"] }
|
||||
clap = { version = "3.1", features = ["wrap_help", "suggestions"] }
|
||||
cfg-if = "1"
|
||||
qrcode = { version = "0.12", default-features = false }
|
||||
exitcode = "1"
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
//! or you could specify a configuration file. The format of configuration file is defined
|
||||
//! in mod `config`.
|
||||
|
||||
use clap::App;
|
||||
use clap::Command;
|
||||
use shadowsocks_rust::service::local;
|
||||
|
||||
fn main() {
|
||||
let mut app = App::new("shadowsocks")
|
||||
let mut app = Command::new("shadowsocks")
|
||||
.version(shadowsocks_rust::VERSION)
|
||||
.about("A fast tunnel proxy that helps you bypass firewalls. (https://shadowsocks.org)");
|
||||
app = local::define_command_line_options(app);
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
//! *It should be notice that the extended configuration file is not suitable for the server
|
||||
//! side.*
|
||||
|
||||
use clap::App;
|
||||
use clap::Command;
|
||||
use shadowsocks_rust::service::manager;
|
||||
|
||||
fn main() {
|
||||
let mut app = App::new("shadowsocks")
|
||||
let mut app = Command::new("shadowsocks")
|
||||
.version(shadowsocks_rust::VERSION)
|
||||
.about("A fast tunnel proxy that helps you bypass firewalls. (https://shadowsocks.org)");
|
||||
app = manager::define_command_line_options(app);
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
//! *It should be notice that the extended configuration file is not suitable for the server
|
||||
//! side.*
|
||||
|
||||
use clap::App;
|
||||
use clap::Command;
|
||||
use shadowsocks_rust::service::server;
|
||||
|
||||
fn main() {
|
||||
let mut app = App::new("shadowsocks")
|
||||
let mut app = Command::new("shadowsocks")
|
||||
.version(shadowsocks_rust::VERSION)
|
||||
.about("A fast tunnel proxy that helps you bypass firewalls. (https://shadowsocks.org)");
|
||||
app = server::define_command_line_options(app);
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
use std::{env, path::Path};
|
||||
|
||||
use clap::{App, AppSettings};
|
||||
use clap::Command;
|
||||
use shadowsocks_rust::service::{local, manager, server};
|
||||
|
||||
fn main() {
|
||||
let app = App::new("shadowsocks")
|
||||
let app = Command::new("shadowsocks")
|
||||
.version(shadowsocks_rust::VERSION)
|
||||
.about("A fast tunnel proxy that helps you bypass firewalls. (https://shadowsocks.org)");
|
||||
|
||||
@@ -30,11 +30,11 @@ fn main() {
|
||||
}
|
||||
|
||||
let matches = app
|
||||
.setting(AppSettings::SubcommandRequired)
|
||||
.subcommand(local::define_command_line_options(App::new("local")).about("Shadowsocks Local service"))
|
||||
.subcommand(server::define_command_line_options(App::new("server")).about("Shadowsocks Server service"))
|
||||
.subcommand_required(true)
|
||||
.subcommand(local::define_command_line_options(Command::new("local")).about("Shadowsocks Local service"))
|
||||
.subcommand(server::define_command_line_options(Command::new("server")).about("Shadowsocks Server service"))
|
||||
.subcommand(
|
||||
manager::define_command_line_options(App::new("manager")).about("Shadowsocks Server Manager service"),
|
||||
manager::define_command_line_options(Command::new("manager")).about("Shadowsocks Server Manager service"),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! SS-URI = "ss://" userinfo "@" hostname ":" port [ "/" ] [ "?" plugin ] [ "#" tag ]
|
||||
//! userinfo = websafe-base64-encode-utf8(method ":" password)
|
||||
|
||||
use clap::{App, Arg};
|
||||
use clap::{Command, Arg};
|
||||
use qrcode::{types::Color, QrCode};
|
||||
|
||||
use shadowsocks_service::{
|
||||
@@ -73,7 +73,7 @@ fn decode(encoded: &str, need_qrcode: bool) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let app = App::new("ssurl")
|
||||
let app = Command::new("ssurl")
|
||||
.version(VERSION)
|
||||
.about("Encode and decode ShadowSocks URL")
|
||||
.arg(
|
||||
|
||||
@@ -183,7 +183,7 @@ impl Config {
|
||||
#[cfg(feature = "multi-threaded")]
|
||||
match matches.value_of_t::<usize>("WORKER_THREADS") {
|
||||
Ok(worker_count) => self.runtime.worker_count = Some(worker_count),
|
||||
Err(ref err) if err.kind == clap::ErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == clap::ErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::{net::IpAddr, path::PathBuf, process, time::Duration};
|
||||
|
||||
use clap::{App, Arg, ArgGroup, ArgMatches, ErrorKind as ClapErrorKind};
|
||||
use clap::{Arg, ArgGroup, ArgMatches, Command, ErrorKind as ClapErrorKind};
|
||||
use futures::future::{self, Either};
|
||||
use log::{info, trace};
|
||||
use tokio::{self, runtime::Builder};
|
||||
@@ -27,12 +27,11 @@ use shadowsocks_service::{
|
||||
use crate::logging;
|
||||
use crate::{
|
||||
config::{Config as ServiceConfig, RuntimeMode},
|
||||
monitor,
|
||||
validator,
|
||||
monitor, validator,
|
||||
};
|
||||
|
||||
/// Defines command line options
|
||||
pub fn define_command_line_options(mut app: App<'_>) -> App<'_> {
|
||||
pub fn define_command_line_options(mut app: Command<'_>) -> Command<'_> {
|
||||
app = app.arg(
|
||||
Arg::new("CONFIG")
|
||||
.short('c')
|
||||
@@ -432,7 +431,7 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
let timeout = match matches.value_of_t::<u64>("TIMEOUT") {
|
||||
Ok(t) => Some(Duration::from_secs(t)),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => None,
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => None,
|
||||
Err(err) => err.exit(),
|
||||
};
|
||||
|
||||
@@ -456,7 +455,7 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<ServerConfig>("URL") {
|
||||
Ok(svr_addr) => config.server.push(svr_addr),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
@@ -494,7 +493,7 @@ pub fn main(matches: &ArgMatches) {
|
||||
let mut local_config = LocalConfig::new(protocol);
|
||||
match matches.value_of_t::<ServerAddr>("LOCAL_ADDR") {
|
||||
Ok(local_addr) => local_config.addr = Some(local_addr),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {
|
||||
#[cfg(feature = "local-tun")]
|
||||
if protocol == ProtocolType::Tun {
|
||||
// `tun` protocol doesn't need --local-addr
|
||||
@@ -507,14 +506,14 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<ServerAddr>("UDP_BIND_ADDR") {
|
||||
Ok(udp_bind_addr) => local_config.udp_addr = Some(udp_bind_addr),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(feature = "local-tunnel")]
|
||||
match matches.value_of_t::<Address>("FORWARD_ADDR") {
|
||||
Ok(addr) => local_config.forward_addr = Some(addr),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
@@ -522,13 +521,13 @@ pub fn main(matches: &ArgMatches) {
|
||||
{
|
||||
match matches.value_of_t::<RedirType>("TCP_REDIR") {
|
||||
Ok(tcp_redir) => local_config.tcp_redir = tcp_redir,
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<RedirType>("UDP_REDIR") {
|
||||
Ok(udp_redir) => local_config.udp_redir = udp_redir,
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
}
|
||||
@@ -562,13 +561,13 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<NameServerAddr>("LOCAL_DNS_ADDR") {
|
||||
Ok(addr) => local_config.local_dns_addr = Some(addr),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<RemoteDnsAddress>("REMOTE_DNS_ADDR") {
|
||||
Ok(addr) => local_config.remote_dns_addr = Some(addr.0),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
}
|
||||
@@ -588,7 +587,7 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
config.local.push(local_dns_config);
|
||||
}
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
}
|
||||
@@ -599,19 +598,19 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<IpNet>("TUN_INTERFACE_ADDRESS") {
|
||||
Ok(tun_address) => local_config.tun_interface_address = Some(tun_address),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<String>("TUN_INTERFACE_NAME") {
|
||||
Ok(tun_name) => local_config.tun_interface_name = Some(tun_name),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
match matches.value_of_t::<PathBuf>("TUN_DEVICE_FD_FROM_PATH") {
|
||||
Ok(fd_path) => local_config.tun_device_fd_from_path = Some(fd_path),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
}
|
||||
@@ -637,34 +636,34 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<u64>("TCP_KEEP_ALIVE") {
|
||||
Ok(keep_alive) => config.keep_alive = Some(Duration::from_secs(keep_alive)),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
match matches.value_of_t::<u32>("OUTBOUND_FWMARK") {
|
||||
Ok(mark) => config.outbound_fwmark = Some(mark),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
match matches.value_of_t::<u32>("OUTBOUND_USER_COOKIE") {
|
||||
Ok(user_cookie) => config.outbound_user_cookie = Some(user_cookie),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<String>("OUTBOUND_BIND_INTERFACE") {
|
||||
Ok(iface) => config.outbound_bind_interface = Some(iface),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(target_os = "android")))]
|
||||
match matches.value_of_t::<u64>("NOFILE") {
|
||||
Ok(nofile) => config.nofile = Some(nofile),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
@@ -689,40 +688,40 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<u64>("UDP_TIMEOUT") {
|
||||
Ok(udp_timeout) => config.udp_timeout = Some(Duration::from_secs(udp_timeout)),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<usize>("UDP_MAX_ASSOCIATIONS") {
|
||||
Ok(udp_max_assoc) => config.udp_max_associations = Some(udp_max_assoc),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<u32>("INBOUND_SEND_BUFFER_SIZE") {
|
||||
Ok(bs) => config.inbound_send_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<u32>("INBOUND_RECV_BUFFER_SIZE") {
|
||||
Ok(bs) => config.inbound_recv_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<u32>("OUTBOUND_SEND_BUFFER_SIZE") {
|
||||
Ok(bs) => config.outbound_send_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<u32>("OUTBOUND_RECV_BUFFER_SIZE") {
|
||||
Ok(bs) => config.outbound_recv_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<IpAddr>("OUTBOUND_BIND_ADDR") {
|
||||
Ok(bind_addr) => config.outbound_bind_addr = Some(bind_addr),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::{net::IpAddr, path::PathBuf, process, time::Duration};
|
||||
|
||||
use clap::{App, Arg, ArgGroup, ArgMatches, ErrorKind as ClapErrorKind};
|
||||
use clap::{Command, Arg, ArgGroup, ArgMatches, ErrorKind as ClapErrorKind};
|
||||
use futures::future::{self, Either};
|
||||
use log::{info, trace};
|
||||
use tokio::{self, runtime::Builder};
|
||||
@@ -29,7 +29,7 @@ use crate::{
|
||||
};
|
||||
|
||||
/// Defines command line options
|
||||
pub fn define_command_line_options(mut app: App<'_>) -> App<'_> {
|
||||
pub fn define_command_line_options(mut app: Command<'_>) -> Command<'_> {
|
||||
app = app
|
||||
.arg(
|
||||
Arg::new("CONFIG")
|
||||
@@ -270,27 +270,27 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<u64>("TCP_KEEP_ALIVE") {
|
||||
Ok(keep_alive) => config.keep_alive = Some(Duration::from_secs(keep_alive)),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
match matches.value_of_t::<u32>("OUTBOUND_FWMARK") {
|
||||
Ok(mark) => config.outbound_fwmark = Some(mark),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
match matches.value_of_t::<u32>("OUTBOUND_USER_COOKIE") {
|
||||
Ok(user_cookie) => config.outbound_user_cookie = Some(user_cookie),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<String>("OUTBOUND_BIND_INTERFACE") {
|
||||
Ok(iface) => config.outbound_bind_interface = Some(iface),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
@@ -302,26 +302,26 @@ pub fn main(matches: &ArgMatches) {
|
||||
config.manager = Some(ManagerConfig::new(addr));
|
||||
}
|
||||
}
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
if let Some(ref mut manager_config) = config.manager {
|
||||
match matches.value_of_t::<CipherKind>("ENCRYPT_METHOD") {
|
||||
Ok(m) => manager_config.method = Some(m),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<u64>("TIMEOUT") {
|
||||
Ok(t) => manager_config.timeout = Some(Duration::from_secs(t)),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<ManagerServerHost>("SERVER_HOST") {
|
||||
Ok(sh) => manager_config.server_host = sh,
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
@@ -336,14 +336,14 @@ pub fn main(matches: &ArgMatches) {
|
||||
#[cfg(unix)]
|
||||
match matches.value_of_t::<ManagerServerMode>("MANAGER_SERVER_MODE") {
|
||||
Ok(server_mode) => manager_config.server_mode = server_mode,
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
match matches.value_of_t::<PathBuf>("MANAGER_SERVER_WORKING_DIRECTORY") {
|
||||
Ok(server_working_directory) => manager_config.server_working_directory = server_working_directory,
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
}
|
||||
@@ -364,7 +364,7 @@ pub fn main(matches: &ArgMatches) {
|
||||
#[cfg(all(unix, not(target_os = "android")))]
|
||||
match matches.value_of_t::<u64>("NOFILE") {
|
||||
Ok(nofile) => config.nofile = Some(nofile),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
@@ -389,40 +389,40 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<u64>("UDP_TIMEOUT") {
|
||||
Ok(udp_timeout) => config.udp_timeout = Some(Duration::from_secs(udp_timeout)),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<usize>("UDP_MAX_ASSOCIATIONS") {
|
||||
Ok(udp_max_assoc) => config.udp_max_associations = Some(udp_max_assoc),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<u32>("INBOUND_SEND_BUFFER_SIZE") {
|
||||
Ok(bs) => config.inbound_send_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<u32>("INBOUND_RECV_BUFFER_SIZE") {
|
||||
Ok(bs) => config.inbound_recv_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<u32>("OUTBOUND_SEND_BUFFER_SIZE") {
|
||||
Ok(bs) => config.outbound_send_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<u32>("OUTBOUND_RECV_BUFFER_SIZE") {
|
||||
Ok(bs) => config.outbound_recv_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<IpAddr>("OUTBOUND_BIND_ADDR") {
|
||||
Ok(bind_addr) => config.outbound_bind_addr = Some(bind_addr),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::{net::IpAddr, path::PathBuf, process, time::Duration};
|
||||
|
||||
use clap::{App, Arg, ArgGroup, ArgMatches, ErrorKind as ClapErrorKind};
|
||||
use clap::{Arg, ArgGroup, ArgMatches, Command, ErrorKind as ClapErrorKind};
|
||||
use futures::future::{self, Either};
|
||||
use log::{info, trace};
|
||||
use tokio::{self, runtime::Builder};
|
||||
@@ -22,12 +22,11 @@ use shadowsocks_service::{
|
||||
use crate::logging;
|
||||
use crate::{
|
||||
config::{Config as ServiceConfig, RuntimeMode},
|
||||
monitor,
|
||||
validator,
|
||||
monitor, validator,
|
||||
};
|
||||
|
||||
/// Defines command line options
|
||||
pub fn define_command_line_options(mut app: App<'_>) -> App<'_> {
|
||||
pub fn define_command_line_options(mut app: Command<'_>) -> Command<'_> {
|
||||
app = app
|
||||
.arg(
|
||||
Arg::new("CONFIG")
|
||||
@@ -288,7 +287,7 @@ pub fn main(matches: &ArgMatches) {
|
||||
let svr_addr = svr_addr.parse::<ServerAddr>().expect("server-addr");
|
||||
let timeout = match matches.value_of_t::<u64>("TIMEOUT") {
|
||||
Ok(t) => Some(Duration::from_secs(t)),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => None,
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => None,
|
||||
Err(err) => err.exit(),
|
||||
};
|
||||
|
||||
@@ -331,27 +330,27 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<u64>("TCP_KEEP_ALIVE") {
|
||||
Ok(keep_alive) => config.keep_alive = Some(Duration::from_secs(keep_alive)),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
match matches.value_of_t::<u32>("OUTBOUND_FWMARK") {
|
||||
Ok(mark) => config.outbound_fwmark = Some(mark),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
match matches.value_of_t::<u32>("OUTBOUND_USER_COOKIE") {
|
||||
Ok(user_cookie) => config.outbound_user_cookie = Some(user_cookie),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<String>("OUTBOUND_BIND_INTERFACE") {
|
||||
Ok(iface) => config.outbound_bind_interface = Some(iface),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
@@ -363,14 +362,14 @@ pub fn main(matches: &ArgMatches) {
|
||||
config.manager = Some(ManagerConfig::new(addr));
|
||||
}
|
||||
}
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(target_os = "android")))]
|
||||
match matches.value_of_t::<u64>("NOFILE") {
|
||||
Ok(nofile) => config.nofile = Some(nofile),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
@@ -395,40 +394,40 @@ pub fn main(matches: &ArgMatches) {
|
||||
|
||||
match matches.value_of_t::<u64>("UDP_TIMEOUT") {
|
||||
Ok(udp_timeout) => config.udp_timeout = Some(Duration::from_secs(udp_timeout)),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<usize>("UDP_MAX_ASSOCIATIONS") {
|
||||
Ok(udp_max_assoc) => config.udp_max_associations = Some(udp_max_assoc),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<u32>("INBOUND_SEND_BUFFER_SIZE") {
|
||||
Ok(bs) => config.inbound_send_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<u32>("INBOUND_RECV_BUFFER_SIZE") {
|
||||
Ok(bs) => config.inbound_recv_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<u32>("OUTBOUND_SEND_BUFFER_SIZE") {
|
||||
Ok(bs) => config.outbound_send_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
match matches.value_of_t::<u32>("OUTBOUND_RECV_BUFFER_SIZE") {
|
||||
Ok(bs) => config.outbound_recv_buffer_size = Some(bs),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
match matches.value_of_t::<IpAddr>("OUTBOUND_BIND_ADDR") {
|
||||
Ok(bind_addr) => config.outbound_bind_addr = Some(bind_addr),
|
||||
Err(ref err) if err.kind == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(ref err) if err.kind() == ClapErrorKind::ArgumentNotFound => {}
|
||||
Err(err) => err.exit(),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user