mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 01:59:16 +08:00
Local server support Tun interface for both TCP and UDP (#586)
* [POC] basic implementation of TCP redirecting tun (#581) * [POC] basic implementation of UDP redirection of Tun * build with action * add configuration interface for tun * refine document and command line options * outbound-bind-addr instead of reusing local_address for outbound sockets * support customizing udp expiry and capacity * make clippy happy * fixed build error for Android * add docs * make a customized AsyncFd with the released tun crate * TUN_INTERFACE_NAME to_owned directly * ignore accept errors for tcp tun * tun supports Android only on master branch * android doesnt support setting IFF_NO_PI * set route for macos automatically when creating tun * set route for macos directly with PF_ROUTE * Linux-like uses ETH_P_IP and ETH_P_IPV6 * use tun on crates.io and ignores Android support temporary * update dependencies
This commit is contained in:
@@ -45,7 +45,10 @@ impl Socks4TestServer {
|
||||
},
|
||||
cli_config: {
|
||||
let mut cfg = Config::new(ConfigType::Local);
|
||||
cfg.local = vec![LocalConfig::new(ServerAddr::from(local_addr), ProtocolType::Socks)];
|
||||
cfg.local = vec![LocalConfig::new_with_addr(
|
||||
ServerAddr::from(local_addr),
|
||||
ProtocolType::Socks,
|
||||
)];
|
||||
cfg.server = vec![ServerConfig::new(svr_addr, pwd.to_owned(), method)];
|
||||
cfg
|
||||
},
|
||||
|
||||
@@ -47,7 +47,10 @@ impl Socks5TestServer {
|
||||
},
|
||||
cli_config: {
|
||||
let mut cfg = Config::new(ConfigType::Local);
|
||||
cfg.local = vec![LocalConfig::new(ServerAddr::from(local_addr), ProtocolType::Socks)];
|
||||
cfg.local = vec![LocalConfig::new_with_addr(
|
||||
ServerAddr::from(local_addr),
|
||||
ProtocolType::Socks,
|
||||
)];
|
||||
cfg.local[0].mode = if enable_udp { Mode::TcpAndUdp } else { Mode::TcpOnly };
|
||||
cfg.server = vec![ServerConfig::new(svr_addr, pwd.to_owned(), method)];
|
||||
cfg
|
||||
|
||||
@@ -35,7 +35,10 @@ fn get_svr_config() -> Config {
|
||||
|
||||
fn get_cli_config() -> Config {
|
||||
let mut cfg = Config::new(ConfigType::Local);
|
||||
cfg.local = vec![LocalConfig::new(LOCAL_ADDR.parse().unwrap(), ProtocolType::Socks)];
|
||||
cfg.local = vec![LocalConfig::new_with_addr(
|
||||
LOCAL_ADDR.parse().unwrap(),
|
||||
ProtocolType::Socks,
|
||||
)];
|
||||
cfg.local[0].mode = Mode::TcpAndUdp;
|
||||
cfg.server = vec![ServerConfig::new(
|
||||
SERVER_ADDR.parse::<SocketAddr>().unwrap(),
|
||||
|
||||
Reference in New Issue
Block a user