From 2bcc40c4f7a6afce6888122c20c9ca9b60d0f770 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Wed, 30 Dec 2020 09:16:20 +0800 Subject: [PATCH] upgrade to trust-dns-resolver v0.20 release --- .gitignore | 1 + Cargo.lock | 31 +++++++++++++----------- crates/shadowsocks-service/Cargo.toml | 2 +- crates/shadowsocks-service/src/config.rs | 25 ++++++++++++++++++- crates/shadowsocks/Cargo.toml | 2 +- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 57ce3cc7..1e9a6131 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ /restart.sh /udp_echo_server.py /.idea +/.devcontainer diff --git a/Cargo.lock b/Cargo.lock index 3047670b..ddda6692 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,9 +20,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68803225a7b13e47191bab76f2687382b60d259e8cf37f6e1893658b84bb9479" +checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86" [[package]] name = "arc-swap" @@ -587,9 +587,9 @@ checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a" [[package]] name = "hyper" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b980c7bc75203b968f06374cbde00bf1818e02e156b8e5b6ccf440fb53b6d0" +checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe" dependencies = [ "bytes 1.0.0", "futures-channel", @@ -865,9 +865,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fcc7939b5edc4e4f86b1b4a04bb1498afaaf871b1a6691838ed06fcb48d3a3f" +checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" dependencies = [ "lazy_static", "libc", @@ -1425,9 +1425,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" dependencies = [ "itoa", "ryu", @@ -2060,8 +2060,9 @@ checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" [[package]] name = "trust-dns-proto" -version = "0.20.0-alpha.3" -source = "git+https://github.com/bluejekyll/trust-dns.git?branch=main#57245de7d73008c9f960ba8c952e2dbcee54bb84" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98a0381b2864c2978db7f8e17c7b23cca5a3a5f99241076e13002261a8ecbabd" dependencies = [ "async-trait", "cfg-if 1.0.0", @@ -2084,8 +2085,9 @@ dependencies = [ [[package]] name = "trust-dns-resolver" -version = "0.20.0-alpha.3" -source = "git+https://github.com/bluejekyll/trust-dns.git?branch=main#57245de7d73008c9f960ba8c952e2dbcee54bb84" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3072d18c10bd621cb00507d59cfab5517862285c353160366e37fbf4c74856e4" dependencies = [ "cfg-if 1.0.0", "futures-util", @@ -2108,8 +2110,9 @@ dependencies = [ [[package]] name = "trust-dns-rustls" -version = "0.20.0-alpha.3" -source = "git+https://github.com/bluejekyll/trust-dns.git?branch=main#57245de7d73008c9f960ba8c952e2dbcee54bb84" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "094ff0f3c89393b47a7bb6837a97b28688ef01e57a2400949db1bbb98c932502" dependencies = [ "futures-channel", "futures-io", diff --git a/crates/shadowsocks-service/Cargo.toml b/crates/shadowsocks-service/Cargo.toml index fc707cba..f8ed77fa 100644 --- a/crates/shadowsocks-service/Cargo.toml +++ b/crates/shadowsocks-service/Cargo.toml @@ -93,7 +93,7 @@ http = { version = "0.2", optional = true } hyper = { version = "0.14", optional = true, features = ["full"] } tower = { version = "0.3", optional = true } -trust-dns-resolver = { git = "https://github.com/bluejekyll/trust-dns.git", branch = "main", optional = true, features = ["serde-config"] } +trust-dns-resolver = { version = "0.20", optional = true, features = ["serde-config"] } ipnet = "2.3" iprange = "0.6" diff --git a/crates/shadowsocks-service/src/config.rs b/crates/shadowsocks-service/src/config.rs index f2b3c2ff..6b2203aa 100644 --- a/crates/shadowsocks-service/src/config.rs +++ b/crates/shadowsocks-service/src/config.rs @@ -539,6 +539,22 @@ impl FromStr for ProtocolType { } } +/// Configuration for `tun` device, enabled by `local-tun` +#[cfg(feature = "local-tun")] +#[derive(Clone, Debug)] +pub struct TunConfig { + /// Name of tun device. System will allocate one for you if set to empty + pub name: String, + /// MTU of the device + pub mtu: Option, + /// IPv4 address of device + pub address: Option, + /// IPv4 destination of device + pub destination: Option, + /// IPv4 netmark address of device + pub netmask: Option, +} + /// Configuration #[derive(Clone, Debug)] pub struct Config { @@ -633,10 +649,14 @@ pub struct Config { /// UDP Transparent Proxy type #[cfg(feature = "local-redir")] pub udp_redir: RedirType, - /// Flow statistic report Unix socket path (only for Android) + /// Flow statistic report Unix socket path (only for Android) #[cfg(feature = "local-flow-stat")] pub stat_path: Option, + + /// tun device configuration + #[cfg(feature = "local-tun")] + pub tun: Option, } /// Configuration parsing error kind @@ -753,6 +773,9 @@ impl Config { #[cfg(feature = "local-flow-stat")] stat_path: None, + + #[cfg(feature = "local-tun")] + tun: None, } } diff --git a/crates/shadowsocks/Cargo.toml b/crates/shadowsocks/Cargo.toml index 86684449..d7196f27 100644 --- a/crates/shadowsocks/Cargo.toml +++ b/crates/shadowsocks/Cargo.toml @@ -47,7 +47,7 @@ mio = "0.7" socket2 = "0.3" tokio = { version = "1.0", features = ["io-util", "macros", "net", "parking_lot", "process", "rt"] } -trust-dns-resolver = { git = "https://github.com/bluejekyll/trust-dns.git", branch = "main", optional = true } +trust-dns-resolver = { version = "0.20", optional = true } [target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies] shadowsocks-crypto = { version = "0.1", features = ["ring"] }