From a980d151fc49ec04005652006aeb971fc2a1aa82 Mon Sep 17 00:00:00 2001 From: _ <> Date: Sat, 6 Mar 2021 21:15:41 +0000 Subject: [PATCH] :arrow_up: deps: upgrade everything to Tokio 1.2.0 And pretend I didn't completely goober the Docker build somehow --- Cargo.lock | 575 ++++++++---------- Cargo.toml | 10 +- Dockerfile | 3 - crates/debug_proxy/Cargo.toml | 8 +- crates/debug_proxy/src/lib.rs | 11 +- crates/ptth_core/Cargo.toml | 14 +- crates/ptth_core/src/graceful_shutdown.rs | 4 +- crates/ptth_core/src/http_serde.rs | 2 +- crates/ptth_file_server_bin/Cargo.toml | 19 +- crates/ptth_file_server_bin/src/main.rs | 5 +- crates/ptth_forwarding/Cargo.toml | 26 +- crates/ptth_forwarding/src/main.rs | 9 +- crates/ptth_forwarding_relay/Cargo.toml | 16 +- crates/ptth_forwarding_relay/src/main.rs | 9 +- crates/ptth_kv/Cargo.toml | 6 +- crates/ptth_kv/src/main.rs | 2 +- crates/ptth_relay/Cargo.toml | 18 +- crates/ptth_relay/src/config.rs | 10 +- crates/ptth_relay/src/lib.rs | 12 +- crates/ptth_relay/src/server_endpoint.rs | 12 +- crates/ptth_server/Cargo.toml | 23 +- crates/ptth_server/src/bin/ptth_server.rs | 2 +- crates/ptth_server/src/file_server/metrics.rs | 2 - crates/ptth_server/src/file_server/mod.rs | 6 +- crates/ptth_server/src/file_server/tests.rs | 2 +- crates/ptth_server/src/lib.rs | 19 +- src/main.rs | 5 +- src/tests.rs | 12 +- tools/ptth_tail/Cargo.toml | 11 +- tools/ptth_tail/src/main.rs | 4 +- 30 files changed, 392 insertions(+), 465 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b7b1d9..7ad9b46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,7 +28,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -37,20 +37,20 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] name = "anyhow" -version = "1.0.35" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0df63cb2955042487fad3aefd2c6e3ae7389ac5dc1beb28921de0b69f779d4" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" [[package]] name = "arc-swap" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec5a4539a733493f412c4d0bb962748ea1f90f3dfdba9ff3ee18acbefc3b33f0" +checksum = "d4d7d63395147b81a9e570bcc6243aaf71c017bd666d4909cfef0085bdda8d73" [[package]] name = "arrayref" @@ -117,7 +117,7 @@ dependencies = [ "polling", "vec-arena", "waker-fn", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -154,7 +154,7 @@ dependencies = [ "futures-lite", "once_cell", "signal-hook", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -188,7 +188,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -203,12 +203,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - [[package]] name = "base64" version = "0.13.0" @@ -285,15 +279,15 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "bytes" -version = "0.5.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" [[package]] name = "cache-padded" @@ -332,7 +326,7 @@ dependencies = [ "serde", "time", "wasm-bindgen", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -368,16 +362,6 @@ dependencies = [ "cache-padded", ] -[[package]] -name = "console_error_panic_hook" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" -dependencies = [ - "cfg-if 0.1.10", - "wasm-bindgen", -] - [[package]] name = "const-random" version = "0.1.13" @@ -440,12 +424,12 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.1.7" +version = "3.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57a92e9749e10f25a171adcebfafe72991d45e7ec2dcb853e8f83d9dafaeb08" +checksum = "c15b8ec3b5755a188c141c1f6a98e76de31b936209bf066b647979e2a84764a9" dependencies = [ - "nix 0.18.0", - "winapi 0.3.9", + "nix 0.20.0", + "winapi", ] [[package]] @@ -484,10 +468,12 @@ name = "debug_proxy" version = "0.1.0" dependencies = [ "anyhow", + "futures-util", "http", "hyper", "reqwest", "tokio", + "tokio-stream", "tracing", "tracing-subscriber", "ulid", @@ -584,22 +570,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - [[package]] name = "futures" version = "0.3.8" @@ -659,7 +629,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.0", + "pin-project-lite", "waker-fn", ] @@ -709,7 +679,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project 1.0.2", + "pin-project", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -726,7 +696,7 @@ dependencies = [ "libc", "log", "rustc_version", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -787,9 +757,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "h2" -version = "0.2.7" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" +checksum = "d832b01df74254fe364568d6ddc294443f61cbec82816b60904303af87efae78" dependencies = [ "bytes", "fnv", @@ -802,14 +772,13 @@ dependencies = [ "tokio", "tokio-util", "tracing", - "tracing-futures", ] [[package]] name = "handlebars" -version = "3.5.1" +version = "3.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2764f9796c0ddca4b82c07f25dd2cb3db30b9a8f47940e78e1c883d9e95c3db9" +checksum = "cdb0867bbc5a3da37a753e78021d5fcf8a4db00e18dd2dd90fd36e24190e162d" dependencies = [ "log", "pest", @@ -861,7 +830,7 @@ dependencies = [ "nix 0.19.1", "pin-utils", "uom", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -880,7 +849,7 @@ dependencies = [ "mach", "ntapi", "smol", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -898,7 +867,7 @@ dependencies = [ "mach", "ntapi", "platforms", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -938,7 +907,7 @@ dependencies = [ "ntapi", "ordered-float", "smol", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -964,9 +933,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" dependencies = [ "bytes", "fnv", @@ -975,9 +944,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" dependencies = [ "bytes", "http", @@ -997,9 +966,9 @@ checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" [[package]] name = "hyper" -version = "0.13.9" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ad767baac13b44d4529fcf58ba2cd0995e36e7b435bc5b039de6f47e880dbf" +checksum = "e8e946c2b1349055e0b72ae281b238baf1a3ea7307c7e9f9d64673bdd9c26ac7" dependencies = [ "bytes", "futures-channel", @@ -1011,7 +980,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project 1.0.2", + "pin-project", "socket2", "tokio", "tower-service", @@ -1021,15 +990,15 @@ dependencies = [ [[package]] name = "hyper-tls" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", "hyper", "native-tls", "tokio", - "tokio-tls", + "tokio-native-tls", ] [[package]] @@ -1062,15 +1031,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - [[package]] name = "ipnet" version = "2.3.0" @@ -1101,16 +1061,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -1119,9 +1069,18 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.81" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" +checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" + +[[package]] +name = "lock_api" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +dependencies = [ + "scopeguard", +] [[package]] name = "log" @@ -1193,68 +1152,17 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "mime_guess" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "mio" -version = "0.6.23" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +checksum = "a5dede4e2065b3842b8b0af444119f3aa331cc7cc2dd20388bfb0f5d5a38823a" dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", "libc", "log", - "miow 0.2.2", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-named-pipes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" -dependencies = [ - "log", - "mio", - "miow 0.3.6", - "winapi 0.3.9", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", + "miow", + "ntapi", + "winapi", ] [[package]] @@ -1264,7 +1172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ "socket2", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1292,30 +1200,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8123a81538e457d44b933a02faf885d3fe8408806b23fa700e8f01c6c3a98998" dependencies = [ "libc", - "winapi 0.3.9", -] - -[[package]] -name = "net2" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "nix" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" -dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", + "winapi", ] [[package]] @@ -1330,13 +1215,25 @@ dependencies = [ "libc", ] +[[package]] +name = "nix" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a" +dependencies = [ + "bitflags", + "cc", + "cfg-if 1.0.0", + "libc", +] + [[package]] name = "ntapi" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1439,6 +1336,31 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall 0.2.5", + "smallvec", + "winapi", +] + [[package]] name = "percent-encoding" version = "2.1.0" @@ -1488,33 +1410,13 @@ dependencies = [ "sha-1", ] -[[package]] -name = "pin-project" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" -dependencies = [ - "pin-project-internal 0.4.27", -] - [[package]] name = "pin-project" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" dependencies = [ - "pin-project-internal 1.0.2", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "pin-project-internal", ] [[package]] @@ -1528,12 +1430,6 @@ dependencies = [ "syn", ] -[[package]] -name = "pin-project-lite" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" - [[package]] name = "pin-project-lite" version = "0.2.0" @@ -1568,7 +1464,7 @@ dependencies = [ "libc", "log", "wepoll-sys", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1627,7 +1523,7 @@ name = "ptth" version = "1.1.0" dependencies = [ "anyhow", - "base64 0.13.0", + "base64", "blake3", "chrono", "debug_proxy", @@ -1667,6 +1563,7 @@ dependencies = [ "serde", "structopt", "tokio", + "tokio-stream", "tracing", "tracing-subscriber", "uom", @@ -1677,16 +1574,18 @@ name = "ptth_forwarding" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.12.3", + "base64", "clap", "futures", + "futures-util", "reqwest", - "rmp-serde", + "rmp-serde 0.15.4", "serde", "serde_json", "structopt", "thiserror", "tokio", + "tokio-stream", "tracing", "tracing-futures", "tracing-subscriber", @@ -1698,9 +1597,11 @@ version = "0.1.0" dependencies = [ "anyhow", "futures", + "futures-util", "hyper", "thiserror", "tokio", + "tokio-stream", "tracing", "tracing-futures", "tracing-subscriber", @@ -1712,7 +1613,7 @@ name = "ptth_kv" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.0", + "base64", "hyper", "thiserror", "tokio", @@ -1722,23 +1623,25 @@ dependencies = [ name = "ptth_relay" version = "1.1.0" dependencies = [ - "base64 0.12.3", + "base64", "blake3", "chrono", "clap", "dashmap", "futures", + "futures-util", "handlebars", "http", "hyper", "itertools", "ptth_core", "rand 0.6.5", - "rmp-serde", + "rmp-serde 0.14.4", "serde", "serde_json", "thiserror", "tokio", + "tokio-stream", "toml", "tracing", "tracing-futures", @@ -1754,7 +1657,7 @@ dependencies = [ "always_equal", "anyhow", "arc-swap", - "base64 0.12.3", + "base64", "blake3", "chrono", "futures", @@ -1766,15 +1669,16 @@ dependencies = [ "percent-encoding", "ptth_core", "pulldown-cmark", - "rand 0.6.5", + "rand 0.8.3", "regex", "reqwest", - "rmp-serde", + "rmp-serde 0.14.4", "serde", "serde_json", "structopt", "thiserror", "tokio", + "tokio-stream", "toml", "tracing", "tracing-futures", @@ -1788,6 +1692,7 @@ name = "ptth_tail" version = "0.1.0" dependencies = [ "anyhow", + "futures-util", "reqwest", "tokio", "tracing", @@ -1837,7 +1742,7 @@ dependencies = [ "rand_os", "rand_pcg", "rand_xorshift", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1853,6 +1758,18 @@ dependencies = [ "rand_hc 0.2.0", ] +[[package]] +name = "rand" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -1873,6 +1790,16 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.2", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1897,6 +1824,15 @@ dependencies = [ "getrandom 0.1.15", ] +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom 0.2.0", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -1915,6 +1851,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.2", +] + [[package]] name = "rand_isaac" version = "0.1.1" @@ -1932,7 +1877,7 @@ checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" dependencies = [ "libc", "rand_core 0.4.2", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1947,7 +1892,7 @@ dependencies = [ "rand_core 0.4.2", "rdrand", "wasm-bindgen", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1984,6 +1929,15 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_syscall" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +dependencies = [ + "bitflags", +] + [[package]] name = "regex" version = "1.4.2" @@ -2018,16 +1972,16 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] name = "reqwest" -version = "0.10.9" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb15d6255c792356a0f578d8a645c677904dc02e862bebe2ecc18e0c01b9a0ce" +checksum = "0460542b551950620a3648c6aa23318ac6b3cd779114bd873209e6e8b5eb1c34" dependencies = [ - "base64 0.13.0", + "base64", "bytes", "encoding_rs", "futures-core", @@ -2041,18 +1995,16 @@ dependencies = [ "lazy_static", "log", "mime", - "mime_guess", "native-tls", "percent-encoding", - "pin-project-lite 0.2.0", + "pin-project-lite", "serde", "serde_urlencoded", "tokio", - "tokio-tls", + "tokio-native-tls", "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-bindgen-test", "web-sys", "winreg", ] @@ -2078,6 +2030,17 @@ dependencies = [ "serde", ] +[[package]] +name = "rmp-serde" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839395ef53057db96b84c9238ab29e1a13f2e5c8ec9f66bef853ab4197303924" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + [[package]] name = "rustc_version" version = "0.2.3" @@ -2100,7 +2063,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ "lazy_static", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2109,6 +2072,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "security-framework" version = "2.0.0" @@ -2149,18 +2118,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.118" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.118" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote", @@ -2169,9 +2138,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.60" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -2239,9 +2208,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "1.5.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "smol" @@ -2269,8 +2238,8 @@ checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall", - "winapi 0.3.9", + "redox_syscall 0.1.57", + "winapi", ] [[package]] @@ -2311,9 +2280,9 @@ checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" [[package]] name = "syn" -version = "1.0.54" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" +checksum = "ed22b90a0e734a23a7610f4283ac9e5acfb96cbb30dfefa540d66f866f1c09c5" dependencies = [ "proc-macro2", "quote", @@ -2329,9 +2298,9 @@ dependencies = [ "cfg-if 0.1.10", "libc", "rand 0.7.3", - "redox_syscall", + "redox_syscall 0.1.57", "remove_dir_all", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2345,18 +2314,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" +checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" +checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" dependencies = [ "proc-macro2", "quote", @@ -2380,7 +2349,7 @@ checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2409,33 +2378,29 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "0.2.24" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48" +checksum = "e8190d04c665ea9e6b6a0dc45523ade572c088d2e6566244c1122671dbf4ae3a" dependencies = [ + "autocfg 1.0.1", "bytes", - "fnv", - "futures-core", - "iovec", - "lazy_static", "libc", "memchr", "mio", - "mio-named-pipes", - "mio-uds", "num_cpus", - "pin-project-lite 0.1.11", + "once_cell", + "parking_lot", + "pin-project-lite", "signal-hook-registry", - "slab", "tokio-macros", - "winapi 0.3.9", + "winapi", ] [[package]] name = "tokio-macros" -version = "0.2.6" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" +checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57" dependencies = [ "proc-macro2", "quote", @@ -2443,26 +2408,37 @@ dependencies = [ ] [[package]] -name = "tokio-tls" -version = "0.3.1" +name = "tokio-native-tls" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" dependencies = [ "native-tls", "tokio", ] [[package]] -name = "tokio-util" -version = "0.3.1" +name = "tokio-stream" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +checksum = "1981ad97df782ab506a1f43bf82c967326960d278acf3bf8279809648c3ff3ea" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebb7cb2f00c5ae8df755b252306272cd1790d39728363936e01827e11f0b017b" dependencies = [ "bytes", "futures-core", "futures-sink", "log", - "pin-project-lite 0.1.11", + "pin-project-lite", "tokio", ] @@ -2483,22 +2459,21 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" [[package]] name = "tracing" -version = "0.1.22" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if 1.0.0", - "log", - "pin-project-lite 0.2.0", + "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07" dependencies = [ "proc-macro2", "quote", @@ -2516,19 +2491,19 @@ dependencies = [ [[package]] name = "tracing-futures" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" dependencies = [ - "pin-project 0.4.27", + "pin-project", "tracing", ] [[package]] name = "tracing-log" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" dependencies = [ "lazy_static", "log", @@ -2547,9 +2522,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401" +checksum = "8ab8966ac3ca27126141f7999361cc97dd6fb4b71da04c02044fa9045d98bb96" dependencies = [ "ansi_term 0.12.1", "chrono", @@ -2784,30 +2759,6 @@ version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" -[[package]] -name = "wasm-bindgen-test" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0355fa0c1f9b792a09b6dcb6a8be24d51e71e6d74972f9eb4a44c4c004d24a25" -dependencies = [ - "console_error_panic_hook", - "js-sys", - "scoped-tls", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test-macro", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27e07b46b98024c2ba2f9e83a10c2ef0515f057f2da299c1762a2017de80438b" -dependencies = [ - "proc-macro2", - "quote", -] - [[package]] name = "web-sys" version = "0.3.46" @@ -2827,12 +2778,6 @@ dependencies = [ "cc", ] -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.9" @@ -2843,12 +2788,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -2867,15 +2806,5 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", + "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index 520a9f7..bc02691 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,16 +23,16 @@ exclude = [ [dependencies] -anyhow = "1.0.34" +anyhow = "1.0.38" blake3 = "0.3.7" -tokio = { version = "0.2.22", features = ["full"] } -tracing-subscriber = "0.2.15" +reqwest = { version = "0.11.1", features = ["stream"] } +tokio = { version = "1.2.0", features = ["full"] } +tracing-subscriber = "0.2.16" +tracing = "0.1.25" debug_proxy = { path = "crates/debug_proxy" } ptth_relay = { path = "crates/ptth_relay" } ptth_server = { path = "crates/ptth_server" } -reqwest = { version = "0.10.8", features = ["stream"] } -tracing = "0.1.21" [dev-dependencies] diff --git a/Dockerfile b/Dockerfile index dfbe0d4..70b6d7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,9 +27,6 @@ COPY ./Cargo.toml ./ COPY ./crates/always_equal/Cargo.toml ./crates/always_equal/ COPY ./crates/ptth_core/Cargo.toml ./crates/ptth_core/ COPY ./crates/ptth_relay/Cargo.toml ./crates/ptth_relay/ -# COPY ./crates/ptth_server/Cargo.toml ./crates/ptth_server/ -# COPY ./crates/ptth_file_server_bin/Cargo.toml ./crates/ptth_file_server_bin/ -# COPY ./tools/ptth_tail/Cargo.toml ./tools/ptth_tail/ # this build step will cache your dependencies RUN cargo build --release -p ptth_relay diff --git a/crates/debug_proxy/Cargo.toml b/crates/debug_proxy/Cargo.toml index 09d4d6a..67914c7 100644 --- a/crates/debug_proxy/Cargo.toml +++ b/crates/debug_proxy/Cargo.toml @@ -9,10 +9,12 @@ license = "AGPL-3.0" [dependencies] anyhow = "1.0.34" +futures-util = "0.3.8" http = "0.2.1" -hyper = "0.13.8" -reqwest = { version = "0.10.8", features = ["stream"] } -tokio = { version = "0.2.22", features = ["full"] } +hyper = { version = "0.14.4", features = ["server", "stream"] } +reqwest = "0.11.1" +tokio = "1.2.0" +tokio-stream = "0.1.3" tracing = "0.1.21" tracing-subscriber = "0.2.15" ulid = "0.4.1" diff --git a/crates/debug_proxy/src/lib.rs b/crates/debug_proxy/src/lib.rs index ca33300..d7ed633 100644 --- a/crates/debug_proxy/src/lib.rs +++ b/crates/debug_proxy/src/lib.rs @@ -3,6 +3,7 @@ use std::{ sync::Arc, }; +use futures_util::StreamExt; use hyper::{ Body, Request, @@ -16,12 +17,12 @@ use hyper::{ use reqwest::Client; use tokio::{ spawn, - stream::StreamExt, sync::{ mpsc, oneshot, }, }; +use tokio_stream::wrappers::ReceiverStream; use ulid::Ulid; struct State { @@ -51,7 +52,7 @@ async fn handle_all (req: Request , state: Arc ) upstream_req = upstream_req.header (k, v); } - let (mut tx, rx) = mpsc::channel (1); + let (tx, rx) = mpsc::channel (1); spawn ({ let req_id = req_id.clone (); async move { @@ -78,7 +79,7 @@ async fn handle_all (req: Request , state: Arc ) } }); - let upstream_resp = upstream_req.body (reqwest::Body::wrap_stream (rx)).send ().await?; + let upstream_resp = upstream_req.body (reqwest::Body::wrap_stream (ReceiverStream::new (rx))).send ().await?; let mut resp = Response::builder () .status (upstream_resp.status ()); @@ -87,7 +88,7 @@ async fn handle_all (req: Request , state: Arc ) resp = resp.header (k, v); } - let (mut tx, rx) = mpsc::channel (1); + let (tx, rx) = mpsc::channel (1); spawn (async move { let mut body = upstream_resp.bytes_stream (); let mut bytes_transferred = 0; @@ -112,7 +113,7 @@ async fn handle_all (req: Request , state: Arc ) Ok::<_, anyhow::Error> (()) }); - Ok (resp.body (Body::wrap_stream (rx))?) + Ok (resp.body (Body::wrap_stream (ReceiverStream::new (rx)))?) } pub async fn run_proxy ( diff --git a/crates/ptth_core/Cargo.toml b/crates/ptth_core/Cargo.toml index 872b82a..3e09275 100644 --- a/crates/ptth_core/Cargo.toml +++ b/crates/ptth_core/Cargo.toml @@ -11,11 +11,11 @@ repository = "https://github.com/ReactorScram/ptth" [dependencies] -ctrlc = { version = "3.1.7", features = [ "termination" ] } +ctrlc = { version = "3.1.8", features = [ "termination" ] } futures = "0.3.7" -hyper = "0.13.8" -serde = {version = "1.0.117", features = ["derive"]} -thiserror = "1.0.22" -tokio = { version = "0.2.22", features = ["full"] } -tracing = "0.1.21" -tracing-futures = "0.2.4" +hyper = "0.14.4" +serde = {version = "1.0.124", features = ["derive"]} +thiserror = "1.0.24" +tokio = { version = "1.2.0", features = ["full"] } +tracing = "0.1.25" +tracing-futures = "0.2.5" diff --git a/crates/ptth_core/src/graceful_shutdown.rs b/crates/ptth_core/src/graceful_shutdown.rs index 38e1c36..8b6dac1 100644 --- a/crates/ptth_core/src/graceful_shutdown.rs +++ b/crates/ptth_core/src/graceful_shutdown.rs @@ -9,7 +9,7 @@ use std::{ use futures::prelude::*; use tokio::{ sync::oneshot, - time::delay_for, + time::sleep, }; use crate::prelude::*; @@ -82,7 +82,7 @@ impl ForcedShutdown { self.tx.send (()).expect ("Error forwarding graceful shutdown signal"); let timeout = 5; debug! ("Starting graceful shutdown. Forcing shutdown in {} seconds", timeout); - delay_for (Duration::from_secs (timeout)).await; + sleep (Duration::from_secs (timeout)).await; error! ("Forcing shutdown"); }; diff --git a/crates/ptth_core/src/http_serde.rs b/crates/ptth_core/src/http_serde.rs index bcbe3ba..40fd27c 100644 --- a/crates/ptth_core/src/http_serde.rs +++ b/crates/ptth_core/src/http_serde.rs @@ -175,7 +175,7 @@ impl Response { self.content_length = b.len ().try_into ().ok (); self.header ("content-length".to_string (), b.len ().to_string ().into_bytes ()); - let (mut tx, rx) = tokio::sync::mpsc::channel (1); + let (tx, rx) = tokio::sync::mpsc::channel (1); tokio::spawn (async move { tx.send (Ok (b)).await.ok (); }); diff --git a/crates/ptth_file_server_bin/Cargo.toml b/crates/ptth_file_server_bin/Cargo.toml index 3565543..6fe3d86 100644 --- a/crates/ptth_file_server_bin/Cargo.toml +++ b/crates/ptth_file_server_bin/Cargo.toml @@ -8,16 +8,17 @@ license = "AGPL-3.0" [dependencies] -anyhow = "1.0.34" -arc-swap = "1.1.0" -handlebars = "3.5.1" +anyhow = "1.0.38" +arc-swap = "1.2.0" +handlebars = "3.5.3" http = "0.2.1" -hyper = "0.13.8" -serde = {version = "1.0.117", features = ["derive"]} -structopt = "0.3.20" -tokio = { version = "0.2.22", features = ["full"] } -tracing = "0.1.21" -tracing-subscriber = "0.2.15" +hyper = "0.14.4" +serde = {version = "1.0.124", features = ["derive"]} +structopt = "0.3.21" +tokio = { version = "1.2.0", features = [] } +tokio-stream = "0.1.3" +tracing = "0.1.25" +tracing-subscriber = "0.2.16" uom = "0.30.0" ptth_core = { path = "../ptth_core" } diff --git a/crates/ptth_file_server_bin/src/main.rs b/crates/ptth_file_server_bin/src/main.rs index fda4d15..d83b122 100644 --- a/crates/ptth_file_server_bin/src/main.rs +++ b/crates/ptth_file_server_bin/src/main.rs @@ -19,6 +19,7 @@ use hyper::{ StatusCode, }; use serde::Deserialize; +use tokio_stream::wrappers::ReceiverStream; use tracing::debug; use ptth_core::{ @@ -70,7 +71,9 @@ async fn handle_all (req: Request , state: Arc ) resp = resp.header (HeaderName::from_str (&k)?, v); } - let body = ptth_resp.body.map_or_else (Body::empty, Body::wrap_stream); + let body = ptth_resp.body.map_or_else (Body::empty, |body| { + Body::wrap_stream (ReceiverStream::new (body)) + }); Ok (resp.body (body)?) } diff --git a/crates/ptth_forwarding/Cargo.toml b/crates/ptth_forwarding/Cargo.toml index 565a332..f6a780d 100644 --- a/crates/ptth_forwarding/Cargo.toml +++ b/crates/ptth_forwarding/Cargo.toml @@ -7,17 +7,19 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.34" -base64 = "0.12.3" +anyhow = "1.0.38" +base64 = "0.13.0" clap = "2.33.3" futures = "0.3.7" -reqwest = { version = "0.10.8", features = ["stream"] } -rmp-serde = "0.14.4" -serde = {version = "1.0.117", features = ["derive"]} -serde_json = "1.0.60" -structopt = "0.3.20" -thiserror = "1.0.22" -tokio = { version = "0.2.22", features = ["full"] } -tracing = "0.1.21" -tracing-futures = "0.2.4" -tracing-subscriber = "0.2.15" +futures-util = "0.3.8" +reqwest = { version = "0.11.1", features = ["stream"] } +rmp-serde = "0.15.4" +serde = {version = "1.0.124", features = ["derive"]} +serde_json = "1.0.64" +structopt = "0.3.21" +thiserror = "1.0.24" +tokio = { version = "1.2.0", features = [] } +tokio-stream = "0.1.3" +tracing = "0.1.25" +tracing-futures = "0.2.5" +tracing-subscriber = "0.2.16" diff --git a/crates/ptth_forwarding/src/main.rs b/crates/ptth_forwarding/src/main.rs index 1297f71..8c73c4f 100644 --- a/crates/ptth_forwarding/src/main.rs +++ b/crates/ptth_forwarding/src/main.rs @@ -1,4 +1,5 @@ use clap::{App, SubCommand}; +use futures_util::StreamExt; use reqwest::Client; use tokio::{ io::{ @@ -11,9 +12,9 @@ use tokio::{ tcp::OwnedReadHalf, }, spawn, - stream::StreamExt, sync::mpsc, }; +use tokio_stream::wrappers::ReceiverStream; #[tokio::main] async fn main () -> anyhow::Result <()> { @@ -37,7 +38,7 @@ async fn main () -> anyhow::Result <()> { TcpStream::connect ("127.0.0.1:4010").await? } else if let Some (_matches) = matches.subcommand_matches ("client") { - let mut listener = TcpListener::bind ("127.0.0.1:4020").await?; + let listener = TcpListener::bind ("127.0.0.1:4020").await?; let (stream, _addr) = listener.accept ().await?; stream } @@ -53,7 +54,7 @@ async fn main () -> anyhow::Result <()> { handle_upstream (tcp_upstream, upstream_tx).await }); - let upstream = client.post ("http://127.0.0.1:4003/").body (reqwest::Body::wrap_stream (upstream_rx)); + let upstream = client.post ("http://127.0.0.1:4003/").body (reqwest::Body::wrap_stream (ReceiverStream::new (upstream_rx))); spawn (async move { upstream.send ().await @@ -72,7 +73,7 @@ async fn main () -> anyhow::Result <()> { async fn handle_upstream ( mut tcp_upstream: OwnedReadHalf, - mut upstream_tx: mpsc::Sender , anyhow::Error>> + upstream_tx: mpsc::Sender , anyhow::Error>> ) -> anyhow::Result <()> { loop { let mut buffer = vec! [0u8; 65_536]; diff --git a/crates/ptth_forwarding_relay/Cargo.toml b/crates/ptth_forwarding_relay/Cargo.toml index 50d6a60..aa8f278 100644 --- a/crates/ptth_forwarding_relay/Cargo.toml +++ b/crates/ptth_forwarding_relay/Cargo.toml @@ -7,12 +7,14 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.34" +anyhow = "1.0.38" futures = "0.3.7" -hyper = "0.13.8" -thiserror = "1.0.22" -tokio = { version = "0.2.22", features = ["full"] } -tracing = "0.1.21" -tracing-futures = "0.2.4" -tracing-subscriber = "0.2.15" +futures-util = "0.3.8" +hyper = "0.14.4" +thiserror = "1.0.24" +tokio = { version = "1.2.0", features = [] } +tokio-stream = "0.1.3" +tracing = "0.1.25" +tracing-futures = "0.2.5" +tracing-subscriber = "0.2.16" ulid = "0.4.1" diff --git a/crates/ptth_forwarding_relay/src/main.rs b/crates/ptth_forwarding_relay/src/main.rs index 09514ea..81cd84c 100644 --- a/crates/ptth_forwarding_relay/src/main.rs +++ b/crates/ptth_forwarding_relay/src/main.rs @@ -4,6 +4,7 @@ use std::{ time::Duration, }; +use futures_util::StreamExt; use hyper::{ Body, Method, @@ -13,13 +14,13 @@ use hyper::{ }; use tokio::{ spawn, - stream::StreamExt, sync::{ RwLock, mpsc, }, time::interval, }; +use tokio_stream::wrappers::ReceiverStream; use tracing::{ info, trace, }; @@ -150,7 +151,7 @@ impl HttpService { }); Ok::<_, anyhow::Error> (Response::builder () - .body (Body::wrap_stream (rx))?) + .body (Body::wrap_stream (ReceiverStream::new (rx)))?) } async fn handle_posts (req: Request , state: &RelayState) @@ -168,7 +169,7 @@ impl HttpService { .body (Body::from ("hello\n"))?) } - async fn handle_downstream (mut tx: mpsc::Sender >) -> Result <(), anyhow::Error> { + async fn handle_downstream (tx: mpsc::Sender >) -> Result <(), anyhow::Error> { let mut int = interval (Duration::from_secs (1)); let mut counter = 0u64; @@ -178,8 +179,6 @@ impl HttpService { tx.send (Ok::<_, anyhow::Error> (format! ("Counter: {}\n", counter))).await?; counter += 1; } - - Ok (()) } } diff --git a/crates/ptth_kv/Cargo.toml b/crates/ptth_kv/Cargo.toml index 7935b66..cae536d 100644 --- a/crates/ptth_kv/Cargo.toml +++ b/crates/ptth_kv/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Trish"] edition = "2018" [dependencies] -anyhow = "1.0.34" +anyhow = "1.0.38" base64 = "0.13.0" -hyper = "0.13.8" +hyper = { version = "0.14.4", features = ["full"] } thiserror = "1.0.22" -tokio = { version = "0.2.22", features = ["full"] } +tokio = { version = "1.2.0", features = ["full"] } diff --git a/crates/ptth_kv/src/main.rs b/crates/ptth_kv/src/main.rs index 1e4f0b2..fc56046 100644 --- a/crates/ptth_kv/src/main.rs +++ b/crates/ptth_kv/src/main.rs @@ -63,7 +63,7 @@ impl HttpService { use std::net::SocketAddr; use hyper::{ - server::Server, + Server, service::{ make_service_fn, service_fn, diff --git a/crates/ptth_relay/Cargo.toml b/crates/ptth_relay/Cargo.toml index ed59393..d3ebf3e 100644 --- a/crates/ptth_relay/Cargo.toml +++ b/crates/ptth_relay/Cargo.toml @@ -8,24 +8,26 @@ license = "AGPL-3.0" [dependencies] -base64 = "0.12.3" +base64 = "0.13.0" blake3 = "0.3.7" -chrono = {version = "0.4.19", features = ["serde"]} +chrono = { version = "0.4.19", features = ["serde"] } clap = "2.33.3" dashmap = "3.11.10" futures = "0.3.7" -handlebars = "3.5.1" -http = "0.2.1" -hyper = "0.13.8" +futures-util = "0.3.8" +handlebars = "3.5.3" +http = "0.2.3" +hyper = { version = "0.14.4", features = ["server", "stream"] } itertools = "0.9.0" rand = "0.6.5" rmp-serde = "0.14.4" -serde = {version = "1.0.117", features = ["derive"]} +serde = { version = "1.0.117", features = ["derive"] } serde_json = "1.0.60" thiserror = "1.0.22" -tokio = { version = "0.2.22", features = ["full"] } +tokio = { version = "1.2.0", features = [] } +tokio-stream = "0.1.3" toml = "0.5.7" -tracing = "0.1.21" +tracing = "0.1.25" tracing-futures = "0.2.4" tracing-subscriber = "0.2.15" ulid = "0.4.1" diff --git a/crates/ptth_relay/src/config.rs b/crates/ptth_relay/src/config.rs index d444081..4f639cc 100644 --- a/crates/ptth_relay/src/config.rs +++ b/crates/ptth_relay/src/config.rs @@ -96,15 +96,7 @@ impl TryFrom for Config { impl Config { pub async fn from_file (path: &Path) -> Result { - use tokio::prelude::*; - - let mut f = tokio::fs::File::open (path).await?; - - let mut buffer = vec! [0_u8; 4096]; - let bytes_read = f.read (&mut buffer).await?; - buffer.truncate (bytes_read); - - let config_s = String::from_utf8 (buffer)?; + let config_s = tokio::fs::read_to_string (path).await?; let new_config: file::Config = toml::from_str (&config_s)?; Self::try_from (new_config) diff --git a/crates/ptth_relay/src/lib.rs b/crates/ptth_relay/src/lib.rs index 378da26..69c4e2c 100644 --- a/crates/ptth_relay/src/lib.rs +++ b/crates/ptth_relay/src/lib.rs @@ -29,6 +29,7 @@ use chrono::{ Utc }; use dashmap::DashMap; +use futures_util::StreamExt; use handlebars::Handlebars; use hyper::{ Body, @@ -47,6 +48,7 @@ use tokio::{ oneshot, }, }; +use tokio_stream::wrappers::ReceiverStream; use ptth_core::{ http_serde, @@ -166,7 +168,7 @@ async fn handle_http_request ( request_rendezvous.insert (watcher_code, new_rendezvous); } - let timeout = tokio::time::delay_for (std::time::Duration::from_secs (30)); + let timeout = tokio::time::sleep (std::time::Duration::from_secs (30)); let received = tokio::select! { val = rx => val, @@ -305,8 +307,6 @@ async fn handle_server_list ( async fn handle_endless_sink (req: Request ) -> Result , http::Error> { - use tokio::stream::StreamExt; - let (_parts, mut body) = req.into_parts (); let mut bytes_received = 0; @@ -339,8 +339,6 @@ async fn handle_endless_source (gib: usize, throttle: Option ) let (tx, rx) = mpsc::channel (1); tokio::spawn (async move { - let mut tx = tx; - let random_block = { use rand::RngCore; @@ -374,7 +372,7 @@ async fn handle_endless_source (gib: usize, throttle: Option ) Response::builder () .status (StatusCode::OK) .header ("content-type", "application/octet-stream") - .body (Body::wrap_stream (rx)) + .body (Body::wrap_stream (ReceiverStream::new (rx))) } #[instrument (level = "trace", skip (req, state, handlebars))] @@ -564,7 +562,7 @@ pub async fn run_relay ( shutdown_oneshot.await.ok (); - state.shutdown_watch_tx.broadcast (true).expect ("Can't broadcast graceful shutdown"); + state.shutdown_watch_tx.send (true).expect ("Can't broadcast graceful shutdown"); let mut response_rendezvous = state.response_rendezvous.write ().await; let mut swapped = DashMap::default (); diff --git a/crates/ptth_relay/src/server_endpoint.rs b/crates/ptth_relay/src/server_endpoint.rs index a5df0f3..d89f3a4 100644 --- a/crates/ptth_relay/src/server_endpoint.rs +++ b/crates/ptth_relay/src/server_endpoint.rs @@ -20,8 +20,8 @@ use tokio::{ mpsc, oneshot, }, - time::delay_for, }; +use tokio_stream::wrappers::ReceiverStream; use ptth_core::{ http_serde, @@ -115,7 +115,7 @@ pub async fn handle_listen ( Ok (Err (ShuttingDownError::ShuttingDown)) => Ok (error_reply (StatusCode::SERVICE_UNAVAILABLE, "Server is shutting down, try again soon")?), Err (_) => Ok (error_reply (StatusCode::INTERNAL_SERVER_ERROR, "Server error")?), }, - _ = delay_for (Duration::from_secs (30)).fuse () => { + _ = tokio::time::sleep (Duration::from_secs (30)).fuse () => { trace! ("Timed out http_listen for server {}", watcher_code); return Ok (error_reply (StatusCode::NO_CONTENT, "No requests now, long-poll again")?) } @@ -151,12 +151,12 @@ pub async fn handle_response ( // Intercept the body packets here so we can check when the stream // ends or errors out - let (mut body_tx, body_rx) = mpsc::channel (2); + let (body_tx, body_rx) = mpsc::channel (2); let (body_finished_tx, body_finished_rx) = oneshot::channel (); let mut shutdown_watch_rx = state.shutdown_watch_rx.clone (); let relay_task = spawn (async move { - if shutdown_watch_rx.recv ().await == Some (false) { + if *shutdown_watch_rx.borrow () == false { loop { let item = body.next ().await; @@ -171,7 +171,7 @@ pub async fn handle_response ( body_finished_tx.send (ClientDisconnected).map_err (|_| LostServer)?; break; }, - _ = shutdown_watch_rx.recv ().fuse () => { + _ = shutdown_watch_rx.changed ().fuse () => { debug! ("Closing stream: relay is shutting down"); break; }, @@ -191,7 +191,7 @@ pub async fn handle_response ( Ok::<(), HandleHttpResponseError> (()) }); - let body = Body::wrap_stream (body_rx); + let body = Body::wrap_stream (ReceiverStream::new (body_rx)); let tx = { let response_rendezvous = state.response_rendezvous.read ().await; diff --git a/crates/ptth_server/Cargo.toml b/crates/ptth_server/Cargo.toml index 0824c84..9711ca8 100644 --- a/crates/ptth_server/Cargo.toml +++ b/crates/ptth_server/Cargo.toml @@ -8,10 +8,10 @@ license = "AGPL-3.0" [dependencies] -aho-corasick = "0.7.14" -anyhow = "1.0.34" -arc-swap = "1.1.0" -base64 = "0.12.3" +aho-corasick = "0.7.15" +anyhow = "1.0.38" +arc-swap = "1.2.0" +base64 = "0.13.0" blake3 = "0.3.7" chrono = {version = "0.4.19", features = ["serde"]} futures = "0.3.7" @@ -22,16 +22,17 @@ lazy_static = "1.4.0" percent-encoding = "2.1.0" pulldown-cmark = "0.8.0" regex = "1.4.1" -reqwest = { version = "0.10.8", features = ["stream"] } +reqwest = { version = "0.11.1", features = [] } rmp-serde = "0.14.4" serde = {version = "1.0.117", features = ["derive"]} serde_json = "1.0.60" structopt = "0.3.20" -thiserror = "1.0.22" -tokio = { version = "0.2.22", features = ["full"] } -tracing = "0.1.21" -tracing-futures = "0.2.4" -tracing-subscriber = "0.2.15" +thiserror = "1.0.24" +tokio = { version = "1.2.0", features = [] } +tokio-stream = "0.1.3" +tracing = "0.1.25" +tracing-futures = "0.2.5" +tracing-subscriber = "0.2.16" toml = "0.5.7" ulid = "0.4.1" uom = "0.30.0" @@ -42,4 +43,4 @@ ptth_core = { path = "../ptth_core" } [dev-dependencies] maplit = "1.0.2" -rand = "0.6.5" +rand = "0.8.3" diff --git a/crates/ptth_server/src/bin/ptth_server.rs b/crates/ptth_server/src/bin/ptth_server.rs index 6fb0fe4..9a05277 100644 --- a/crates/ptth_server/src/bin/ptth_server.rs +++ b/crates/ptth_server/src/bin/ptth_server.rs @@ -41,7 +41,7 @@ fn main () -> Result <(), anyhow::Error> { return Ok (()); } - let mut rt = runtime::Runtime::new ()?; + let rt = runtime::Runtime::new ()?; rt.block_on (async move { run_server ( diff --git a/crates/ptth_server/src/file_server/metrics.rs b/crates/ptth_server/src/file_server/metrics.rs index 3853ff5..c2bcf07 100644 --- a/crates/ptth_server/src/file_server/metrics.rs +++ b/crates/ptth_server/src/file_server/metrics.rs @@ -82,8 +82,6 @@ impl Interval { use heim::process; use uom::si::{ information::mebibyte, - ratio, - time::second, }; let our_process = process::current ().await?; diff --git a/crates/ptth_server/src/file_server/mod.rs b/crates/ptth_server/src/file_server/mod.rs index 78468a0..5393dd6 100644 --- a/crates/ptth_server/src/file_server/mod.rs +++ b/crates/ptth_server/src/file_server/mod.rs @@ -24,7 +24,10 @@ use tokio::{ File, ReadDir, }, - io::AsyncReadExt, + io::{ + AsyncReadExt, + AsyncSeekExt, + }, sync::mpsc::{ channel, }, @@ -141,7 +144,6 @@ async fn serve_file ( if should_send_body { tokio::spawn (async move { - let mut tx = tx; let mut bytes_sent = 0; let mut bytes_left = content_length; diff --git a/crates/ptth_server/src/file_server/tests.rs b/crates/ptth_server/src/file_server/tests.rs index c616a29..503a725 100644 --- a/crates/ptth_server/src/file_server/tests.rs +++ b/crates/ptth_server/src/file_server/tests.rs @@ -64,7 +64,7 @@ fn file_server () { use super::*; tracing_subscriber::fmt ().try_init ().ok (); - let mut rt = Runtime::new ().expect ("Can't create runtime"); + let rt = Runtime::new ().expect ("Can't create runtime"); rt.block_on (async { let file_server_root = PathBuf::from ("./"); diff --git a/crates/ptth_server/src/lib.rs b/crates/ptth_server/src/lib.rs index 7028ccd..5b61d53 100644 --- a/crates/ptth_server/src/lib.rs +++ b/crates/ptth_server/src/lib.rs @@ -20,8 +20,8 @@ use tokio::{ sync::{ oneshot, }, - time::delay_for, }; +use tokio_stream::wrappers::ReceiverStream; use ptth_core::{ http_serde, @@ -88,7 +88,7 @@ async fn handle_one_req ( resp_req = resp_req.header ("Content-Length", length.to_string ()); } if let Some (body) = response.body { - resp_req = resp_req.body (reqwest::Body::wrap_stream (body)); + resp_req = resp_req.body (reqwest::Body::wrap_stream (ReceiverStream::new (body))); } let req = resp_req.build ().map_err (ServerError::Step5Responding)?; @@ -231,14 +231,15 @@ pub async fn run_server ( // TODO: Extract loop body to function? if backoff_delay > 0 { - let mut delay = delay_for (Duration::from_millis (backoff_delay)).fuse (); + let sleep = tokio::time::sleep (Duration::from_millis (backoff_delay)); + tokio::pin! (sleep); - if futures::select! ( - _ = delay => false, - _ = shutdown_oneshot => true, - ) { - info! ("Received graceful shutdown"); - break; + tokio::select! { + _ = &mut sleep => {}, + _ = &mut shutdown_oneshot => { + info! ("Received graceful shutdown"); + break; + }, } } diff --git a/src/main.rs b/src/main.rs index c6e3dab..d0e8a23 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,6 @@ use reqwest::Client; use tokio::{ spawn, sync::oneshot, - time::delay_for, }; use tracing::{ debug, @@ -89,7 +88,7 @@ async fn main () -> anyhow::Result <()> { }) }; - delay_for (Duration::from_millis (1000)).await; + tokio::time::sleep (Duration::from_millis (1000)).await; assert_eq! (relay_state.list_servers ().await, vec! [ server_name.to_string (), @@ -129,7 +128,7 @@ async fn main () -> anyhow::Result <()> { assert_eq! (resp.status (), reqwest::StatusCode::NOT_FOUND); - delay_for (Duration::from_secs (60)).await; + tokio::time::sleep (Duration::from_secs (60)).await; info! ("Shutting down end-to-end test"); diff --git a/src/tests.rs b/src/tests.rs index 66aa02d..c45b612 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -12,7 +12,6 @@ use tokio::{ runtime::Runtime, spawn, sync::oneshot, - time::delay_for, }; use reqwest::Client; @@ -24,7 +23,7 @@ use tracing::{debug, info}; async fn wait_for_any_server (relay_state: &ptth_relay::RelayState) { for _ in 0..50 { - delay_for (Duration::from_millis (100)).await; + tokio::time::sleep (Duration::from_millis (100)).await; if ! relay_state.list_servers ().await.is_empty () { break; } @@ -181,7 +180,7 @@ fn end_to_end () { // and we don't care if another test already installed a subscriber. //tracing_subscriber::fmt ().try_init ().ok (); - let mut rt = Runtime::new ().expect ("Can't create runtime for testing"); + let rt = Runtime::new ().expect ("Can't create runtime for testing"); // Spawn the root task rt.block_on (async { @@ -197,7 +196,6 @@ fn end_to_end () { proxy_port, relay_port, }; - let relay_url = testing_config.relay_url (); let testing_relay = TestingRelay::new (&testing_config).await; let testing_server = TestingServer::new (&testing_config).await; @@ -222,7 +220,7 @@ fn end_to_end () { #[test] fn debug_proxy () { tracing_subscriber::fmt ().try_init ().ok (); - let mut rt = Runtime::new ().expect ("Can't create runtime for testing"); + let rt = Runtime::new ().expect ("Can't create runtime for testing"); rt.block_on (async { let relay_port = 4002; @@ -278,7 +276,7 @@ fn debug_proxy () { #[test] fn scraper_endpoints () { - let mut rt = Runtime::new ().expect ("Can't create runtime for testing"); + let rt = Runtime::new ().expect ("Can't create runtime for testing"); rt.block_on (async { use ptth_relay::*; @@ -334,7 +332,7 @@ fn scraper_endpoints () { }, }; - delay_for (Duration::from_millis (200)).await; + tokio::time::sleep (Duration::from_millis (200)).await; } let resp = resp.expect ("Reqwest repeatedly failed to connect to the relay"); let resp = resp.bytes ().await.expect ("Couldn't check if relay is up"); diff --git a/tools/ptth_tail/Cargo.toml b/tools/ptth_tail/Cargo.toml index 8aaa59d..a55ed19 100644 --- a/tools/ptth_tail/Cargo.toml +++ b/tools/ptth_tail/Cargo.toml @@ -8,14 +8,15 @@ license = "AGPL-3.0" [dependencies] -anyhow = "1.0.34" -tracing = "0.1.21" -tracing-subscriber = "0.2.15" +anyhow = "1.0.38" +futures-util = "0.3.8" +tracing = "0.1.25" +tracing-subscriber = "0.2.16" [dependencies.reqwest] -version = "0.10.8" +version = "0.11.1" features = ["stream"] [dependencies.tokio] -version = "0.2.22" +version = "1.2.0" features = ["full"] diff --git a/tools/ptth_tail/src/main.rs b/tools/ptth_tail/src/main.rs index 7cc513b..f1d64df 100644 --- a/tools/ptth_tail/src/main.rs +++ b/tools/ptth_tail/src/main.rs @@ -7,12 +7,12 @@ use std::{ time::Duration, }; +use futures_util::StreamExt; use reqwest::{ Client, StatusCode, }; use tokio::{ - stream::StreamExt, time::interval, }; use tracing::{ @@ -75,6 +75,4 @@ async fn main () -> Result <(), anyhow::Error> { total_bytes_received += u64::try_from (chunk.len ())?; } } - - Ok (()) }