diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-08-15 04:34:42 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-09-01 14:17:21 +0200 |
| commit | 546a7b2b166528251364f28bf3c2ec9687705b48 (patch) | |
| tree | f5b35c78e299f3a6810b8f5eec0cfc1d33e23037 | |
| parent | 4f4b661e9748f2b6a1ee45c6175fac9f6dfad8ea (diff) | |
| download | mullvadvpn-546a7b2b166528251364f28bf3c2ec9687705b48.tar.xz mullvadvpn-546a7b2b166528251364f28bf3c2ec9687705b48.zip | |
Update tunnel state machine event loop and remove tokio 0.1
| -rw-r--r-- | Cargo.lock | 284 | ||||
| -rw-r--r-- | mullvad-daemon/Cargo.toml | 4 | ||||
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 4 | ||||
| -rw-r--r-- | mullvad-daemon/src/main.rs | 2 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 32 | ||||
| -rw-r--r-- | mullvad-daemon/src/relays.rs | 6 | ||||
| -rw-r--r-- | mullvad-daemon/src/version_check.rs | 6 | ||||
| -rw-r--r-- | mullvad-daemon/src/wireguard.rs | 7 | ||||
| -rw-r--r-- | talpid-core/Cargo.toml | 5 | ||||
| -rw-r--r-- | talpid-core/src/future_retry.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/offline/linux.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/routing/linux.rs | 6 | ||||
| -rw-r--r-- | talpid-core/src/routing/macos.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/routing/unix.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/openvpn.rs | 8 | ||||
| -rw-r--r-- | talpid-core/src/tunnel_state_machine/mod.rs | 96 |
16 files changed, 71 insertions, 405 deletions
diff --git a/Cargo.lock b/Cargo.lock index 31d6dd3547..3d8051a290 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,15 +182,6 @@ 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.4 (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.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -284,40 +275,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "crossbeam-deque" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -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)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "crossbeam-utils" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1078,14 +1035,6 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "memoffset" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "miniz_oxide" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1238,8 +1187,6 @@ dependencies = [ "talpid-core 0.1.0", "talpid-types 0.1.0", "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "triggered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2197,11 +2144,6 @@ dependencies = [ ] [[package]] -name = "scoped-tls" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2322,11 +2264,6 @@ dependencies = [ [[package]] name = "slab" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2526,9 +2463,6 @@ dependencies = [ "talpid-types 0.1.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "tonic 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "tonic-build 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "triggered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2648,29 +2582,6 @@ dependencies = [ [[package]] name = "tokio" -version = "0.1.22" -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 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-fs 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-uds 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio" version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ @@ -2693,72 +2604,6 @@ dependencies = [ ] [[package]] -name = "tokio-codec" -version = "0.1.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)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-core" -version = "0.1.17" -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 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-fs" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -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 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "tokio-macros" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2769,24 +2614,6 @@ dependencies = [ ] [[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (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.11 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.13.0 (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-executor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "tokio-rustls" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2798,95 +2625,6 @@ dependencies = [ ] [[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -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 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (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.11 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.13.0 (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.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-timer" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-timer" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (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.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-udp" -version = "0.1.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 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-uds" -version = "0.2.7" -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 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.76 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-uds 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "tokio-util" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3506,7 +3244,6 @@ dependencies = [ "checksum blake2b_simd 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" "checksum bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" "checksum cc 1.0.59 (registry+https://github.com/rust-lang/crates.io-index)" = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" "checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" @@ -3519,9 +3256,6 @@ dependencies = [ "checksum constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" "checksum core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" "checksum core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" -"checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -"checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -"checksum crossbeam-queue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" "checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" "checksum ct-logs 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4d3686f5fa27dbc1d76c751300376e167c5a43387f44bb451fd1c24776e49113" "checksum ctrlc 3.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d0b676fa23f995faf587496dcd1c80fead847ed58d2da52ac1caca9a72790dd2" @@ -3608,7 +3342,6 @@ dependencies = [ "checksum log-panics 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae0136257df209261daa18d6c16394757c63e032e27aafd8b07788b051082bef" "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" "checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" -"checksum memoffset 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" "checksum miniz_oxide 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" "checksum mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)" = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" "checksum mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" @@ -3707,7 +3440,6 @@ dependencies = [ "checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" "checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" "checksum schannel 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" -"checksum scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" "checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" "checksum sct 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" "checksum security-framework 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" @@ -3722,7 +3454,6 @@ dependencies = [ "checksum shell-escape 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" "checksum signal-hook-registry 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035" "checksum simple-signal 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53f7da44adcc42667d57483bd93f81295f27d66897804b757573b61b6f13288b" -"checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "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 snailquote 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc3e2894a343234fb8a8653cf9d49ef6aea44e6581612ca311c91c4bd356dec4" @@ -3749,24 +3480,9 @@ dependencies = [ "checksum thiserror-impl 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" "checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" -"checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" "checksum tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" -"checksum tokio-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" -"checksum tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "aeeffbbb94209023feaef3c196a41cbcdafa06b4a6f893f68779bb5e53796f71" -"checksum tokio-current-thread 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -"checksum tokio-executor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -"checksum tokio-fs 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" -"checksum tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" "checksum tokio-macros 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" -"checksum tokio-reactor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" "checksum tokio-rustls 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4" -"checksum tokio-sync 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -"checksum tokio-tcp 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -"checksum tokio-threadpool 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -"checksum tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6131e780037787ff1b3f8aad9da83bca02438b72277850dd6ad0d455e0e20efc" -"checksum tokio-timer 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" -"checksum tokio-udp 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" -"checksum tokio-uds 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" "checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" "checksum tokio-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" "checksum toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index 86abaabfaf..4847bb7465 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -24,9 +24,7 @@ rand = "0.7" regex = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -tokio02 = { package = "tokio", version = "0.2", features = [ "io-util", "process", "rt-core", "rt-threaded", "stream", "fs"] } -tokio-core = "0.1" -tokio-timer = "0.1" +tokio = { version = "0.2", features = [ "io-util", "process", "rt-core", "rt-threaded", "stream", "fs"] } uuid = { version = "0.7", features = ["v4"] } mullvad-paths = { path = "../mullvad-paths" } diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 3a083b512e..f848af595d 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -666,7 +666,7 @@ where cb(); } - let shutdown_signal = tokio02::time::timeout( + let shutdown_signal = tokio::time::timeout( TUNNEL_STATE_MACHINE_SHUTDOWN_TIMEOUT, tunnel_state_machine_shutdown_signal, ); @@ -958,7 +958,7 @@ where fn schedule_reconnect(&mut self, delay: Duration) { let tunnel_command_tx = self.tx.to_specialized_sender(); let (future, abort_handle) = abortable(Box::pin(async move { - tokio02::time::delay_for(delay).await; + tokio::time::delay_for(delay).await; log::debug!("Attempting to reconnect"); let _ = tunnel_command_tx.send(DaemonCommand::Reconnect); })); diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index adb7c39f0a..9afd231c93 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -87,7 +87,7 @@ fn run_platform(_config: &cli::Config, log_dir: Option<PathBuf>) -> Result<(), S fn run_standalone(log_dir: Option<PathBuf>) -> Result<(), String> { { - let mut runtime = tokio02::runtime::Builder::new() + let mut runtime = tokio::runtime::Builder::new() .basic_scheduler() .enable_all() .build() diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index cebdd18667..5fe25fc15c 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -38,7 +38,7 @@ pub enum Error { // Unable to start the tokio runtime #[error(display = "Failed to create the tokio runtime")] - TokioRuntimeError(#[error(source)] tokio02::io::Error), + TokioRuntimeError(#[error(source)] tokio::io::Error), } struct ManagementServiceImpl { @@ -48,9 +48,8 @@ struct ManagementServiceImpl { pub type ServiceResult<T> = std::result::Result<Response<T>, Status>; type EventsListenerReceiver = - tokio02::sync::mpsc::UnboundedReceiver<Result<types::DaemonEvent, Status>>; -type EventsListenerSender = - tokio02::sync::mpsc::UnboundedSender<Result<types::DaemonEvent, Status>>; + tokio::sync::mpsc::UnboundedReceiver<Result<types::DaemonEvent, Status>>; +type EventsListenerSender = tokio::sync::mpsc::UnboundedSender<Result<types::DaemonEvent, Status>>; const INVALID_VOUCHER_MESSAGE: &str = "This voucher code is invalid"; const USED_VOUCHER_MESSAGE: &str = "This voucher code has already been used"; @@ -58,9 +57,8 @@ const USED_VOUCHER_MESSAGE: &str = "This voucher code has already been used"; #[mullvad_management_interface::async_trait] impl ManagementService for ManagementServiceImpl { type GetRelayLocationsStream = - tokio02::sync::mpsc::Receiver<Result<types::RelayListCountry, Status>>; - type GetSplitTunnelProcessesStream = - tokio02::sync::mpsc::UnboundedReceiver<Result<i32, Status>>; + tokio::sync::mpsc::Receiver<Result<types::RelayListCountry, Status>>; + type GetSplitTunnelProcessesStream = tokio::sync::mpsc::UnboundedReceiver<Result<i32, Status>>; type EventsListenStream = EventsListenerReceiver; // Control and get the tunnel state @@ -104,7 +102,7 @@ impl ManagementService for ManagementServiceImpl { // async fn events_listen(&self, _: Request<()>) -> ServiceResult<Self::EventsListenStream> { - let (tx, rx) = tokio02::sync::mpsc::unbounded_channel(); + let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); let mut subscriptions = self.subscriptions.write(); subscriptions.push(tx); @@ -195,9 +193,9 @@ impl ManagementService for ManagementServiceImpl { let locations = rx.await.map_err(|_| Status::internal("internal error"))?; let (mut stream_tx, stream_rx) = - tokio02::sync::mpsc::channel(cmp::max(1, locations.countries.len())); + tokio::sync::mpsc::channel(cmp::max(1, locations.countries.len())); - tokio02::spawn(async move { + tokio::spawn(async move { for country in &locations.countries { if let Err(error) = stream_tx .send(Ok(convert_relay_list_country(country))) @@ -624,8 +622,8 @@ impl ManagementService for ManagementServiceImpl { self.send_command_to_daemon(DaemonCommand::GetSplitTunnelProcesses(tx))?; let pids = rx.await.map_err(|_| Status::internal("internal error"))?; - let (tx, rx) = tokio02::sync::mpsc::unbounded_channel(); - tokio02::spawn(async move { + let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); + tokio::spawn(async move { for pid in pids { let _ = tx.send(Ok(pid)); } @@ -635,7 +633,7 @@ impl ManagementService for ManagementServiceImpl { } #[cfg(not(target_os = "linux"))] { - let (_, rx) = tokio02::sync::mpsc::unbounded_channel(); + let (_, rx) = tokio::sync::mpsc::unbounded_channel(); Ok(Response::new(rx)) } } @@ -1443,17 +1441,17 @@ fn convert_proto_location(location: types::RelayLocation) -> Constraint<Location pub struct ManagementInterfaceServer { subscriptions: Arc<RwLock<Vec<EventsListenerSender>>>, socket_path: String, - runtime: tokio02::runtime::Runtime, + runtime: tokio::runtime::Runtime, server_abort_tx: triggered::Trigger, server_join_handle: Option< - tokio02::task::JoinHandle<std::result::Result<(), mullvad_management_interface::Error>>, + tokio::task::JoinHandle<std::result::Result<(), mullvad_management_interface::Error>>, >, } impl ManagementInterfaceServer { pub fn start(tunnel_tx: DaemonCommandSender) -> Result<Self, Error> { // TODO: don't spawn a tokio runtime here; make this function async - let mut runtime = tokio02::runtime::Builder::new() + let mut runtime = tokio::runtime::Builder::new() .threaded_scheduler() .core_threads(1) .enable_all() @@ -1521,7 +1519,7 @@ impl ManagementInterfaceServer { /// A handle that allows broadcasting messages to all subscribers of the management interface. #[derive(Clone)] pub struct ManagementInterfaceEventBroadcaster { - runtime: tokio02::runtime::Handle, + runtime: tokio::runtime::Handle, subscriptions: Arc<RwLock<Vec<EventsListenerSender>>>, close_handle: triggered::Trigger, } diff --git a/mullvad-daemon/src/relays.rs b/mullvad-daemon/src/relays.rs index 78e0292023..ce880a3d19 100644 --- a/mullvad-daemon/src/relays.rs +++ b/mullvad-daemon/src/relays.rs @@ -33,7 +33,7 @@ use talpid_types::{ net::{all_of_the_internet, openvpn::ProxySettings, wireguard, TransportProtocol, TunnelType}, ErrorExt, }; -use tokio02::fs::File; +use tokio::fs::File; const DATE_TIME_FORMAT_STR: &str = "%Y-%m-%d %H:%M:%S%.3f"; const RELAYS_FILENAME: &str = "relays.json"; @@ -807,7 +807,7 @@ impl RelayListUpdater { } async fn run(mut self, mut cmd_rx: mpsc::Receiver<()>) { - let mut check_interval = tokio02::time::interval(UPDATE_CHECK_INTERVAL).fuse(); + let mut check_interval = tokio::time::interval(UPDATE_CHECK_INTERVAL).fuse(); let mut download_future = Box::pin(Fuse::terminated()); loop { futures::select! { @@ -918,7 +918,7 @@ impl RelayListUpdater { .map_err(Error::OpenRelayCache)?; let bytes = serde_json::to_vec_pretty(relays).map_err(Error::Serialize)?; let mut slice: &[u8] = bytes.as_slice(); - let _ = tokio02::io::copy(&mut slice, &mut file) + let _ = tokio::io::copy(&mut slice, &mut file) .await .map_err(Error::WriteRelayCache)?; Ok(()) diff --git a/mullvad-daemon/src/version_check.rs b/mullvad-daemon/src/version_check.rs index 6092c5b0de..183082f457 100644 --- a/mullvad-daemon/src/version_check.rs +++ b/mullvad-daemon/src/version_check.rs @@ -17,7 +17,7 @@ use std::{ }; use talpid_core::mpsc::Sender; use talpid_types::ErrorExt; -use tokio02::fs::File; +use tokio::fs::File; const VERSION_INFO_FILENAME: &str = "version-info.json"; @@ -165,7 +165,7 @@ impl VersionUpdater { let mut buf = serde_json::to_vec_pretty(&cached_app_version).map_err(Error::Serialize)?; let mut read_buf: &[u8] = buf.as_mut(); - let _ = tokio02::io::copy(&mut read_buf, &mut file) + let _ = tokio::io::copy(&mut read_buf, &mut file) .await .map_err(Error::WriteVersionCache)?; Ok(()) @@ -218,7 +218,7 @@ impl VersionUpdater { pub async fn run(mut self) { let mut rx = self.rx.take().unwrap().fuse(); - let next_delay = || tokio02::time::delay_for(UPDATE_CHECK_INTERVAL).fuse(); + let next_delay = || tokio::time::delay_for(UPDATE_CHECK_INTERVAL).fuse(); let mut check_delay = next_delay(); let mut version_check = futures::future::Fuse::terminated(); diff --git a/mullvad-daemon/src/wireguard.rs b/mullvad-daemon/src/wireguard.rs index 2ebd5fae50..8ad580dd55 100644 --- a/mullvad-daemon/src/wireguard.rs +++ b/mullvad-daemon/src/wireguard.rs @@ -19,7 +19,6 @@ pub use talpid_types::net::wireguard::{ ConnectionConfig, PrivateKey, TunnelConfig, TunnelParameters, }; use talpid_types::ErrorExt; -use tokio_timer; /// Default automatic key rotation const DEFAULT_AUTOMATIC_KEY_ROTATION: Duration = Duration::from_secs(7 * 24 * 60 * 60); @@ -35,8 +34,6 @@ pub enum Error { RestError(#[error(source)] mullvad_rpc::rest::Error), #[error(display = "Account already has maximum number of keys")] TooManyKeys, - #[error(display = "Failed to create rotation timer")] - RotationScheduleError(#[error(source)] tokio_timer::TimerError), } pub type Result<T> = std::result::Result<T, Error>; @@ -291,7 +288,7 @@ impl KeyManager { } async fn key_rotation_timer(key: PublicKey, rotation_interval_secs: u64) { - let mut interval = tokio02::time::interval(KEY_CHECK_INTERVAL); + let mut interval = tokio::time::interval(KEY_CHECK_INTERVAL); loop { interval.tick().await; if (Utc::now().signed_duration_since(key.created)).num_seconds() as u64 @@ -342,7 +339,7 @@ impl KeyManager { rotation_interval_secs: u64, account_token: AccountToken, ) { - let mut interval = tokio02::time::interval_at( + let mut interval = tokio::time::interval_at( (Instant::now() + AUTOMATIC_ROTATION_RETRY_DELAY).into(), AUTOMATIC_ROTATION_RETRY_DELAY, ); diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml index f135e52b26..5222c5d26d 100644 --- a/talpid-core/Cargo.toml +++ b/talpid-core/Cargo.toml @@ -24,12 +24,10 @@ parking_lot = "0.9" regex = "1.1.0" shell-escape = "0.1" talpid-types = { path = "../talpid-types" } -tokio-core = "0.1" -tokio-executor = "0.1" uuid = { version = "0.7", features = ["v4"] } zeroize = "1" chrono = "0.4" -tokio02 = { package = "tokio", version = "0.2", features = [ "io-util", "process", "rt-core", "rt-threaded", "stream"] } +tokio = { version = "0.2", features = [ "io-util", "process", "rt-core", "rt-threaded", "stream"] } rand = "0.7" @@ -42,7 +40,6 @@ prost = "0.6" [target.'cfg(unix)'.dependencies] nix = "0.17" -tokio-io = "0.1" [target.'cfg(target_os = "android")'.dependencies] diff --git a/talpid-core/src/future_retry.rs b/talpid-core/src/future_retry.rs index bf992117bd..cc1fb1ed20 100644 --- a/talpid-core/src/future_retry.rs +++ b/talpid-core/src/future_retry.rs @@ -32,10 +32,10 @@ pub async fn retry_future_with_backoff< async fn sleep(mut delay: Duration) { while delay > MAX_SINGLE_DELAY { delay -= MAX_SINGLE_DELAY; - tokio02::time::delay_for(MAX_SINGLE_DELAY).await; + tokio::time::delay_for(MAX_SINGLE_DELAY).await; } - tokio02::time::delay_for(delay).await; + tokio::time::delay_for(delay).await; } /// Provides an exponential back-off timer to delay the next retry of a failed operation. diff --git a/talpid-core/src/offline/linux.rs b/talpid-core/src/offline/linux.rs index 435bc2193d..63c058de76 100644 --- a/talpid-core/src/offline/linux.rs +++ b/talpid-core/src/offline/linux.rs @@ -46,7 +46,7 @@ pub enum Error { pub struct MonitorHandle { handle: rtnetlink::Handle, - runtime: tokio02::runtime::Runtime, + runtime: tokio::runtime::Runtime, } impl MonitorHandle { @@ -65,7 +65,7 @@ impl MonitorHandle { } pub fn spawn_monitor(sender: Weak<UnboundedSender<TunnelCommand>>) -> Result<MonitorHandle> { - let mut runtime = tokio02::runtime::Builder::new() + let mut runtime = tokio::runtime::Builder::new() .threaded_scheduler() .core_threads(1) .enable_all() diff --git a/talpid-core/src/routing/linux.rs b/talpid-core/src/routing/linux.rs index ba5ffb66a6..566e1c027b 100644 --- a/talpid-core/src/routing/linux.rs +++ b/talpid-core/src/routing/linux.rs @@ -124,7 +124,7 @@ impl RouteManagerImpl { .bind(&addr) .map_err(Error::BindError)?; - tokio02::spawn(connection); + tokio::spawn(connection); let iface_map = Self::initialize_link_map(&handle).await?; let split_table_id = Self::initialize_exclusions_table().await?; @@ -903,7 +903,7 @@ mod test { /// Tests if dropping inside a tokio runtime panics #[test] fn test_drop_in_executor() { - let mut runtime = tokio02::runtime::Runtime::new().expect("Failed to initialize runtime"); + let mut runtime = tokio::runtime::Runtime::new().expect("Failed to initialize runtime"); runtime.block_on(async { let manager = RouteManagerImpl::new(HashSet::new()) .await @@ -915,7 +915,7 @@ mod test { /// Tests if dropping outside a runtime panics #[test] fn test_drop() { - let mut runtime = tokio02::runtime::Runtime::new().expect("Failed to initialize runtime"); + let mut runtime = tokio::runtime::Runtime::new().expect("Failed to initialize runtime"); let manager = runtime.block_on(async { RouteManagerImpl::new(HashSet::new()) .await diff --git a/talpid-core/src/routing/macos.rs b/talpid-core/src/routing/macos.rs index 6a4512d144..6304dcc24f 100644 --- a/talpid-core/src/routing/macos.rs +++ b/talpid-core/src/routing/macos.rs @@ -12,7 +12,7 @@ use std::{ net::IpAddr, process::{ExitStatus, Stdio}, }; -use tokio02::{io::AsyncBufReadExt, process::Command}; +use tokio::{io::AsyncBufReadExt, process::Command}; pub type Result<T> = std::result::Result<T, Error>; @@ -310,7 +310,7 @@ async fn listen_for_default_route_changes() -> Result<impl Stream<Item = std::io let mut process = cmd.spawn().map_err(Error::FailedToMonitorRoutes)?; - let reader = tokio02::io::BufReader::new(process.stdout.take().unwrap()); + let reader = tokio::io::BufReader::new(process.stdout.take().unwrap()); let lines = reader.lines(); // route -n monitor will produce netlink messages in the following format diff --git a/talpid-core/src/routing/unix.rs b/talpid-core/src/routing/unix.rs index 38896a4392..b84e5850b7 100644 --- a/talpid-core/src/routing/unix.rs +++ b/talpid-core/src/routing/unix.rs @@ -69,7 +69,7 @@ pub enum RouteManagerCommand { /// the route will be adjusted dynamically when the default route changes. pub struct RouteManager { manage_tx: Option<UnboundedSender<RouteManagerCommand>>, - runtime: tokio02::runtime::Runtime, + runtime: tokio::runtime::Runtime, } impl RouteManager { @@ -78,7 +78,7 @@ impl RouteManager { /// routes. pub fn new(required_routes: HashSet<RequiredRoute>) -> Result<Self, Error> { let (manage_tx, manage_rx) = mpsc::unbounded(); - let mut runtime = tokio02::runtime::Runtime::new().expect("Failed to spawn runtime"); + let mut runtime = tokio::runtime::Runtime::new().expect("Failed to spawn runtime"); let manager = runtime.block_on(imp::RouteManagerImpl::new(required_routes))?; runtime.handle().spawn(manager.run(manage_rx)); diff --git a/talpid-core/src/tunnel/openvpn.rs b/talpid-core/src/tunnel/openvpn.rs index 5dc14ba8d9..da3b507bb1 100644 --- a/talpid-core/src/tunnel/openvpn.rs +++ b/talpid-core/src/tunnel/openvpn.rs @@ -21,7 +21,7 @@ use std::{ time::Duration, }; use talpid_types::net::openvpn; -use tokio02::task; +use tokio::task; #[cfg(target_os = "linux")] use which; @@ -132,7 +132,7 @@ pub struct OpenVpnMonitor<C: OpenVpnBuilder = OpenVpnCommand> { /// Keep the 'TempFile' for the proxy user-pass file in the struct, so it's removed on drop. _proxy_auth_file: Option<mktemp::TempFile>, - runtime: tokio02::runtime::Runtime, + runtime: tokio::runtime::Runtime, event_server_abort_tx: triggered::Trigger, server_join_handle: Option<task::JoinHandle<std::result::Result<(), event_server::Error>>>, } @@ -239,7 +239,7 @@ impl<C: OpenVpnBuilder + 'static> OpenVpnMonitor<C> { let (event_server_abort_tx, event_server_abort_rx) = triggered::trigger(); - let mut runtime = tokio02::runtime::Builder::new() + let mut runtime = tokio::runtime::Builder::new() .threaded_scheduler() .core_threads(1) .enable_all() @@ -619,7 +619,7 @@ mod event_server { pin::Pin, task::{Context, Poll}, }; - use tokio02::io::{AsyncRead, AsyncWrite}; + use tokio::io::{AsyncRead, AsyncWrite}; use tonic::{ self, transport::{server::Connected, Server}, diff --git a/talpid-core/src/tunnel_state_machine/mod.rs b/talpid-core/src/tunnel_state_machine/mod.rs index 6f5debdd52..22c0d823a5 100644 --- a/talpid-core/src/tunnel_state_machine/mod.rs +++ b/talpid-core/src/tunnel_state_machine/mod.rs @@ -27,22 +27,19 @@ use futures::{ channel::{mpsc, oneshot}, StreamExt, }; -use futures01::{sync::mpsc as old_mpsc, Async, Future, Poll, Stream}; +use futures01::{sync::mpsc as old_mpsc, Async, Poll, Stream}; use std::{ collections::HashSet, io, path::{Path, PathBuf}, sync::{mpsc as sync_mpsc, Arc}, - thread, }; #[cfg(target_os = "android")] -use talpid_types::android::AndroidContext; +use talpid_types::{android::AndroidContext, ErrorExt}; use talpid_types::{ net::TunnelParameters, tunnel::{ErrorStateCause, ParameterGenerationError, TunnelStateTransition}, - ErrorExt, }; -use tokio_core::reactor::Core; /// Errors that can happen when setting up or using the state machine. #[derive(err_derive::Error, Debug)] @@ -108,7 +105,7 @@ pub async fn spawn( // Hide internal 0.1 futures from the client let (command_adapter_tx, command_adapter_rx) = old_mpsc::unbounded(); - tokio02::spawn(async move { + tokio::spawn(async move { while let Some(command) = command_rx.next().await { if command_adapter_tx.unbounded_send(command).is_err() { log::error!("Failed to forward daemon command"); @@ -117,8 +114,8 @@ pub async fn spawn( }); let (startup_result_tx, startup_result_rx) = sync_mpsc::channel(); - thread::spawn(move || { - match create_event_loop( + std::thread::spawn(move || { + let state_machine = TunnelStateMachine::new( allow_lan, block_when_disconnected, is_offline, @@ -128,27 +125,32 @@ pub async fn spawn( resource_dir, cache_dir, command_adapter_rx, - state_change_listener, - shutdown_tx, - ) { - Ok((mut reactor, event_loop)) => { - startup_result_tx.send(Ok(())).expect( - "Tunnel state machine won't be started because the owner thread crashed", - ); - - if let Err(e) = reactor.run(event_loop) { - log::error!( - "{}", - e.display_chain_with_msg("Tunnel state machine exited with an error") - ); - } + ); + let state_machine = match state_machine { + Ok(state_machine) => { + startup_result_tx.send(Ok(())).unwrap(); + state_machine } - Err(startup_error) => { - startup_result_tx - .send(Err(startup_error)) - .expect("Failed to send startup error"); + Err(error) => { + startup_result_tx.send(Err(error)).unwrap(); + return; + } + }; + + let mut iter = state_machine.wait(); + while let Some(Ok(change_event)) = iter.next() { + if let Err(error) = state_change_listener + .send(change_event) + .map_err(|_| Error::SendStateChange) + { + log::error!("{}", error); + break; } } + if shutdown_tx.send(()).is_err() { + log::error!("Can't send shutdown completion to daemon"); + } + std::mem::drop(offline_monitor); }); @@ -158,48 +160,6 @@ pub async fn spawn( Ok(command_tx) } -fn create_event_loop( - allow_lan: bool, - block_when_disconnected: bool, - is_offline: bool, - tunnel_parameters_generator: impl TunnelParametersGenerator, - tun_provider: TunProvider, - log_dir: Option<PathBuf>, - resource_dir: PathBuf, - cache_dir: impl AsRef<Path>, - commands: old_mpsc::UnboundedReceiver<TunnelCommand>, - state_change_listener: impl Sender<TunnelStateTransition>, - shutdown_tx: oneshot::Sender<()>, -) -> Result<(Core, impl Future<Item = (), Error = Error>), Error> { - let reactor = Core::new().map_err(Error::ReactorError)?; - let state_machine = TunnelStateMachine::new( - allow_lan, - block_when_disconnected, - is_offline, - tunnel_parameters_generator, - tun_provider, - log_dir, - resource_dir, - cache_dir, - commands, - )?; - - let future = state_machine - .for_each(move |state_change_event| { - state_change_listener - .send(state_change_event) - .map_err(|_| Error::SendStateChange) - }) - .then(move |_| { - if shutdown_tx.send(()).is_err() { - log::error!("Can't send shutdown completion to daemon"); - } - Ok(()) - }); - - Ok((reactor, future)) -} - /// Representation of external commands for the tunnel state machine. pub enum TunnelCommand { /// Enable or disable LAN access in the firewall. |
