From 206c8c7f09af938d36854406ffce2c2c54b703ea Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Sat, 7 Dec 2019 14:32:23 +0800 Subject: [PATCH] Set trust-dns as default, optimized most of the context.clone()s --- Cargo.lock | 443 +++---------------- Cargo.toml | 8 +- build/Dockerfile | 2 +- src/context.rs | 12 +- src/relay/dns_resolver/trust_dns_resolver.rs | 16 +- src/relay/loadbalancing/server/ping.rs | 16 +- src/relay/tcprelay/client.rs | 25 +- src/relay/tcprelay/context.rs | 2 +- src/relay/tcprelay/mod.rs | 21 +- src/relay/tcprelay/server.rs | 5 +- src/relay/tcprelay/socks5_local.rs | 16 +- src/relay/tcprelay/tunnel_local.rs | 12 +- src/relay/udprelay/server.rs | 12 +- src/relay/udprelay/socks5_local.rs | 12 +- src/relay/udprelay/tunnel_local.rs | 2 +- 15 files changed, 135 insertions(+), 469 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f3967cc..8acdad6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,7 +42,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "async-trait" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -172,15 +172,6 @@ name = "byteorder" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bytes" version = "0.5.2" @@ -269,14 +260,6 @@ dependencies = [ "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cmac" version = "0.2.0" @@ -295,15 +278,6 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "crossbeam-utils" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crypto-mac" version = "0.7.0" @@ -501,25 +475,11 @@ dependencies = [ "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "futures-channel-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "futures-core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "futures-core-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "futures-executor" version = "0.3.1" @@ -530,26 +490,11 @@ dependencies = [ "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "futures-executor-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "futures-io" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "futures-io-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "futures-macro" version = "0.3.1" @@ -561,29 +506,11 @@ dependencies = [ "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "futures-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "futures-sink" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "futures-sink-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "futures-task" version = "0.3.1" @@ -607,20 +534,6 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "futures-util-preview" -version = "0.3.0-alpha.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "generic-array" version = "0.12.3" @@ -646,22 +559,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "h2" -version = "0.2.0-alpha.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -709,10 +620,10 @@ dependencies = [ [[package]] name = "http" -version = "0.1.20" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -798,9 +709,6 @@ dependencies = [ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "lazycell" @@ -824,7 +732,7 @@ dependencies = [ [[package]] name = "libsodium-ffi" version = "0.2.0" -source = "git+https://github.com/zonyitoo/libsodium-ffi#f7ca7f32d3f038e1116e55e3dfefc872af3ae972" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bindgen 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -852,14 +760,6 @@ name = "linked-hash-map" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lock_api" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "log" version = "0.4.8" @@ -891,11 +791,6 @@ name = "matches" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "md-5" version = "0.8.0" @@ -1081,30 +976,6 @@ dependencies = [ "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -1154,24 +1025,6 @@ dependencies = [ "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "pin-project" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "pin-project-internal 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "pin-project-lite" version = "0.1.1" @@ -1345,14 +1198,6 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rustls" version = "0.16.0" @@ -1374,11 +1219,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "scopeguard" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "sct" version = "0.6.0" @@ -1388,19 +1228,6 @@ dependencies = [ "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "serde" version = "1.0.103" @@ -1457,7 +1284,7 @@ dependencies = [ "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "json5 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "libsodium-ffi 0.2.0 (git+https://github.com/zonyitoo/libsodium-ffi)", + "libsodium-ffi 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru_time_cache 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "md-5 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1471,7 +1298,7 @@ dependencies = [ "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-resolver 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)", + "trust-dns-resolver 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1495,14 +1322,6 @@ name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "smallvec" version = "1.0.0" @@ -1537,14 +1356,6 @@ dependencies = [ "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "string" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "strsim" version = "0.8.0" @@ -1648,40 +1459,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tokio-codec" -version = "0.2.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-executor" -version = "0.2.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-io" -version = "0.2.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tokio-macros" version = "0.2.0" @@ -1691,26 +1468,6 @@ dependencies = [ "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tokio-net" -version = "0.2.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tokio-rustls" version = "0.12.0" @@ -1724,112 +1481,67 @@ dependencies = [ ] [[package]] -name = "tokio-sync" -version = "0.2.0-alpha.6" +name = "tokio-util" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-timer" -version = "0.3.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-attributes 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-core" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "trust-dns-https" -version = "0.18.0-alpha.1" -source = "git+https://github.com/bluejekyll/trust-dns#b3e729374f13b467e9ba7dd23785aab99af62fd5" +version = "0.18.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-net 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-rustls 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)", - "trust-dns-rustls 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)", - "typed-headers 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-proto 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-rustls 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", + "typed-headers 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "webpki-roots 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "trust-dns-proto" -version = "0.18.0-alpha.1" -source = "git+https://github.com/bluejekyll/trust-dns#b3e729374f13b467e9ba7dd23785aab99af62fd5" +version = "0.18.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "async-trait 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "async-trait 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "enum-as-inner 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-net 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.3.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "trust-dns-resolver" -version = "0.18.0-alpha.1" -source = "git+https://github.com/bluejekyll/trust-dns#b3e729374f13b467e9ba7dd23785aab99af62fd5" +version = "0.18.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1838,38 +1550,35 @@ dependencies = [ "rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-net 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-https 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)", - "trust-dns-proto 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)", - "trust-dns-rustls 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)", + "trust-dns-https 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-proto 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-rustls 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", "webpki-roots 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "trust-dns-rustls" -version = "0.18.0-alpha.1" -source = "git+https://github.com/bluejekyll/trust-dns#b3e729374f13b467e9ba7dd23785aab99af62fd5" +version = "0.18.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-net 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-rustls 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)", + "trust-dns-proto 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", "webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "typed-headers" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2171,7 +1880,7 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum anyhow 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9267dff192e68f3399525901e709a48c1d3982c9c072fa32f2127a0cb0babf14" "checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" -"checksum async-trait 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3495c8ae99b96d8a84050dee9d7b9d6425f9bfe84c2e3f800c2c2859457f8590" +"checksum async-trait 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "8b6dd385bb33043b833ba049048d57bdbb4d654a121ed68c71871ca51ff67070" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" @@ -2187,7 +1896,6 @@ dependencies = [ "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byte_string 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11aade7a05aa8c3a351cedc44c3fc45806430543382fcc4743a9b757a2a0b4ed" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c85319f157e4e26c703678e68e26ab71a46c0199286fa670b21cc9fec13d895" "checksum bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b" "checksum bzip2-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6584aa36f5ad4c9247f5323b0a42f37802b37a836f0ad87084d7a33961abe25f" @@ -2199,10 +1907,8 @@ dependencies = [ "checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" "checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmac 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4a435124bcc292eba031f1f725d7abacdaf13cbf9f935450e8c45aa9e96cad" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum curl 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)" = "06aa71e9208a54def20792d877bc663d6aae0732b9852e612c4a933177c31283" @@ -2225,30 +1931,23 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" "checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" -"checksum futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "d5e5f4df964fa9c1c2f8bddeb5c3611631cacd93baf810fc8bb2fb4b495c263a" "checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" -"checksum futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "b35b6263fb1ef523c3056565fa67b1d16f0a8604ff12b11b08c25f28a734c60a" "checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" -"checksum futures-executor-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "75236e88bd9fe88e5e8bfcd175b665d0528fe03ca4c5207fabc028c8f9d93e98" "checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" -"checksum futures-io-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "f4914ae450db1921a56c91bde97a27846287d062087d4a652efc09bb3a01ebda" "checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" -"checksum futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3b1dce2a0267ada5c6ff75a8ba864b4e679a9e2aa44262af7a3b5516d530d76e" "checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" -"checksum futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "86f148ef6b69f75bb610d4f9a2336d4fc88c4b5b67129d1a340dd0fd362efeec" "checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" "checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" -"checksum futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -"checksum h2 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0f107db1419ef8271686187b1a5d47c6431af4a7f4d98b495e7b7fc249bb0a78" +"checksum h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9433d71e471c1736fd5a61b671fc0b148d7a2992f666c958d03cd8feb3b88d1" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" "checksum hkdf 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fa08a006102488bd9cd5b8013aabe84955cf5ae22e304c2caf655b633aefae3" "checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" "checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" -"checksum http 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "2790658cddc82e82b08e25176c431d7015a0adeb1718498715cbd20138a0bf68" +"checksum http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" @@ -2262,16 +1961,14 @@ dependencies = [ "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum libsodium-ffi 0.2.0 (git+https://github.com/zonyitoo/libsodium-ffi)" = "" +"checksum libsodium-ffi 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afcda749bf3b53c0e7cfa728fb87508cdc9cb3e86598f16aa87f8434d506f504" "checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" -"checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" "checksum lru_time_cache 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab44e08e5b5110188be64dc8f0865635206ad7386fe672903bef195df3cc8960" "checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" "checksum md-5 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a18af3dcaf2b0219366cdb4e2af65a6101457b415c3d1a5c71dd9c2b7c77b9c8" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" @@ -2291,16 +1988,12 @@ dependencies = [ "checksum openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)" = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f" -"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" "checksum pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4fb201c5c22a55d8b24fef95f78be52738e5e1361129be1b5e862ecdb6894a" "checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" "checksum pest_generator 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9fcf299b5712d06ee128a556c94709aaa04512c4dffb8ead07c5c998447fc0" "checksum pest_meta 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "df43fd99896fd72c485fe47542c7b500e4ac1e8700bf995544d1317a60ded547" -"checksum pin-project 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "94b90146c7216e4cb534069fb91366de4ea0ea353105ee45ed297e2d1619e469" -"checksum pin-project-internal 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "44ca92f893f0656d3cba8158dd0f2b99b94de256a4a54e870bd6922fcc6c8355" "checksum pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f0af6cbca0e6e3ce8692ee19fb8d734b641899e07b68eb73e9bbbd32f1703991" "checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" @@ -2324,13 +2017,9 @@ dependencies = [ "checksum ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6747f8da1f2b1fabbee1aaa4eb8a11abf9adef0bf58a41cee45db5d59cecdfac" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e" "checksum schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" -"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum sct 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" "checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" "checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" @@ -2338,13 +2027,11 @@ dependencies = [ "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" "checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" "checksum stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" -"checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" @@ -2356,22 +2043,14 @@ dependencies = [ "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e765bf9f550bd9b8a970633ca3b56b8120c4b6c5dcbe26a93744cb02fee4b17" -"checksum tokio-codec 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9f5d22fd1e84bd4045d28813491cb7d7caae34d45c80517c2213f09a85e8787a" -"checksum tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee9ceecf69145923834ea73f32ba40c790fd877b74a7817dd0b089f1eb9c7c8" -"checksum tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "112784d5543df30660b04a72ca423bfbd90e8bb32f94dcf610f15401218b22c5" "checksum tokio-macros 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5795a71419535c6dcecc9b6ca95bdd3c2d6142f7e8343d7beb9923f129aa87e" -"checksum tokio-net 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a441682cd32f3559383112c4a7f372f5c9fa1950c5cf8c8dd05274a2ce8c2654" "checksum tokio-rustls 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "420448fb2a5fb489169ee30d1667d7182d7edc516a66a09f04cd2a6abf62134a" -"checksum tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4f1aaeb685540f7407ea0e27f1c9757d258c7c6bf4e3eb19da6fc59b747239d2" -"checksum tokio-timer 0.3.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b97c1587fe71018eb245a4a9daa13a5a3b681bbc1f7fdadfe24720e141472c13" -"checksum tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ff4e4f59e752cb3beb5b61c6d5e11191c7946231ba84faec2902c9efdd8691c5" -"checksum tracing-attributes 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a4263b12c3d3c403274493eb805966093b53214124796552d674ca1dd5d27c2b" -"checksum tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bc913647c520c959b6d21e35ed8fa6984971deca9f0a2fcb8c51207e0c56af1d" -"checksum trust-dns-https 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)" = "" -"checksum trust-dns-proto 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)" = "" -"checksum trust-dns-resolver 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)" = "" -"checksum trust-dns-rustls 0.18.0-alpha.1 (git+https://github.com/bluejekyll/trust-dns)" = "" -"checksum typed-headers 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bd6f5af532d859106afe9077c8f95bcaa09af272d5d9b338ec1ff05830b5803c" +"checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" +"checksum trust-dns-https 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2dfa86eaa1401fceddbdc431beb1171834dcff05b3f91b1207b796a13d68aa82" +"checksum trust-dns-proto 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2a7f3a2ab8a919f5eca52a468866a67ed7d3efa265d48a652a9a3452272b413f" +"checksum trust-dns-resolver 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6f90b1502b226f8b2514c6d5b37bafa8c200d7ca4102d57dc36ee0f3b7a04a2f" +"checksum trust-dns-rustls 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0c36e5f39dfde25d907a4500d6f86f3189d2b1b3e23407d7e22ad9ac63b278e1" +"checksum typed-headers 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3179a61e9eccceead5f1574fd173cf2e162ac42638b9bf214c6ad0baf7efa24a" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" "checksum ucd-trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8f00ed7be0c1ff1e24f46c3d2af4859f7e863672ba3a6e92e7cff702bf9f06c2" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" diff --git a/Cargo.toml b/Cargo.toml index 3689bc84..64bcbd94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ path = "src/bin/ssurl.rs" lto = true [features] -default = ["sodium", "rc4", "aes-cfb", "aes-ctr"] +default = ["sodium", "rc4", "aes-cfb", "aes-ctr", "trust-dns"] sodium = ["libsodium-ffi"] rc4 = ["openssl"] aes-cfb = ["openssl"] @@ -64,11 +64,9 @@ serde_urlencoded = "0.6" serde = { version = "1.0", features = ["derive"] } url = "2.1" byte_string = "1.0" -# libsodium-ffi = { version = "0.1", optional = true } -libsodium-ffi = { git = "https://github.com/zonyitoo/libsodium-ffi", optional = true } +libsodium-ffi = { version = "0.2", optional = true } miscreant = { version = "0.4", optional = true } -# trust-dns-resolver = { version = "0.11", features = ["dns-over-rustls", "dns-over-https-rustls"] } -trust-dns-resolver = { git = "https://github.com/bluejekyll/trust-dns", features = ["dns-over-rustls", "dns-over-https-rustls"], optional = true } +trust-dns-resolver = { version = "0.18.0-alpha", features = ["dns-over-rustls", "dns-over-https-rustls"], optional = true } hkdf = "0.8" hmac = "0.7" sha-1 = "0.8" diff --git a/build/Dockerfile b/build/Dockerfile index 2c1ec8ff..87937339 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -11,5 +11,5 @@ RUN cd /home/rust/libs && \ V=1 make && sudo make install && \ cd .. && rm -rf libsodium-$SODIUM_VERS.tar.gz libsodium-$SODIUM_VERS -ENV SODIUM_STATIC=yes +#ENV SODIUM_STATIC=yes ENV SODIUM_LIB_DIR=/usr/local/musl/lib diff --git a/src/context.rs b/src/context.rs index 29f3c31d..5c52e175 100644 --- a/src/context.rs +++ b/src/context.rs @@ -5,17 +5,17 @@ use std::sync::{ Arc, }; -#[cfg(futures = "trust-dns")] +#[cfg(feature = "trust-dns")] use trust_dns_resolver::AsyncResolver; use crate::config::Config; -#[cfg(futures = "trust-dns")] +#[cfg(feature = "trust-dns")] use crate::relay::dns_resolver::create_resolver; #[derive(Clone)] pub struct SharedServerState { - #[cfg(futures = "trust-dns")] + #[cfg(feature = "trust-dns")] dns_resolver: Arc, server_running: Arc, } @@ -24,7 +24,7 @@ impl SharedServerState { #[allow(unused_variables)] pub fn new(config: &Config) -> SharedServerState { SharedServerState { - #[cfg(futures = "trust-dns")] + #[cfg(feature = "trust-dns")] dns_resolver: Arc::new(create_resolver(config.get_dns_config())), server_running: Arc::new(AtomicBool::new(true)), } @@ -41,7 +41,7 @@ impl SharedServerState { } /// Get the global shared resolver - #[cfg(futures = "trust-dns")] + #[cfg(feature = "trust-dns")] pub fn dns_resolver(&self) -> &AsyncResolver { &*self.dns_resolver } @@ -78,7 +78,7 @@ impl Context { } /// Get the global shared resolver - #[cfg(futures = "trust-dns")] + #[cfg(feature = "trust-dns")] pub fn dns_resolver(&self) -> &AsyncResolver { self.server_state.dns_resolver() } diff --git a/src/relay/dns_resolver/trust_dns_resolver.rs b/src/relay/dns_resolver/trust_dns_resolver.rs index 2742eadb..b59882f0 100644 --- a/src/relay/dns_resolver/trust_dns_resolver.rs +++ b/src/relay/dns_resolver/trust_dns_resolver.rs @@ -9,7 +9,7 @@ use log::{debug, error, trace}; use tokio; use trust_dns_resolver::{config::ResolverConfig, AsyncResolver}; -use crate::context::SharedContext; +use crate::context::Context; pub fn create_resolver(dns: Option) -> AsyncResolver { let (resolver, bg) = { @@ -69,12 +69,7 @@ pub fn create_resolver(dns: Option) -> AsyncResolver { resolver } -async fn inner_resolve( - context: SharedContext, - addr: &str, - port: u16, - check_forbidden: bool, -) -> io::Result> { +async fn inner_resolve(context: &Context, addr: &str, port: u16, check_forbidden: bool) -> io::Result> { match context.dns_resolver().lookup_ip(addr).await { Err(err) => { error!("Failed to resolve {}:{}, err: {}", addr, port, err); @@ -109,11 +104,6 @@ async fn inner_resolve( } /// Resolve address to IP -pub async fn resolve( - context: SharedContext, - addr: &str, - port: u16, - check_forbidden: bool, -) -> io::Result> { +pub async fn resolve(context: &Context, addr: &str, port: u16, check_forbidden: bool) -> io::Result> { inner_resolve(context, addr, port, check_forbidden).await } diff --git a/src/relay/loadbalancing/server/ping.rs b/src/relay/loadbalancing/server/ping.rs index 4652d67e..54a810a8 100644 --- a/src/relay/loadbalancing/server/ping.rs +++ b/src/relay/loadbalancing/server/ping.rs @@ -1,17 +1,15 @@ use std::{ collections::VecDeque, - fmt, - io, + fmt, io, sync::{ atomic::{AtomicU64, AtomicUsize, Ordering}, - Arc, - Mutex, + Arc, Mutex, }, }; use crate::{ config::ServerConfig, - context::SharedContext, + context::{Context, SharedContext}, relay::{loadbalancing::server::LoadBalancer, socks5::Address, tcprelay::client::ServerClient}, }; @@ -144,7 +142,7 @@ impl Inner { while context.server_running() { interval.tick().await; - let score = match Inner::check_delay(sc.clone(), context.clone()).await { + let score = match Inner::check_delay(&*sc, &*context).await { Ok(d) => latency.push(d), Err(..) => latency.push(DEFAULT_CHECK_TIMEOUT_SEC * 2 * 1000), // Penalty }; @@ -161,7 +159,7 @@ impl Inner { } } - async fn check_request(sc: Arc, context: SharedContext) -> io::Result<()> { + async fn check_request(sc: Arc, context: &Context) -> io::Result<()> { static GET_BODY: &[u8] = b"GET /generate_204 HTTP/1.1\r\nHost: dl.google.com\r\nConnection: close\r\nAccept: */*\r\n\r\n"; @@ -176,12 +174,12 @@ impl Inner { Ok(()) } - async fn check_delay(sc: Arc, context: SharedContext) -> io::Result { + async fn check_delay(sc: &Server, context: &Context) -> io::Result { let start = Instant::now(); // Send HTTP GET and read the first byte let timeout = Duration::from_secs(DEFAULT_CHECK_TIMEOUT_SEC); - let res = time::timeout(timeout, Inner::check_request(sc.config.clone(), context.clone())).await; + let res = time::timeout(timeout, Inner::check_request(sc.config.clone(), context)).await; let elapsed = Instant::now() - start; let elapsed = elapsed.as_secs() * 1000 + u64::from(elapsed.subsec_millis()); // Converted to ms diff --git a/src/relay/tcprelay/client.rs b/src/relay/tcprelay/client.rs index 15d53acb..159fb6d8 100644 --- a/src/relay/tcprelay/client.rs +++ b/src/relay/tcprelay/client.rs @@ -5,25 +5,18 @@ use std::{ net::SocketAddr, pin::Pin, sync::Arc, - task::{Context, Poll}, + task::{self, Poll}, }; use log::trace; use tokio::{net::TcpStream, prelude::*}; use crate::relay::socks5::{ - self, - Address, - Command, - HandshakeRequest, - HandshakeResponse, - Reply, - TcpRequestHeader, - TcpResponseHeader, + self, Address, Command, HandshakeRequest, HandshakeResponse, Reply, TcpRequestHeader, TcpResponseHeader, }; use super::{CryptoStream, STcpStream}; -use crate::{config::ServerConfig, context::SharedContext}; +use crate::{config::ServerConfig, context::Context}; /// Socks5 proxy client pub struct Socks5Client { @@ -111,21 +104,21 @@ impl Socks5Client { } impl AsyncRead for Socks5Client { - fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll> { + fn poll_read(mut self: Pin<&mut Self>, cx: &mut task::Context, buf: &mut [u8]) -> Poll> { Pin::new(&mut self.stream).poll_read(cx, buf) } } impl AsyncWrite for Socks5Client { - fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll> { + fn poll_write(mut self: Pin<&mut Self>, cx: &mut task::Context, buf: &[u8]) -> Poll> { Pin::new(&mut self.stream).poll_write(cx, buf) } - fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_flush(mut self: Pin<&mut Self>, cx: &mut task::Context) -> Poll> { Pin::new(&mut self.stream).poll_flush(cx) } - fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut task::Context) -> Poll> { Pin::new(&mut self.stream).poll_shutdown(cx) } } @@ -136,11 +129,11 @@ pub(crate) struct ServerClient { impl ServerClient { pub(crate) async fn connect( - context: SharedContext, + context: &Context, addr: &Address, svr_cfg: Arc, ) -> io::Result { - let stream = super::connect_proxy_server(context, svr_cfg.clone()).await?; + let stream = super::connect_proxy_server(context, &*svr_cfg).await?; Ok(ServerClient { stream: super::proxy_server_handshake(stream, svr_cfg, addr).await?, }) diff --git a/src/relay/tcprelay/context.rs b/src/relay/tcprelay/context.rs index ad79ba83..88e155c3 100644 --- a/src/relay/tcprelay/context.rs +++ b/src/relay/tcprelay/context.rs @@ -102,7 +102,7 @@ impl TcpServerContext { ServerAddr::DomainName(ref domain, ref port) => { use crate::relay::dns_resolver::resolve; - let addrs = resolve(self.context.clone(), &domain[..], *port, false).await?; + let addrs = resolve(&*self.context, &domain[..], *port, false).await?; socket.send_to(payload.as_ref(), addrs[0]).await?; } #[cfg(not(feature = "trust-dns"))] diff --git a/src/relay/tcprelay/mod.rs b/src/relay/tcprelay/mod.rs index b75d3984..d84302d1 100644 --- a/src/relay/tcprelay/mod.rs +++ b/src/relay/tcprelay/mod.rs @@ -10,13 +10,13 @@ use std::{ ops::{Deref, DerefMut}, pin::Pin, sync::Arc, - task::{Context, Poll}, + task::{self, Poll}, time::Duration, }; use crate::{ config::{ConfigType, ServerAddr, ServerConfig}, - context::SharedContext, + context::Context, relay::{socks5::Address, utils::try_timeout}, }; @@ -24,9 +24,8 @@ use bytes::BytesMut; use futures::{future::FusedFuture, ready, select, Future}; use log::trace; use tokio::{ - io::{BufReader, ReadHalf, WriteHalf}, + io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, BufReader, ReadHalf, WriteHalf}, net::TcpStream, - prelude::*, time::{self, Delay}, }; @@ -78,7 +77,7 @@ impl Connection { ErrorKind::TimedOut.into() } - fn poll_timeout(&mut self, cx: &mut Context<'_>) -> Poll> { + fn poll_timeout(&mut self, cx: &mut task::Context<'_>) -> Poll> { loop { if let Some(ref mut timer) = self.timer { ready!(Pin::new(timer).poll(cx)); @@ -135,7 +134,7 @@ impl AsyncRead for Connection where S: AsyncRead + Unpin, { - fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll> { + fn poll_read(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: &mut [u8]) -> Poll> { match Pin::new(&mut self.stream).poll_read(cx, buf) { Poll::Ready(r) => { self.cancel_timeout(); @@ -153,7 +152,7 @@ impl AsyncWrite for Connection where S: AsyncRead + AsyncWrite + Unpin, { - fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll> { + fn poll_write(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: &[u8]) -> Poll> { match Pin::new(&mut self.stream).poll_write(cx, buf) { Poll::Ready(r) => { self.cancel_timeout(); @@ -166,7 +165,7 @@ where } } - fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + fn poll_flush(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll> { match Pin::new(&mut self.stream).poll_flush(cx) { Poll::Ready(r) => { self.cancel_timeout(); @@ -179,7 +178,7 @@ where } } - fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll> { Pin::new(&mut self.stream).poll_shutdown(cx) } } @@ -187,7 +186,7 @@ where pub type STcpStream = Connection; /// Connect to proxy server with `ServerConfig` -async fn connect_proxy_server(context: SharedContext, svr_cfg: Arc) -> io::Result { +async fn connect_proxy_server(context: &Context, svr_cfg: &ServerConfig) -> io::Result { let timeout = svr_cfg.timeout(); let svr_addr = match context.config().config_type { @@ -213,7 +212,7 @@ async fn connect_proxy_server(context: SharedContext, svr_cfg: Arc let mut last_err: Option = None; for addr in &vec_ipaddr { match try_timeout(TcpStream::connect(addr), timeout).await { - Ok(s) => return Ok(STcpStream::new(BufReader::new(s), timeout)), + Ok(s) => return Ok(STcpStream::new(s, timeout)), Err(e) => { error!( "Failed to connect {}:{}, resolved address {}, try another (err: {})", diff --git a/src/relay/tcprelay/server.rs b/src/relay/tcprelay/server.rs index 293a858d..75a378e9 100644 --- a/src/relay/tcprelay/server.rs +++ b/src/relay/tcprelay/server.rs @@ -17,8 +17,7 @@ use crate::{context::SharedContext, relay::socks5::Address}; use super::{ context::{SharedTcpServerContext, TcpServerContext}, monitor::TcpMonStream, - CryptoStream, - STcpStream, + CryptoStream, STcpStream, }; #[allow(clippy::cognitive_complexity)] @@ -94,7 +93,7 @@ async fn handle_client( Address::DomainNameAddress(ref dname, port) => { use crate::relay::dns_resolver::resolve; - let addrs = match resolve(context.clone(), dname.as_str(), port, true).await { + let addrs = match resolve(&*context, dname.as_str(), port, true).await { Ok(r) => r, Err(err) => { error!("Failed to resolve {}, {}", dname, err); diff --git a/src/relay/tcprelay/socks5_local.rs b/src/relay/tcprelay/socks5_local.rs index 707e5a9b..c86d17c7 100644 --- a/src/relay/tcprelay/socks5_local.rs +++ b/src/relay/tcprelay/socks5_local.rs @@ -8,13 +8,15 @@ use tokio::{ self, net::{ tcp::{ReadHalf, WriteHalf}, - TcpListener, - TcpStream, + TcpListener, TcpStream, }, prelude::*, }; -use crate::{config::ServerConfig, context::SharedContext}; +use crate::{ + config::ServerConfig, + context::{Context, SharedContext}, +}; use crate::relay::{ loadbalancing::server::{LoadBalancer, PingBalancer}, @@ -30,14 +32,14 @@ struct UdpConfig { } async fn handle_socks5_connect<'a>( - context: SharedContext, + context: &Context, (mut r, mut w): (ReadHalf<'a>, WriteHalf<'a>), client_addr: SocketAddr, local_addr: SocketAddr, addr: &Address, svr_cfg: Arc, ) -> io::Result<()> { - let svr_s = match super::connect_proxy_server(context, svr_cfg.clone()).await { + let svr_s = match super::connect_proxy_server(context, &*svr_cfg).await { Ok(svr_s) => { trace!("Proxy server connected, {:?}", svr_cfg); @@ -116,7 +118,7 @@ async fn handle_socks5_connect<'a>( #[allow(clippy::cognitive_complexity)] async fn handle_socks5_client( - context: SharedContext, + context: &Context, mut s: TcpStream, conf: Arc, udp_conf: UdpConfig, @@ -256,7 +258,7 @@ pub async fn run(context: SharedContext) -> io::Result<()> { let context = context.clone(); let udp_conf = udp_conf.clone(); tokio::spawn(async move { - if let Err(err) = handle_socks5_client(context, socket, server_cfg, udp_conf).await { + if let Err(err) = handle_socks5_client(&*context, socket, server_cfg, udp_conf).await { error!("Socks5 client {}", err); } }); diff --git a/src/relay/tcprelay/tunnel_local.rs b/src/relay/tcprelay/tunnel_local.rs index 1931b6e2..9ae4ab06 100644 --- a/src/relay/tcprelay/tunnel_local.rs +++ b/src/relay/tcprelay/tunnel_local.rs @@ -8,7 +8,7 @@ use tokio::net::{TcpListener, TcpStream}; use crate::{ config::ServerConfig, - context::SharedContext, + context::{Context, SharedContext}, relay::{ loadbalancing::server::{LoadBalancer, PingBalancer}, socks5::Address, @@ -19,13 +19,13 @@ use crate::{ /// /// This method must be called after handshaking with client (for example, socks5 handshaking) async fn establish_client_tcp_tunnel<'a>( - context: SharedContext, + context: &Context, mut s: TcpStream, client_addr: SocketAddr, addr: &Address, svr_cfg: Arc, ) -> io::Result<()> { - let svr_s = match super::connect_proxy_server(context, svr_cfg.clone()).await { + let svr_s = match super::connect_proxy_server(context, &*svr_cfg).await { Ok(svr_s) => { trace!("Proxy server connected, {:?}", svr_cfg); svr_s @@ -77,7 +77,7 @@ async fn establish_client_tcp_tunnel<'a>( Ok(()) } -async fn handle_tunnel_client(context: SharedContext, s: TcpStream, conf: Arc) -> io::Result<()> { +async fn handle_tunnel_client(context: &Context, s: TcpStream, conf: Arc) -> io::Result<()> { if let Err(err) = s.set_keepalive(conf.timeout()) { error!("Failed to set keep alive: {:?}", err); } @@ -93,7 +93,7 @@ async fn handle_tunnel_client(context: SharedContext, s: TcpStream, conf: Arc io::Result<()> { @@ -123,7 +123,7 @@ pub async fn run(context: SharedContext) -> io::Result<()> { let context = context.clone(); tokio::spawn(async move { - if let Err(err) = handle_tunnel_client(context, socket, server_cfg).await { + if let Err(err) = handle_tunnel_client(&*context, socket, server_cfg).await { error!("TCP Tunnel client {}", err); } }); diff --git a/src/relay/udprelay/server.rs b/src/relay/udprelay/server.rs index 3152f5c2..ea77671f 100644 --- a/src/relay/udprelay/server.rs +++ b/src/relay/udprelay/server.rs @@ -22,7 +22,7 @@ use tokio::{ use crate::{ config::ServerConfig, - context::SharedContext, + context::{Context, SharedContext}, relay::{socks5::Address, utils::try_timeout}, }; @@ -41,6 +41,7 @@ struct UdpAssociation { impl UdpAssociation { /// Create an association with addr async fn associate( + context: SharedContext, svr_cfg: Arc, src_addr: SocketAddr, mut response_tx: mpsc::Sender<(SocketAddr, BytesMut)>, @@ -65,7 +66,8 @@ impl UdpAssociation { tokio::spawn(async move { while let Some(pkt) = rx.recv().await { // pkt is already a raw packet, so just send it - if let Err(err) = UdpAssociation::relay_l2r(src_addr, &mut sender, &pkt[..], timeout, &*c_svr_cfg).await + if let Err(err) = + UdpAssociation::relay_l2r(&*context, src_addr, &mut sender, &pkt[..], timeout, &*c_svr_cfg).await { error!("Failed to relay packet, {} -> ..., error: {}", src_addr, err); @@ -95,7 +97,9 @@ impl UdpAssociation { } /// Relay packets from local to remote + #[cfg_attr(not(feature = "trust-dns"), allow(unused_variables))] async fn relay_l2r( + context: &Context, src: SocketAddr, remote_udp: &mut SendHalf, pkt: &[u8], @@ -225,7 +229,7 @@ impl UdpAssociation { } } -async fn listen(_context: SharedContext, svr_cfg: Arc) -> io::Result<()> { +async fn listen(context: SharedContext, svr_cfg: Arc) -> io::Result<()> { let listen_addr = *svr_cfg.addr().listen_addr(); info!("ShadowSocks UDP listening on {}", listen_addr); @@ -264,7 +268,7 @@ async fn listen(_context: SharedContext, svr_cfg: Arc) -> io::Resu let assoc = match assoc_map.entry(src.to_string()) { Entry::Occupied(oc) => oc.into_mut(), Entry::Vacant(vc) => vc.insert( - UdpAssociation::associate(svr_cfg.clone(), src, tx.clone()) + UdpAssociation::associate(context.clone(), svr_cfg.clone(), src, tx.clone()) .await .expect("Failed to create udp association"), ), diff --git a/src/relay/udprelay/socks5_local.rs b/src/relay/udprelay/socks5_local.rs index 1e807e4f..e493ef71 100644 --- a/src/relay/udprelay/socks5_local.rs +++ b/src/relay/udprelay/socks5_local.rs @@ -21,7 +21,7 @@ use tokio::{ use crate::{ config::{ServerAddr, ServerConfig}, - context::SharedContext, + context::{Context, SharedContext}, relay::{ loadbalancing::server::{LoadBalancer, RoundRobin}, socks5::{Address, UdpAssociateHeader}, @@ -65,6 +65,7 @@ struct UdpAssociation { impl UdpAssociation { /// Create an association with addr async fn associate( + context: SharedContext, svr_cfg: Arc, src_addr: SocketAddr, mut response_tx: mpsc::Sender<(SocketAddr, Vec)>, @@ -89,7 +90,8 @@ impl UdpAssociation { tokio::spawn(async move { while let Some(pkt) = rx.recv().await { // pkt is already a raw packet, so just send it - if let Err(err) = UdpAssociation::relay_l2r(src_addr, &mut sender, &pkt[..], timeout, &*c_svr_cfg).await + if let Err(err) = + UdpAssociation::relay_l2r(&*context, src_addr, &mut sender, &pkt[..], timeout, &*c_svr_cfg).await { error!("Failed to send packet {} -> ..., error: {}", src_addr, err); @@ -119,7 +121,9 @@ impl UdpAssociation { } /// Relay packets from local to remote + #[cfg_attr(not(feature = "trust-dns"), allow(unused_variables))] async fn relay_l2r( + context: &Context, src: SocketAddr, remote_udp: &mut SendHalf, pkt: &[u8], @@ -151,7 +155,7 @@ impl UdpAssociation { ServerAddr::DomainName(ref dname, port) => { use crate::relay::dns_resolver::resolve; - let vec_ipaddr = resolve(context, dname, port, false).await?; + let vec_ipaddr = resolve(context, dname, *port, false).await?; assert!(!vec_ipaddr.is_empty()); try_timeout(remote_udp.send_to(&encrypt_buf[..], &vec_ipaddr[0]), Some(timeout)).await? @@ -274,7 +278,7 @@ async fn listen(context: SharedContext, l: UdpSocket) -> io::Result<()> { let assoc = match assoc_map.entry(src.to_string()) { Entry::Occupied(oc) => oc.into_mut(), Entry::Vacant(vc) => vc.insert( - UdpAssociation::associate(svr_cfg.clone(), src, tx.clone()) + UdpAssociation::associate(context.clone(), svr_cfg.clone(), src, tx.clone()) .await .expect("Failed to create udp association"), ), diff --git a/src/relay/udprelay/tunnel_local.rs b/src/relay/udprelay/tunnel_local.rs index 01fd6365..e9923b6f 100644 --- a/src/relay/udprelay/tunnel_local.rs +++ b/src/relay/udprelay/tunnel_local.rs @@ -133,7 +133,7 @@ impl UdpAssociation { ServerAddr::DomainName(ref dname, port) => { use crate::relay::dns_resolver::resolve; - let vec_ipaddr = resolve(context, dname, port, false).await?; + let vec_ipaddr = resolve(context, dname, *port, false).await?; assert!(!vec_ipaddr.is_empty()); try_timeout(remote_udp.send_to(&encrypt_buf[..], &vec_ipaddr[0]), Some(timeout)).await?