diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-05-09 16:27:36 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-05-09 16:27:36 +0200 |
| commit | 0ce25aeb01ffc054033388d97b2974f04335b859 (patch) | |
| tree | 1283c25d0a6f7cd9dc5d2b8b9939e4572a76bf5e | |
| parent | c6dbac4ce8db20d6e93309ee378c7c4ba7bab51d (diff) | |
| parent | 7fe075e231f952f036c708f39425313ffb517a12 (diff) | |
| download | mullvadvpn-0ce25aeb01ffc054033388d97b2974f04335b859.tar.xz mullvadvpn-0ce25aeb01ffc054033388d97b2974f04335b859.zip | |
Merge branch 'cleaner-ipc-with-ws'
| -rw-r--r-- | Cargo.lock | 261 | ||||
| -rw-r--r-- | mullvad_daemon/Cargo.toml | 6 | ||||
| -rw-r--r-- | mullvad_daemon/src/frontend_ipc_router.rs | 2 | ||||
| -rw-r--r-- | mullvad_daemon/src/main.rs | 4 | ||||
| -rw-r--r-- | talpid_ipc/Cargo.toml | 2 | ||||
| -rw-r--r-- | talpid_ipc/src/http_ipc/mod.rs | 82 | ||||
| -rw-r--r-- | talpid_ipc/src/lib.rs | 62 |
7 files changed, 167 insertions, 252 deletions
diff --git a/Cargo.lock b/Cargo.lock index ee987cf14f..71e46c965a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,14 +61,6 @@ dependencies = [ ] [[package]] -name = "base64" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -85,6 +77,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bytes" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bytes" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ @@ -168,18 +165,14 @@ dependencies = [ ] [[package]] -name = "futures" -version = "0.1.13" +name = "fnv" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "futures-cpupool" -version = "0.1.5" +name = "futures" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "gcc" @@ -187,33 +180,23 @@ version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "httparse" -version = "1.2.1" +name = "globset" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "hyper" -version = "0.11.0-a.0" -source = "git+https://github.com/hyperium/hyper#f05a58a1b2288d30a601b0466bc08a38c5a76054" dependencies = [ - "base64 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "httparse" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "idna" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -240,36 +223,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "jsonrpc-core" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc#92693e6d127dbff0c7039ecc3fe707418f861493" +source = "git+https://github.com/paritytech/jsonrpc#05eca1e1dd80f9b3bd8f1738ca5680d078021c27" dependencies = [ "futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "jsonrpc-http-server" +name = "jsonrpc-server-utils" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc#92693e6d127dbff0c7039ecc3fe707418f861493" +source = "git+https://github.com/paritytech/jsonrpc#05eca1e1dd80f9b3bd8f1738ca5680d078021c27" dependencies = [ - "hyper 0.11.0-a.0 (git+https://github.com/hyperium/hyper)", + "globset 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc)", - "jsonrpc-server-utils 7.0.0 (git+https://github.com/paritytech/jsonrpc)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "jsonrpc-server-utils" +name = "jsonrpc-ws-server" version = "7.0.0" -source = "git+https://github.com/paritytech/jsonrpc#92693e6d127dbff0c7039ecc3fe707418f861493" +source = "git+https://github.com/paritytech/jsonrpc#05eca1e1dd80f9b3bd8f1738ca5680d078021c27" dependencies = [ "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc)", + "jsonrpc-server-utils 7.0.0 (git+https://github.com/paritytech/jsonrpc)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ws 0.6.0 (git+https://github.com/tomusdrw/ws-rs)", ] [[package]] @@ -282,11 +265,6 @@ dependencies = [ ] [[package]] -name = "language-tags" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "lazycell" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -330,14 +308,6 @@ dependencies = [ ] [[package]] -name = "mime" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "mio" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -373,9 +343,9 @@ dependencies = [ "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "talpid_ipc 0.1.0", ] @@ -408,14 +378,6 @@ version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "num_cpus" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "openvpn_ffi" version = "0.1.0" dependencies = [ @@ -454,11 +416,6 @@ dependencies = [ ] [[package]] -name = "redox_syscall" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "regex" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -481,26 +438,18 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "rustc_version" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "scoped-tls" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "semver" -version = "0.1.20" +name = "serde" +version = "0.9.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "0.9.13" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -522,6 +471,25 @@ dependencies = [ ] [[package]] +name = "serde_derive" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive_internals" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syn 0.11.10 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "serde_json" version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -533,6 +501,22 @@ dependencies = [ ] [[package]] +name = "serde_json" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sha1" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "shared_child" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -548,11 +532,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "smallvec" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "strsim" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -576,11 +555,6 @@ dependencies = [ ] [[package]] -name = "take" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "talpid_cli" version = "0.0.0" dependencies = [ @@ -610,7 +584,7 @@ dependencies = [ "assert_matches 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc)", - "jsonrpc-http-server 7.0.0 (git+https://github.com/paritytech/jsonrpc)", + "jsonrpc-ws-server 7.0.0 (git+https://github.com/paritytech/jsonrpc)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -646,17 +620,6 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "tokio-core" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -682,44 +645,11 @@ dependencies = [ ] [[package]] -name = "tokio-proto" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-service" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "toml" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "unicase" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "unicode-bidi" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -790,6 +720,21 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "ws" +version = "0.6.0" +source = "git+https://github.com/tomusdrw/ws-rs#7f8e416b7f048880228005457e117128be38bf0f" +dependencies = [ + "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "ws2_32-sys" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -824,10 +769,10 @@ dependencies = [ "checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159" "checksum backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f551bc2ddd53aea015d453ef0b635af89444afa5ed2405dd0b2062ad5d600d80" "checksum backtrace-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d192fd129132fbc97497c1f2ec2c2c5174e376b95f535199ef4fe0a293d33842" -"checksum base64 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9892882c3bd89ed02dec391c128984c772b663a29700c32b5de0b33861cdf2bd" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8" +"checksum bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c129aff112dcc562970abb69e2508b40850dd24c274761bb50fb8a0067ba6c27" "checksum bytes 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3941933da81d8717b427c2ddc2d73567cd15adb6c57514a2726d9ee598a5439a" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" "checksum clap 2.23.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf1114886d7cde2d6448517161d7db8d681a9a1c09f7d210f0b0864e48195f6" @@ -838,19 +783,18 @@ dependencies = [ "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum error-chain 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "318cb3c71ee4cdea69fdc9e15c173b245ed6063e1709029e8fd32525a881120f" "checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" +"checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344" "checksum futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "55f0008e13fc853f79ea8fc86e931486860d4c4c156cdffb59fa5f7fa833660a" -"checksum futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a283c84501e92cade5ea673a2a7ca44f71f209ccdd302a3e0896f50083d2c5ff" "checksum gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)" = "40899336fb50db0c78710f53e87afc54d8c7266fb76262fecc78ca1a7f09deae" +"checksum globset 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90d069fe6beb9be359ef505650b3f73228c5591a3c4b1f32be2f4f44459ffa3a" "checksum httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a6e7a63e511f9edffbab707141fbb8707d1a3098615fb2adbd5769cdfcc9b17d" -"checksum hyper 0.11.0-a.0 (git+https://github.com/hyperium/hyper)" = "<none>" "checksum idna 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6ac85ec3f80c8e4e99d9325521337e14ec7555c458a14e377d189659a427f375" "checksum iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29d062ee61fccdf25be172e70f34c9f6efc597e1fb8f6526e8437b2046ab26be" "checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c" "checksum jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc)" = "<none>" -"checksum jsonrpc-http-server 7.0.0 (git+https://github.com/paritytech/jsonrpc)" = "<none>" "checksum jsonrpc-server-utils 7.0.0 (git+https://github.com/paritytech/jsonrpc)" = "<none>" +"checksum jsonrpc-ws-server 7.0.0 (git+https://github.com/paritytech/jsonrpc)" = "<none>" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce12306c4739d86ee97c23139f3a34ddf0387bbf181bc7929d287025a8c3ef6b" "checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b" "checksum libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "88ee81885f9f04bff991e306fea7c1c60a5f0f9e409e99f6b40e3311a3363135" @@ -858,45 +802,39 @@ dependencies = [ "checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" "checksum metadeps 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829fffe7ea1d747e23f64be972991bc516b2f1ac2ae4a3b33d8bea150c410151" -"checksum mime 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5514f038123342d01ee5f95129e4ef1e0470c93bc29edf058a46f9ee3ba6737e" "checksum mio 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f27d38f824a0d267d55b29b171e9e99269a53812e385fa75c1fe700ae254a6a4" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum net2 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)" = "18b9642ad6222faf5ce46f6966f59b71b9775ad5758c9e09fcf0a6c8061972b4" "checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487" "checksum num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "e1cbfa3781f3fe73dc05321bed52a06d2d491eaa764c52335cf4399f046ece99" -"checksum num_cpus 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a18c392466409c50b87369414a2680c93e739aedeb498eb2bff7d7eb569744e2" "checksum os_pipe 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "998bfbb3042e715190fe2a41abfa047d7e8cb81374d2977d7f100eacd8619cb1" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d" -"checksum redox_syscall 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "29dbdfd4b9df8ab31dec47c6087b7b13cbf4a776f335e4de8efba8288dda075b" "checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01" "checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457" "checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95" -"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" -"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" "checksum serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)" = "231dfd55909400769e437326cfb4af8bec97c3dd56ab3d02df8ef5c7e00f179b" +"checksum serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3b46a59dd63931010fdb1d88538513f3279090d88b5c22ef4fe8440cfffcc6e3" "checksum serde_codegen_internals 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bc888bd283bd2420b16ad0d860e35ad8acb21941180a83a189bb2046f9d00400" "checksum serde_derive 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)" = "d75c72ef4dd193d89eb652b73890fe2489996c9ead8b37980f57a1078f96ed50" +"checksum serde_derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6c06b68790963518008b8ae0152d48be4bbbe77015d2c717f6282eea1824be9a" +"checksum serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "021c338d22c7e30f957a6ab7e388cb6098499dda9fd4ba1661ee074ca7a180d1" "checksum serde_json 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ad8bcf487be7d2e15d3d543f04312de991d631cfe1b43ea0ade69e6a8a5b16a1" +"checksum serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "48b04779552e92037212c3615370f6bd57a40ebba7f20e554ff9f55e41a69a7b" +"checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c" "checksum shared_child 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "099b38928dbe4a0a01fcd8c233183072f14a7d126a34bed05880869be66e14cc" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" -"checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" "checksum syn 0.11.10 (registry+https://github.com/rust-lang/crates.io-index)" = "171b739972d9a1bfb169e8077238b51f9ebeaae4ff6e08072f7ba386a8802da2" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -"checksum take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5" "checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209" "checksum thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4437c97558c70d129e40629a5b385b3fb1ffac301e63941335e4d354081ec14a" "checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7" -"checksum time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade" "checksum tokio-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "99e958104a67877907c1454386d5482fe8e965a55d60be834a15a44328e7dc76" "checksum tokio-io 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "48f55df1341bb92281f229a6030bc2abffde2c7a44c6d6b802b7687dd8be0775" -"checksum tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fbb47ae81353c63c487030659494b295f6cb6576242f907f203473b191b0389" -"checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" "checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" -"checksum unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a5906ca2b98c799f4b1ab4557b76367ebd6ae5ef14930ec841c74aed5f3764" "checksum unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a078ebdd62c0e71a709c3d53d2af693fe09fe93fbff8344aebe289b78f9032" "checksum unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e28fa37426fceeb5cf8f41ee273faa7c82c47dc8fba5853402841e665fcd86ff" "checksum unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18127285758f0e2c6cf325bb3f3d138a12fee27de4f23e146cd6a179f26c2cf3" @@ -909,6 +847,7 @@ dependencies = [ "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum ws 0.6.0 (git+https://github.com/tomusdrw/ws-rs)" = "<none>" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum zmq 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9623581b345b8a85fb72cae9b2cb67116d73ccb141e6c02f689e311962b74f9c" "checksum zmq-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ecf3aafc58984279d9b8f776703ef569d32ae386353192a267cd6e711da70dde" diff --git a/mullvad_daemon/Cargo.toml b/mullvad_daemon/Cargo.toml index 3fca0a15f7..42a00a29f6 100644 --- a/mullvad_daemon/Cargo.toml +++ b/mullvad_daemon/Cargo.toml @@ -6,9 +6,9 @@ description = "The meat of Mullvad, the core if you wish" [dependencies] error-chain = "0.10" -serde = "0.9" -serde_derive = "0.9" -serde_json = "0.9" +serde = "1.0" +serde_derive = "1.0" +serde_json = "1.0" log = "0.3" env_logger = "0.4" jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc" } diff --git a/mullvad_daemon/src/frontend_ipc_router.rs b/mullvad_daemon/src/frontend_ipc_router.rs index aad05cf778..1c1b74950c 100644 --- a/mullvad_daemon/src/frontend_ipc_router.rs +++ b/mullvad_daemon/src/frontend_ipc_router.rs @@ -20,7 +20,7 @@ pub fn build_router() -> jsonrpc_core::IoHandler { } fn add_route<T, U, F>(router: &mut jsonrpc_core::IoHandler, method: &str, handler: F) - where T: serde::Deserialize + 'static, + where for<'de> T: serde::Deserialize<'de>, U: serde::Serialize + 'static, F: Fn(&T) -> Result<U> + Send + Sync + 'static { diff --git a/mullvad_daemon/src/main.rs b/mullvad_daemon/src/main.rs index e4e732d749..ff4b62dcb3 100644 --- a/mullvad_daemon/src/main.rs +++ b/mullvad_daemon/src/main.rs @@ -24,8 +24,8 @@ fn init_logger() -> Result<()> { env_logger::init().chain_err(|| "Failed to bootstrap logging system") } -fn start_ipc() -> Result<talpid_ipc::http_ipc::ServerHandle> { - talpid_ipc::http_ipc::start(frontend_ipc_router::build_router) +fn start_ipc() -> Result<talpid_ipc::IpcServer> { + talpid_ipc::IpcServer::start(frontend_ipc_router::build_router().into(), 0) .chain_err(|| "Failed to start IPC server") } diff --git a/talpid_ipc/Cargo.toml b/talpid_ipc/Cargo.toml index 5650689103..3b3418b148 100644 --- a/talpid_ipc/Cargo.toml +++ b/talpid_ipc/Cargo.toml @@ -10,7 +10,7 @@ serde = "0.9" serde_json = "0.9" log = "0.3" jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc" } -jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc" } +jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc" } [target.'cfg(not(windows))'.dependencies] zmq = "0.8" diff --git a/talpid_ipc/src/http_ipc/mod.rs b/talpid_ipc/src/http_ipc/mod.rs deleted file mode 100644 index 16195ee69f..0000000000 --- a/talpid_ipc/src/http_ipc/mod.rs +++ /dev/null @@ -1,82 +0,0 @@ -extern crate jsonrpc_core; -extern crate jsonrpc_http_server; - -use self::jsonrpc_http_server::{Server, ServerBuilder}; -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; -use std::result::Result as StdResult; - -mod connection_info; - -error_chain! { - errors { - FailedToWriteConnectionInfo { - description("Unable to write IPC connection info") - } - UnableToStartServer { - description("Failed to start the server") - } - } -} - - -pub struct ServerHandle { - address: String, - server: Server, -} - -impl ServerHandle { - pub fn address(&self) -> &str { - &self.address - } - - pub fn stop(self) { - self.server.close(); - } -} - -pub fn start(build_router: fn() -> jsonrpc_core::IoHandler) -> Result<ServerHandle> { - let server = start_server(build_router).chain_err(|| ErrorKind::UnableToStartServer)?; - let write_result = connection_info::write(server.address()).chain_err( - || { - ErrorKind::FailedToWriteConnectionInfo - }, - ); - if let Err(e) = write_result { - error!("Could not write the connection info, killing the IPC server"); - server.stop(); - Err(e) - } else { - info!("Started Ipc server on: {}", server.address()); - Ok(server) - } -} - -fn start_server(build_router: fn() -> jsonrpc_core::IoHandler) - -> StdResult<ServerHandle, jsonrpc_http_server::Error> { - let mut last_error = None; - for port in 5000..5010 { - match start_server_on_port(port, build_router()) { - Ok(server) => return Ok(server), - Err(e) => last_error = Some(e), - } - } - bail!(last_error.unwrap()); -} - -fn start_server_on_port(port: u16, - router: jsonrpc_core::IoHandler) - -> StdResult<ServerHandle, jsonrpc_http_server::Error> { - let ip = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); - let listen_addr = SocketAddr::new(ip, port); - ServerBuilder::new(router) - .allow_only_bind_host() - .start_http(&listen_addr) - .map( - |server| { - ServerHandle { - address: format!("http://{}", listen_addr), - server: server, - } - }, - ) -} diff --git a/talpid_ipc/src/lib.rs b/talpid_ipc/src/lib.rs index 1fcfe47962..d1f1b816bd 100644 --- a/talpid_ipc/src/lib.rs +++ b/talpid_ipc/src/lib.rs @@ -5,6 +5,15 @@ extern crate log; extern crate serde; +extern crate jsonrpc_core; +extern crate jsonrpc_ws_server; + +use jsonrpc_core::{MetaIoHandler, Metadata}; +use jsonrpc_ws_server::{MetaExtractor, NoopExtractor, Server, ServerBuilder}; + +use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + + #[cfg(windows)] #[path = "nop_ipc.rs"] mod ipc_impl; @@ -15,8 +24,6 @@ mod ipc_impl; pub use self::ipc_impl::*; -pub mod http_ipc; - /// An Id created by the Ipc server that the client can use to connect to it pub type IpcServerId = String; @@ -35,5 +42,56 @@ error_chain!{ SendError { description("Unable to send message") } + IpcServerError { + description("Error in IPC server") + } + } +} + + +pub struct IpcServer { + address: String, + server: Server, +} + +impl IpcServer { + pub fn start<M: Metadata>(handler: MetaIoHandler<M>, port_offset: u8) -> Result<Self> { + Self::start_with_metadata(handler, NoopExtractor, port_offset) + } + + pub fn start_with_metadata<M, E>(handler: MetaIoHandler<M>, + meta_extractor: E, + port_offset: u8) + -> Result<Self> + where M: Metadata, + E: MetaExtractor<M> + { + let port = 5000 + port_offset as u16; + let ip = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); + let listen_addr = SocketAddr::new(ip, port); + ServerBuilder::new(handler) + .session_meta_extractor(meta_extractor) + .start(&listen_addr) + .map( + |server| { + IpcServer { + address: format!("ws://{}", listen_addr), + server: server, + } + }, + ) + .chain_err(|| ErrorKind::IpcServerError) + } + + pub fn address(&self) -> &str { + &self.address + } + + pub fn stop(self) { + self.server.close(); + } + + pub fn wait(self) -> Result<()> { + self.server.wait().chain_err(|| ErrorKind::IpcServerError) } } |
