upgrade tokio, bytes, hyper, reqwest, http-serve

This was mostly straightforward. The most confusing part waas the Sync
bound change on body streams. I copied what hyper did and it seemed to
work. /shruggie
This commit is contained in:
Scott Lamb 2021-01-27 11:47:52 -08:00
parent 4c5444740b
commit b114493729
6 changed files with 240 additions and 336 deletions

441
server/Cargo.lock generated
View File

@ -45,7 +45,7 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -85,6 +85,27 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "async-stream"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3670df70cbc01729f901f94c887814b3c68db038aad1329a418bae178bc5295c"
dependencies = [
"async-stream-impl",
"futures-core",
]
[[package]]
name = "async-stream-impl"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3548b8efc9f8e8a5a0a2808c5bd8451a9031b9e5b879a79590304ae928b0a70"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.51",
]
[[package]]
name = "atty"
version = "0.2.14"
@ -93,7 +114,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -226,9 +247,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[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 = "cc"
@ -257,8 +278,8 @@ dependencies = [
"libc",
"num-integer",
"num-traits",
"time 0.1.44",
"winapi 0.3.9",
"time",
"winapi",
]
[[package]]
@ -295,16 +316,6 @@ dependencies = [
"bitflags",
]
[[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.12"
@ -327,12 +338,6 @@ dependencies = [
"tiny-keccak",
]
[[package]]
name = "const_fn"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
[[package]]
name = "constant_time_eq"
version = "0.1.5"
@ -535,7 +540,7 @@ checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901"
dependencies = [
"libc",
"redox_users",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -695,22 +700,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 = "funty"
version = "1.0.1"
@ -858,9 +847,9 @@ checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
[[package]]
name = "h2"
version = "0.2.7"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535"
checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5"
dependencies = [
"bytes",
"fnv",
@ -933,9 +922,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",
@ -944,9 +933,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",
@ -954,12 +943,15 @@ dependencies = [
[[package]]
name = "http-serve"
version = "0.2.2"
source = "git+https://github.com/scottlamb/http-serve?branch=dir#efde86035aedf6c623c11d1125aa256a3e99e6a2"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "499568d7cb16b48145c6575916c59b0fef1d436f53098a8a53d7b28f7518561b"
dependencies = [
"bytes",
"flate2",
"futures",
"futures-channel",
"futures-core",
"futures-util",
"http",
"http-body",
"httpdate",
@ -967,9 +959,8 @@ dependencies = [
"memchr",
"mime",
"smallvec",
"time 0.2.23",
"tokio",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -986,9 +977,9 @@ checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47"
[[package]]
name = "hyper"
version = "0.13.9"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ad767baac13b44d4529fcf58ba2cd0995e36e7b435bc5b039de6f47e880dbf"
checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe"
dependencies = [
"bytes",
"futures-channel",
@ -1037,9 +1028,9 @@ dependencies = [
[[package]]
name = "input_buffer"
version = "0.3.1"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19a8a95243d5a0398cae618ec29477c6e3cb631152be5c19481f80bc71559754"
checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413"
dependencies = [
"bytes",
]
@ -1053,15 +1044,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"
@ -1092,16 +1074,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"
@ -1213,7 +1185,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
dependencies = [
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1222,16 +1194,6 @@ 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 = "miniz_oxide"
version = "0.4.3"
@ -1244,44 +1206,25 @@ dependencies = [
[[package]]
name = "mio"
version = "0.6.22"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430"
checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7"
dependencies = [
"cfg-if 0.1.10",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
"kernel32-sys",
"libc",
"log",
"miow",
"net2",
"slab",
"winapi 0.2.8",
]
[[package]]
name = "mio-uds"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0"
dependencies = [
"iovec",
"libc",
"mio",
"ntapi",
"winapi",
]
[[package]]
name = "miow"
version = "0.2.1"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897"
dependencies = [
"kernel32-sys",
"net2",
"winapi 0.2.8",
"ws2_32-sys",
"socket2",
"winapi",
]
[[package]]
@ -1294,7 +1237,7 @@ dependencies = [
"log",
"nom",
"parking_lot",
"time 0.1.44",
"time",
]
[[package]]
@ -1326,7 +1269,7 @@ dependencies = [
"rusqlite",
"smallvec",
"tempdir",
"time 0.1.44",
"time",
"uuid",
]
@ -1381,8 +1324,9 @@ dependencies = [
"serde_json",
"smallvec",
"structopt 0.3.20",
"sync_wrapper",
"tempdir",
"time 0.1.44",
"time",
"tokio",
"tokio-tungstenite",
"url",
@ -1420,17 +1364,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "net2"
version = "0.2.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853"
dependencies = [
"cfg-if 0.1.10",
"libc",
"winapi 0.3.9",
]
[[package]]
name = "nix"
version = "0.19.0"
@ -1461,6 +1394,15 @@ dependencies = [
"version_check",
]
[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
"winapi",
]
[[package]]
name = "num"
version = "0.3.1"
@ -1595,7 +1537,7 @@ dependencies = [
"libc",
"redox_syscall",
"smallvec",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1653,12 +1595,6 @@ dependencies = [
"syn 1.0.51",
]
[[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"
@ -1828,7 +1764,7 @@ dependencies = [
"libc",
"rand_core 0.3.1",
"rdrand",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1839,9 +1775,21 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom 0.1.15",
"libc",
"rand_chacha",
"rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc",
"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.1",
"rand_hc 0.3.0",
]
[[package]]
@ -1854,6 +1802,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.1",
]
[[package]]
name = "rand_core"
version = "0.3.1"
@ -1878,6 +1836,15 @@ dependencies = [
"getrandom 0.1.15",
]
[[package]]
name = "rand_core"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5"
dependencies = [
"getrandom 0.2.0",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
@ -1887,6 +1854,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.1",
]
[[package]]
name = "rawpointer"
version = "0.2.1"
@ -1952,14 +1928,14 @@ 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.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb15d6255c792356a0f578d8a645c677904dc02e862bebe2ecc18e0c01b9a0ce"
checksum = "fd281b1030aa675fb90aa994d07187645bb3c8fc756ca766e7c3070b439de9de"
dependencies = [
"base64 0.13.0",
"bytes",
@ -1974,9 +1950,8 @@ dependencies = [
"lazy_static",
"log",
"mime",
"mime_guess",
"percent-encoding",
"pin-project-lite 0.2.0",
"pin-project-lite",
"serde",
"serde_json",
"serde_urlencoded",
@ -1984,7 +1959,6 @@ dependencies = [
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"web-sys",
"winreg",
]
@ -2001,7 +1975,7 @@ dependencies = [
"spin",
"untrusted",
"web-sys",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -2011,7 +1985,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d755237fc0f99d98641540e66abac8bc46a0652f19148ac9e21de2da06b326c9"
dependencies = [
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -2051,7 +2025,7 @@ dependencies = [
"libc",
"rand 0.3.23",
"rustc-serialize",
"time 0.1.44",
"time",
]
[[package]]
@ -2081,12 +2055,6 @@ dependencies = [
"cipher",
]
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]]
name = "scoped_threadpool"
version = "0.1.9"
@ -2262,7 +2230,7 @@ dependencies = [
"cfg-if 1.0.0",
"libc",
"redox_syscall",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -2277,15 +2245,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "standback"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf906c8b8fc3f6ecd1046e01da1d8ddec83e48c8b08b84dcc02b585a6bedf5a8"
dependencies = [
"version_check",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
@ -2378,6 +2337,12 @@ dependencies = [
"unicode-xid 0.2.1",
]
[[package]]
name = "sync_wrapper"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7174d72af9345181af0142ec91151e24afcbf249ef573905b954baca3a3a3705"
[[package]]
name = "synstructure"
version = "0.12.4"
@ -2414,7 +2379,7 @@ checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42"
dependencies = [
"byteorder",
"dirs",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -2424,7 +2389,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9"
dependencies = [
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -2445,42 +2410,7 @@ checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
"winapi 0.3.9",
]
[[package]]
name = "time"
version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcdaeea317915d59b2b4cd3b5efcd156c309108664277793f5351700c02ce98b"
dependencies = [
"const_fn",
"standback",
"time-macros",
"version_check",
]
[[package]]
name = "time-macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1"
dependencies = [
"proc-macro-hack",
"time-macros-impl",
]
[[package]]
name = "time-macros-impl"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa"
dependencies = [
"proc-macro-hack",
"proc-macro2 1.0.24",
"quote 1.0.7",
"standback",
"syn 1.0.51",
"winapi",
]
[[package]]
@ -2509,33 +2439,29 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "0.2.23"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6d7ad61edd59bfcc7e80dababf0f4aed2e6d5e0ba1659356ae889752dfc12ff"
checksum = "8efab2086f17abcddb8f756117665c958feee6b2e39974c2f1600592ab3a4195"
dependencies = [
"autocfg",
"bytes",
"fnv",
"futures-core",
"iovec",
"lazy_static",
"libc",
"memchr",
"mio",
"mio-uds",
"num_cpus",
"once_cell",
"parking_lot",
"pin-project-lite 0.1.11",
"pin-project-lite",
"signal-hook-registry",
"slab",
"tokio-macros",
"winapi 0.3.9",
"winapi",
]
[[package]]
name = "tokio-macros"
version = "0.2.6"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a"
checksum = "42517d2975ca3114b22a16192634e8241dc5cc1f130be194645970cc1c371494"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
@ -2543,30 +2469,43 @@ dependencies = [
]
[[package]]
name = "tokio-tungstenite"
version = "0.11.0"
name = "tokio-stream"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d9e878ad426ca286e4dcae09cbd4e1973a7f8987d97570e2469703dd7f5720c"
checksum = "76066865172052eb8796c686f0b441a93df8b08d40a950b062ffb9a426f00edd"
dependencies = [
"futures-core",
"pin-project-lite",
"tokio",
]
[[package]]
name = "tokio-tungstenite"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1a5f475f1b9d077ea1017ecbc60890fda8e54942d680ca0b1d2b47cfa2d861b"
dependencies = [
"futures-util",
"log",
"pin-project 0.4.27",
"pin-project 1.0.2",
"tokio",
"tungstenite",
]
[[package]]
name = "tokio-util"
version = "0.3.1"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499"
checksum = "feb971a26599ffd28066d387f109746df178eff14d5ea1e235015c5601967a4b"
dependencies = [
"async-stream",
"bytes",
"futures-core",
"futures-sink",
"log",
"pin-project-lite 0.1.11",
"pin-project-lite",
"tokio",
"tokio-stream",
]
[[package]]
@ -2591,8 +2530,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3"
dependencies = [
"cfg-if 1.0.0",
"log",
"pin-project-lite 0.2.0",
"pin-project-lite",
"tracing-core",
]
@ -2623,18 +2561,18 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "tungstenite"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0308d80d86700c5878b9ef6321f020f29b1bb9d5ff3cab25e75e23f3a492a23"
checksum = "8ada8297e8d70872fa9a551d93250a9f407beb9f37ef86494eb20012a2ff7c24"
dependencies = [
"base64 0.12.3",
"base64 0.13.0",
"byteorder",
"bytes",
"http",
"httparse",
"input_buffer",
"log",
"rand 0.7.3",
"rand 0.8.3",
"sha-1",
"url",
"utf-8",
@ -2652,15 +2590,6 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c"
[[package]]
name = "unicase"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
"version_check",
]
[[package]]
name = "unicode-bidi"
version = "0.3.4"
@ -2845,30 +2774,6 @@ version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
[[package]]
name = "wasm-bindgen-test"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34d1cdc8b98a557f24733d50a1199c4b0635e465eecba9c45b214544da197f64"
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.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8fb9c67be7439ee8ab1b7db502a49c05e51e2835b66796c705134d9b8e1a585"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
]
[[package]]
name = "web-sys"
version = "0.3.45"
@ -2879,12 +2784,6 @@ dependencies = [
"wasm-bindgen",
]
[[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"
@ -2895,12 +2794,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"
@ -2919,17 +2812,7 @@ 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",
]
[[package]]

View File

@ -23,7 +23,7 @@ members = ["base", "db"]
base = { package = "moonfire-base", path = "base" }
base64 = "0.13.0"
blake3 = "0.3.7"
bytes = "0.5.3"
bytes = "1"
byteorder = "1.0"
cstr = "0.2.5"
cursive = "0.15.0"
@ -33,9 +33,9 @@ ffmpeg = { package = "moonfire-ffmpeg", git = "https://github.com/scottlamb/moon
futures = "0.3"
fnv = "1.0"
h264-reader = { git = "https://github.com/dholroyd/h264-reader" }
http = "0.2.0"
http-serve = { git = "https://github.com/scottlamb/http-serve", branch = "dir", features = ["dir"] }
hyper = "0.13.0"
http = "0.2.3"
http-serve = { version = "0.3.0", features = ["dir"] }
hyper = { version = "0.14.2", features = ["http1", "server", "stream", "tcp"] }
lazy_static = "1.0"
libc = "0.2"
log = { version = "0.4", features = ["release_max_level_info"] }
@ -54,14 +54,15 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
smallvec = "1.0"
structopt = { version = "0.3.13", features = ["default", "wrap_help"] }
sync_wrapper = "0.1.0"
time = "0.1"
tokio = { version = "0.2.0", features = ["blocking", "macros", "parking_lot", "rt-threaded", "signal"] }
tokio-tungstenite = "0.11.0"
tokio = { version = "1.0", features = ["macros", "parking_lot", "rt-multi-thread", "signal"] }
tokio-tungstenite = "0.13.0"
url = "2.1.1"
uuid = { version = "0.8", features = ["serde", "std", "v4"] }
[dev-dependencies]
reqwest = { version = "0.10.1", default-features = false, features = ["json"] }
reqwest = { version = "0.11.0", default-features = false, features = ["json"] }
tempdir = "0.3"
[profile.dev.package.scrypt]

View File

@ -35,12 +35,12 @@ use futures::{Stream, stream};
use reffers::ARefss;
use std::error::Error as StdError;
use std::pin::Pin;
use sync_wrapper::SyncWrapper;
pub struct Chunk(ARefss<'static, [u8]>);
//pub type CompatError = ::failure::Compat<Error>;
pub type BoxedError = Box<dyn StdError + Send + Sync>;
pub type BodyStream = Box<dyn Stream<Item = Result<Chunk, BoxedError>> + Send + Sync + 'static>;
pub type BodyStream = Box<dyn Stream<Item = Result<Chunk, BoxedError>> + Send>;
pub fn wrap_error(e: Error) -> BoxedError {
Box::new(e.compat())
@ -66,15 +66,18 @@ impl From<Vec<u8>> for Chunk {
fn from(r: Vec<u8>) -> Self { Chunk(ARefss::new(r).map(|v| &v[..])) }
}
impl ::bytes::Buf for Chunk {
impl hyper::body::Buf for Chunk {
fn remaining(&self) -> usize { self.0.len() }
fn bytes(&self) -> &[u8] { &*self.0 }
fn chunk(&self) -> &[u8] { &*self.0 }
fn advance(&mut self, cnt: usize) {
self.0 = ::std::mem::replace(&mut self.0, ARefss::new(&[][..])).map(|b| &b[cnt..]);
}
}
pub struct Body(Pin<BodyStream>);
// This SyncWrapper stuff is blindly copied from hyper's body type.
// See <https://github.com/hyperium/hyper/pull/2187>, matched by
// <https://github.com/scottlamb/http-serve/pull/18>.
pub struct Body(SyncWrapper<Pin<BodyStream>>);
impl hyper::body::HttpBody for Body {
type Data = Chunk;
@ -85,8 +88,7 @@ impl hyper::body::HttpBody for Body {
// This is safe because the pin is not structural.
// https://doc.rust-lang.org/std/pin/#pinning-is-not-structural-for-field
// (The field _holds_ a pin, but isn't itself pinned.)
unsafe { self.get_unchecked_mut() }.0.as_mut().poll_next(cx)
//Pin::from(self.0).as_mut().poll_next(cx)
unsafe { self.get_unchecked_mut() }.0.get_mut().as_mut().poll_next(cx)
}
fn poll_trailers(self: Pin<&mut Self>, _cx: &mut std::task::Context)
@ -96,17 +98,17 @@ impl hyper::body::HttpBody for Body {
}
impl From<BodyStream> for Body {
fn from(b: BodyStream) -> Self { Body(Pin::from(b)) }
fn from(b: BodyStream) -> Self { Body(SyncWrapper::new(Pin::from(b))) }
}
impl<C: Into<Chunk>> From<C> for Body {
fn from(c: C) -> Self {
Body(Box::pin(stream::once(futures::future::ok(c.into()))))
Body(SyncWrapper::new(Box::pin(stream::once(futures::future::ok(c.into())))))
}
}
impl From<Error> for Body {
fn from(e: Error) -> Self {
Body(Box::pin(stream::once(futures::future::err(wrap_error(e)))))
Body(SyncWrapper::new(Box::pin(stream::once(futures::future::err(wrap_error(e))))))
}
}

View File

@ -286,9 +286,7 @@ pub async fn run(args: &Args) -> Result<(), Error> {
move |req| Arc::clone(&svc).serve(req)
}))
});
let server = ::hyper::server::Server::bind(&args.http_addr)
.tcp_nodelay(true)
.serve(make_svc);
let server = ::hyper::Server::bind(&args.http_addr).tcp_nodelay(true).serve(make_svc);
let mut int = signal(SignalKind::interrupt())?;
let mut term = signal(SignalKind::terminate())?;

View File

@ -36,6 +36,7 @@
//! `mdat` box for fast start. More specifically, boxes are arranged in the order suggested by
//! ISO/IEC 14496-12 section 6.2.3 (Table 1):
//!
//! ```text
//! * ftyp (file type and compatibility)
//! * moov (container for all the metadata)
//! ** mvhd (movie header, overall declarations)
@ -77,7 +78,7 @@
//! ```
use base::{Error, ErrorKind, ResultExt, bail_t, format_err_t};
use bytes::{Buf, BytesMut};
use bytes::BytesMut;
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
use crate::body::{Chunk, BoxedError, wrap_error};
use db::dir;
@ -87,6 +88,7 @@ use futures::stream;
use http;
use http::header::HeaderValue;
use http_serve;
use hyper::body::Buf;
use log::{debug, error, trace, warn};
use memmap;
use parking_lot::Once;
@ -1632,10 +1634,15 @@ impl File {
use futures::stream::StreamExt;
match b.next().await {
Some(r) => {
let chunk = r
let mut chunk = r
.map_err(failure::Error::from_boxed_compat)
.err_kind(ErrorKind::Unknown)?;
v.extend_from_slice(chunk.bytes())
while chunk.has_remaining() {
let c = chunk.chunk();
v.extend_from_slice(c);
let len = c.len();
chunk.advance(len);
}
},
None => return Ok(()),
}
@ -1718,8 +1725,8 @@ impl fmt::Debug for File {
#[cfg(test)]
mod tests {
use base::clock::RealClocks;
use bytes::Buf;
use byteorder::{BigEndian, ByteOrder};
use hyper::body::Buf;
use crate::stream::{self, Opener, Stream};
use db::recording::{self, TIME_UNITS_PER_SEC};
use db::testutil::{self, TestDb, TEST_STREAM_ID};
@ -1738,10 +1745,10 @@ mod tests {
where E::Error : ::std::fmt::Debug {
let mut p = 0;
Pin::from(e.get_range(start .. start + slice.len() as u64))
.try_for_each(|chunk| {
let c: &[u8] = chunk.bytes();
slice[p .. p + c.len()].copy_from_slice(c);
p += c.len();
.try_for_each(|mut chunk| {
let len = chunk.remaining();
chunk.copy_to_slice(&mut slice[p .. p + len]);
p += len;
futures::future::ok::<_, E::Error>(())
})
.await
@ -1752,9 +1759,13 @@ mod tests {
async fn digest<E: http_serve::Entity>(e: &E) -> blake3::Hash
where E::Error : ::std::fmt::Debug {
Pin::from(e.get_range(0 .. e.len()))
.try_fold(blake3::Hasher::new(), |mut hasher, chunk| {
let c: &[u8] = chunk.bytes();
hasher.update(c);
.try_fold(blake3::Hasher::new(), |mut hasher, mut chunk| {
while chunk.has_remaining() {
let c = chunk.chunk();
hasher.update(c);
let len = c.len();
chunk.advance(len);
}
futures::future::ok::<_, E::Error>(hasher)
})
.await
@ -2020,8 +2031,16 @@ mod tests {
let mut out = fs::OpenOptions::new().write(true).create_new(true).open(&filename).unwrap();
use ::std::io::Write;
Pin::from(mp4.get_range(0 .. mp4.len()))
.try_for_each(|chunk| {
futures::future::ready(out.write_all(chunk.bytes()).map_err(|e| e.into()))
.try_for_each(|mut chunk| {
while chunk.has_remaining() {
let c = chunk.chunk();
let len = match out.write(c) {
Err(e) => return futures::future::err(BoxedError::from(e)),
Ok(l) => l,
};
chunk.advance(len);
}
futures::future::ok(())
})
.await
.unwrap();
@ -2522,13 +2541,14 @@ mod bench {
http_serve::serve(mp4.clone(), &req))
}))
});
let mut rt = tokio::runtime::Runtime::new().unwrap();
let srv = rt.enter(|| {
let rt = tokio::runtime::Runtime::new().unwrap();
let srv = {
let _guard = rt.enter();
let addr = ([127, 0, 0, 1], 0).into();
hyper::server::Server::bind(&addr)
.tcp_nodelay(true)
.serve(make_svc)
});
};
let addr = srv.local_addr(); // resolve port 0 to a real ephemeral port number.
::std::thread::spawn(move || {
rt.block_on(srv).unwrap();
@ -2578,8 +2598,8 @@ mod bench {
let p = server.generated_len;
b.bytes = p;
let client = reqwest::Client::new();
let mut rt = tokio::runtime::Runtime::new().unwrap();
let mut run = || {
let rt = tokio::runtime::Runtime::new().unwrap();
let run = || {
rt.block_on(async {
let resp =
client.get(server.url.clone())

View File

@ -30,7 +30,7 @@
use base::clock::Clocks;
use base::{ErrorKind, bail_t};
use bytes::Bytes;
use hyper::body::Bytes;
use crate::body::Body;
use crate::json;
use crate::mp4;
@ -398,21 +398,21 @@ impl Service {
.expect("stream_id refed by camera");
}
let (parts, body) = req.into_parts();
let req = Request::from_parts(parts, ());
let response = tungstenite::handshake::server::create_response(&req)
let response =
tungstenite::handshake::server::create_response_with_body(
&req, hyper::Body::empty)
.map_err(|e| bad_req(e.to_string()))?;
let (parts, ()) = response.into_parts();
let (parts, _) = response.into_parts();
tokio::spawn(self.stream_live_m4s_ws(stream_id, open_id, body, sub_rx));
tokio::spawn(self.stream_live_m4s_ws(stream_id, open_id, req, sub_rx));
Ok(Response::from_parts(parts, Body::from("")))
}
async fn stream_live_m4s_ws(
self: Arc<Self>, stream_id: i32, open_id: u32, body: hyper::Body,
self: Arc<Self>, stream_id: i32, open_id: u32, req: hyper::Request<hyper::Body>,
mut sub_rx: futures::channel::mpsc::UnboundedReceiver<db::LiveSegment>) {
let upgraded = match body.on_upgrade().await {
let upgraded = match hyper::upgrade::on(req).await {
Ok(u) => u,
Err(e) => {
warn!("Unable to upgrade stream to websocket: {}", e);
@ -1125,12 +1125,11 @@ mod tests {
let (tx, rx) = std::sync::mpsc::channel();
let handle = ::std::thread::spawn(move || {
let addr = ([127, 0, 0, 1], 0).into();
let mut rt = tokio::runtime::Runtime::new().unwrap();
let srv = rt.enter(|| {
hyper::server::Server::bind(&addr)
.tcp_nodelay(true)
.serve(make_svc)
});
let rt = tokio::runtime::Runtime::new().unwrap();
let srv = {
let _guard = rt.enter();
hyper::server::Server::bind(&addr).tcp_nodelay(true).serve(make_svc)
};
let addr = srv.local_addr(); // resolve port 0 to a real ephemeral port number.
tx.send(addr).unwrap();
rt.block_on(srv.with_graceful_shutdown(shutdown_rx.map(|_| ()))).unwrap();
@ -1429,13 +1428,14 @@ mod bench {
move |req| Arc::clone(&s).serve(req)
}))
});
let mut rt = tokio::runtime::Runtime::new().unwrap();
let srv = rt.enter(|| {
let rt = tokio::runtime::Runtime::new().unwrap();
let srv = {
let _guard = rt.enter();
let addr = ([127, 0, 0, 1], 0).into();
hyper::server::Server::bind(&addr)
.tcp_nodelay(true)
.serve(make_svc)
});
};
let addr = srv.local_addr(); // resolve port 0 to a real ephemeral port number.
::std::thread::spawn(move || {
rt.block_on(srv).unwrap();
@ -1458,8 +1458,8 @@ mod bench {
let url = reqwest::Url::parse(&format!("{}/api/cameras/{}/main/recordings", server.base_url,
server.test_camera_uuid)).unwrap();
let client = reqwest::Client::new();
let mut rt = tokio::runtime::Runtime::new().unwrap();
let mut f = || {
let rt = tokio::runtime::Runtime::new().unwrap();
let f = || {
rt.block_on(async {
let resp = client.get(url.clone()).send().await.unwrap();
assert_eq!(resp.status(), reqwest::StatusCode::OK);