From e17923ed39e972e8ccada1cf0c3a4888366a598d Mon Sep 17 00:00:00 2001 From: Hung-I Wang Date: Fri, 7 Jul 2023 16:32:26 +0800 Subject: [PATCH] refactor: update rustls and other deps && rewrite poll_write accordingly --- .gitmodules | 3 + Cargo.lock | 698 ++++++++++++++++++++++++++++--------------- Cargo.toml | 4 +- rustls-patched | 1 + tunnel/Cargo.toml | 3 +- tunnel/src/client.rs | 6 +- tunnel/src/common.rs | 236 +++++++++++---- tunnel/src/fp.rs | 7 +- tunnel/src/totp.rs | 4 +- tunnel/src/utils.rs | 60 +++- 10 files changed, 689 insertions(+), 333 deletions(-) create mode 100644 .gitmodules create mode 160000 rustls-patched diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..82a4bce --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "rustls-patched"] + path = rustls-patched + url = https://github.com/Gowee/rustls-patched.git diff --git a/Cargo.lock b/Cargo.lock index 0423ba8..cc7a07a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aead" version = "0.4.3" @@ -25,9 +40,9 @@ dependencies = [ [[package]] name = "aes-gcm" -version = "0.9.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" +checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" dependencies = [ "aead", "aes", @@ -48,6 +63,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "aho-corasick" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +dependencies = [ + "memchr", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -59,19 +83,19 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.65" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "async-trait" -version = "0.1.57" +version = "0.1.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" +checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.23", ] [[package]] @@ -80,7 +104,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -91,6 +115,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -99,27 +138,27 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "blake2" -version = "0.10.4" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ "digest", ] [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] [[package]] name = "bumpalo" -version = "3.11.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "bytecount" @@ -127,23 +166,17 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - [[package]] name = "bytes" -version = "1.2.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "camino" -version = "1.1.1" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" dependencies = [ "serde", ] @@ -172,9 +205,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.73" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-if" @@ -233,9 +266,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.22" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", "bitflags", @@ -243,7 +276,7 @@ dependencies = [ "indexmap", "strsim 0.10.0", "termcolor", - "textwrap 0.15.1", + "textwrap 0.16.0", ] [[package]] @@ -257,18 +290,18 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] [[package]] name = "crossbeam-queue" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" dependencies = [ "cfg-if", "crossbeam-utils", @@ -276,9 +309,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.12" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] @@ -295,31 +328,32 @@ dependencies = [ [[package]] name = "ctr" -version = "0.8.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" dependencies = [ "cipher", ] [[package]] name = "curve25519-dalek" -version = "4.0.0-pre.2" +version = "4.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc3116fe595d7847c701796ac1b189bd86b81f4f593c6f775f9d80fb2e29f4" +checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" dependencies = [ - "byteorder", - "digest", - "rand_core", + "cfg-if", + "fiat-crypto", + "packed_simd_2", + "platforms", "subtle", "zeroize", ] [[package]] name = "deadqueue" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35c1225e178e8fd4fe648205304a25dc8712740d5d46462cbf0fc38d280ee8d" +checksum = "16a2561fd313df162315935989dceb8c99db4ee1933358270a57a3cfb8c957f3" dependencies = [ "crossbeam-queue", "tokio", @@ -327,9 +361,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.5" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -338,9 +372,30 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] [[package]] name = "error-chain" @@ -353,18 +408,24 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] +[[package]] +name = "fiat-crypto" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" + [[package]] name = "futures" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -377,9 +438,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -387,15 +448,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -404,38 +465,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.23", ] [[package]] name = "futures-sink" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -451,9 +512,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -461,9 +522,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -480,11 +541,17 @@ dependencies = [ "polyval", ] +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" @@ -513,6 +580,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + [[package]] name = "hex-literal" version = "0.3.4" @@ -527,9 +600,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown", @@ -544,6 +617,17 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.2", + "libc", + "windows-sys", +] + [[package]] name = "itertools" version = "0.10.5" @@ -555,14 +639,14 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" [[package]] name = "ja3-rustls" -version = "0.0.5" -source = "git+https://github.com/gowee/ja3-rustls.git#87edeb59075c662557e7712f16738cacb40ec5ca" +version = "0.0.6" +source = "git+https://github.com/gowee/ja3-rustls.git#462a8eee0ff2a3485a9b1dfb8e47a17ca7bb83e3" dependencies = [ "rand", "rustls", @@ -570,9 +654,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -585,15 +669,27 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.134" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "libm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" + +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -601,12 +697,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" @@ -623,7 +716,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -632,14 +725,22 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + [[package]] name = "mio" -version = "0.8.4" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", - "log", "wasi", "windows-sys", ] @@ -650,7 +751,7 @@ version = "0.2.1" dependencies = [ "anyhow", "async-trait", - "clap 3.2.22", + "clap 3.2.25", "deadqueue", "futures", "httparse", @@ -668,6 +769,16 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-derive" version = "0.3.3" @@ -676,7 +787,7 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -690,19 +801,28 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.2", "libc", ] +[[package]] +name = "object" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" -version = "1.15.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" @@ -712,9 +832,25 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "os_str_bytes" -version = "6.3.0" +version = "6.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "packed_simd_2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" +checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" +dependencies = [ + "cfg-if", + "libm", +] [[package]] name = "parking_lot" @@ -728,22 +864,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.3" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-targets", ] [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -751,6 +887,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "platforms" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" + [[package]] name = "poly1305" version = "0.7.2" @@ -776,9 +918,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-error" @@ -789,7 +931,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -806,18 +948,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.46" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" dependencies = [ "unicode-ident", ] [[package]] name = "pulldown-cmark" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d9cc634bc78768157b5cbfe988ffcd1dcba95cd2b2f03a88316c08c6d00ed63" +checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" dependencies = [ "bitflags", "memchr", @@ -826,9 +968,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -865,20 +1007,23 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.6.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "89089e897c013b3deb627116ae56a6955a72b8bed395c9526af31c9fe528b484" dependencies = [ - "regex-syntax", + "aho-corasick", + "memchr", + "regex-automata 0.3.0", + "regex-syntax 0.7.3", ] [[package]] @@ -887,23 +1032,31 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa250384981ea14565685dea16a9ccc4d1c541a13f82b9c168572264d1df8c56" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.3", ] [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] -name = "remove_dir_all" -version = "0.5.3" +name = "regex-syntax" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "2ab07dc67230e4a4718e70fd5c20055a4334b121f1f9db8fe63ef39ce9b8c846" [[package]] name = "ring" @@ -920,6 +1073,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustc_version" version = "0.4.0" @@ -929,22 +1088,45 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.37.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "rustls" -version = "0.20.6" -source = "git+https://github.com/gowee/rustls-patched.git#d95c7e7d9ef8d978604763d3c523bf0d832eae44" +version = "0.21.3" dependencies = [ "log", "ring", + "rustls-webpki", "sct", - "webpki", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f36a6828982f422756984e47912a7a51dcbc2a197aa791158f8ca61cd8204e" +dependencies = [ + "ring", + "untrusted", ] [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" [[package]] name = "same-file" @@ -973,38 +1155,38 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.145" +version = "1.0.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "d01b7404f9d441d3ad40e6a636a7782c377d2abdbe4fa2440e2edcc2f4f10db8" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "5dd83d6dde2b6b2d466e14d9d1acce8816dedee94f735eac6395808b3483c6d6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.23", ] [[package]] name = "serde_json" -version = "1.0.85" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" dependencies = [ "itoa", "ryu", @@ -1013,9 +1195,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -1033,9 +1215,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] @@ -1057,24 +1239,24 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] [[package]] name = "smallvec" -version = "1.9.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "snow" -version = "0.9.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774d05a3edae07ce6d68ea6984f3c05e9bba8927e3dd591e3b479e5b03213d0d" +checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" dependencies = [ "aes-gcm", "blake2", @@ -1106,9 +1288,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -1163,7 +1345,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1179,15 +1361,26 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "1.0.101" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" dependencies = [ "proc-macro2", "quote", @@ -1196,23 +1389,23 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.3.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys", ] [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] @@ -1228,49 +1421,50 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "c16a64ba9387ef3fdae4f9c1a7f07a0997fce91985c0336f1ddc1822b3b37802" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "d14928354b01c4d6a4f0e549069adef399a284e7995c7ccca94e8a07a5346c59" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.23", ] [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] [[package]] name = "tokio" -version = "1.21.2" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" dependencies = [ "autocfg", + "backtrace", "bytes", "libc", - "memchr", "mio", "num_cpus", "parking_lot", @@ -1278,25 +1472,25 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "winapi", + "windows-sys", ] [[package]] name = "tokio-macros" -version = "1.8.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.23", ] [[package]] name = "tracing" -version = "0.1.36" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "pin-project-lite", @@ -1306,20 +1500,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.22" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.23", ] [[package]] name = "tracing-core" -version = "0.1.29" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", "valuable", @@ -1338,12 +1532,12 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" dependencies = [ - "ansi_term", "matchers", + "nu-ansi-term", "once_cell", "regex", "sharded-slab", @@ -1356,9 +1550,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicase" @@ -1371,15 +1565,15 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.4" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "unicode-segmentation" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" @@ -1389,9 +1583,9 @@ checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "universal-hash" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ "generic-array", "subtle", @@ -1423,12 +1617,11 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -1440,9 +1633,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1450,24 +1643,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.23", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1475,43 +1668,33 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.23", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "web-sys" -version = "0.3.60" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "winapi" version = "0.3.9" @@ -1545,49 +1728,72 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.36.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +dependencies = [ + "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_msvc", "windows_x86_64_gnu", + "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" -version = "0.36.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.36.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.36.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.36.1" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.36.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zeroize" -version = "1.3.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/Cargo.toml b/Cargo.toml index fcb81ec..ed1f320 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,5 @@ members = [ ] [patch.crates-io] -# rustls = { path = "../rustls-mod/rustls" } -rustls = { git = "https://github.com/gowee/rustls-patched.git" } +rustls = { path = "./rustls-patched/rustls" } + diff --git a/rustls-patched b/rustls-patched new file mode 160000 index 0000000..b153796 --- /dev/null +++ b/rustls-patched @@ -0,0 +1 @@ +Subproject commit b15379697711631e5d46c893b65467bd1fa60a12 diff --git a/tunnel/Cargo.toml b/tunnel/Cargo.toml index 8e194f0..2778a2e 100644 --- a/tunnel/Cargo.toml +++ b/tunnel/Cargo.toml @@ -8,7 +8,7 @@ version = "0.1.0" [dependencies] hex-literal = "0.3" snow = "0.9" -rustls = { version = "0.20", features = ["dangerous_configuration"] } +rustls = { version = "*", features = ["dangerous_configuration"] } tokio = { version = "1.20", features = ["full"] } lazy_static = "1.4" futures = "0.3" @@ -18,3 +18,4 @@ tracing = "0.1" lru = "0.7" ja3-rustls = { version = "0.0", git = "https://github.com/gowee/ja3-rustls.git", features = ["rand"] } itertools = "0.10" + diff --git a/tunnel/src/client.rs b/tunnel/src/client.rs index dd8a63d..13e0d96 100644 --- a/tunnel/src/client.rs +++ b/tunnel/src/client.rs @@ -26,7 +26,7 @@ use super::common::{ PSKLEN, TLS_RECORD_HEADER_LENGTH, }; -/// Client with config to establish snowy tunnels with peer servers +/// Client with config to establish snowy tunnels with a peer server #[derive(Debug, Clone)] pub struct Client { pub key: [u8; PSKLEN], @@ -114,7 +114,9 @@ impl Client { Arc::new(tlsconf.clone()), self.server_name.clone(), random.into(), - session_id.as_slice().into(), + Some(session_id.as_slice().into()), + None, + None, chwriter, ) .expect("TLS config valid"); diff --git a/tunnel/src/common.rs b/tunnel/src/common.rs index 01f9eee..5051d09 100644 --- a/tunnel/src/common.rs +++ b/tunnel/src/common.rs @@ -1,5 +1,6 @@ use lazy_static::lazy_static; -use rustls::internal::msgs::deframer::MessageDeframer; +use rustls::internal::msgs::message::MessageError; +use rustls::internal::msgs::{codec::Reader as RustlsCodecReader, message::OpaqueMessage}; use snow::params::NoiseParams; use snow::TransportState; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; @@ -13,7 +14,7 @@ use std::io::{self}; use std::pin::Pin; use std::task::{Context, Poll}; -use crate::utils::{possibly_insecure_hash_with_key, SyncReadAdapter}; +use crate::utils::possibly_insecure_hash_with_key; lazy_static! { pub static ref NOISE_PARAMS: NoiseParams = @@ -21,6 +22,7 @@ lazy_static! { } pub const TLS_RECORD_HEADER_LENGTH: usize = 5; // 1 type + 2 proto ver + 2 data len + // TODO: match TLS length limit? pub const MAXIMUM_CIPHERTEXT_LENGTH: usize = 2usize.pow(14); // 2**14 B = 16 KiB < show::constants::MAXMSGLEN pub const AEAD_TAG_LENGTH: usize = 16; // show::constants::TAGLEN pub const MAXIMUM_PLAINTEXT_LENGTH: usize = MAXIMUM_CIPHERTEXT_LENGTH - AEAD_TAG_LENGTH; @@ -36,7 +38,11 @@ pub struct SnowyStream { pub(crate) socket: TcpStream, pub(crate) noise: TransportState, pub(crate) state: SnowyState, - pub(crate) tls_deframer: MessageDeframer, + // pub(crate) tls_deframer: MessageDeframer, + /// buffer read from raw socket without deframing or decrypting + pub(crate) pending_read_buffer: Box<[u8]>, + pub(crate) pending_read_filled: usize, + /// decrypted plaintext to be consumed by upper-layer app pub(crate) read_buffer: Vec, pub(crate) read_offset: usize, pub(crate) write_buffer: Vec, @@ -48,11 +54,18 @@ impl SnowyStream { /// /// Generally, it is not intended to be used directly by external callers. pub fn new(io: TcpStream, noise: TransportState) -> Self { + // TODO: safe + let mut pending_read_buffer = vec![]; + pending_read_buffer.reserve_exact(OpaqueMessage::MAX_WIRE_SIZE); + unsafe { pending_read_buffer.set_len(OpaqueMessage::MAX_WIRE_SIZE) }; + SnowyStream { socket: io, noise, state: SnowyState::Stream, - tls_deframer: Default::default(), + // tls_deframer: Default::default(), + pending_read_buffer: pending_read_buffer.into_boxed_slice(), + pending_read_filled: 0, read_buffer: Default::default(), read_offset: 0, write_buffer: Default::default(), @@ -75,8 +88,12 @@ impl fmt::Debug for SnowyStream { .field("socket", &self.socket) .field("noise", &self.noise) .field("state", &self.state) - .field("tls_deframer.frames", &self.tls_deframer.frames) - .field("tls_deframer.desynced", &self.tls_deframer.desynced) + // .field("tls_deframer.frames", &self.tls_deframer.frames) // TODO: debug? + // .field("tls_deframer.desynced", &self.tls_deframer.desynced) + .field( + "pending_read_buffer", + &&self.pending_read_buffer[..self.pending_read_filled], + ) .field("read_buffer", &&self.read_buffer[self.read_offset..]) .field("write_buffer", &&self.write_buffer[self.write_offset..]) .finish() @@ -100,6 +117,7 @@ impl AsyncRead for SnowyStream { // first, clean pending read_buffer if this.read_offset < this.read_buffer.len() { let len = cmp::min(this.read_buffer.len() - this.read_offset, buf.remaining()); + // trace!(buflen=len, "get ready buf"); buf.put_slice(&this.read_buffer[this.read_offset..this.read_offset + len]); this.read_offset += len; has_read |= len > 0; @@ -114,41 +132,99 @@ impl AsyncRead for SnowyStream { debug_assert_eq!(this.read_buffer.len(), 0); // then, try to pop a ready TLS frame - if let Some(message) = this.tls_deframer.frames.pop_front() { - // TODO: handle close notify - if message.payload.0.is_empty() { - continue; + // trace!(buflen=this.pending_read_filled, "Extracting a TLS frame from buffer"); + let mut rd = + RustlsCodecReader::init(&this.pending_read_buffer[..this.pending_read_filled]); + match OpaqueMessage::read(&mut rd) { + Ok(message) => { + // TODO: handle close notify + let n = rd.used(); + debug_assert!(n <= this.pending_read_filled); + this.pending_read_buffer + .copy_within(n..this.pending_read_filled, 0); + this.pending_read_filled -= n; + if message.payload.0.is_empty() { + continue; + } + debug_assert_eq!(this.read_offset, 0); + this.read_buffer + .reserve_exact(MAXIMUM_PLAINTEXT_LENGTH - this.read_buffer.capacity()); + unsafe { this.read_buffer.set_len(MAXIMUM_PLAINTEXT_LENGTH) }; + // ensure message payload no empty, o.w. mysterious Decrypt error may be resulted + let len = this + .noise + .read_message(&message.payload.0, &mut this.read_buffer) + .map_err(|e| { + debug!( + "Noise read error on {:?}, message: {:#?}", + this.socket, message + ); + io::Error::new( + io::ErrorKind::InvalidData, + format!("Noise failed to read message: {}", e), + ) + })?; + this.read_buffer.truncate(len); + trace!( + pldlen = message.payload.0.len(), + plainlen = len, + "tls message ready for {:?}, type: {:?}, version: {:?}", + this.socket, + message.typ, + message.version, + ); + } + Err(MessageError::TooShortForHeader) | Err(MessageError::TooShortForLength) => { + // no ready tls frame, proceed to read the inner socket + // trace!("No TLS frame ready"); + break 'read_ready; + } + Err(err) => { + // TODO: properly handle and alert? + debug!("Invalid TLS frame on {:?}: {:?}", this.socket, err); + this.state.shutdown_read(); + return Poll::Ready(Err(io::Error::new( + io::ErrorKind::InvalidData, + "Invalid TLS frame", + ))); } - this.read_buffer - .reserve_exact(MAXIMUM_PLAINTEXT_LENGTH - this.read_buffer.capacity()); - unsafe { this.read_buffer.set_len(MAXIMUM_PLAINTEXT_LENGTH) }; - // ensure message payload no empty, o.w. mysterious Decrypt error may be resulted - let len = this - .noise - .read_message(&message.payload.0, &mut this.read_buffer) - .map_err(|e| { - debug!( - "noise read error on {:?}, message: {:#?}", - this.socket, message - ); - io::Error::new( - io::ErrorKind::InvalidData, - format!("Noise failed to read message: {}", e), - ) - })?; - this.read_buffer.truncate(len); - trace!( - pldlen = message.payload.0.len(), - plainlen = len, - "tls message ready for {:?}, type: {:?}, version: {:?}", - this.socket, - message.typ, - message.version, - ); - } else { - // no ready tls frame, proceed to read the inner socket - break 'read_ready; } + + // if let Some(message) = this.tls_deframer.pop() { + // // TODO: handle close notify + // if message.payload.0.is_empty() { + // continue; + // } + // this.read_buffer + // .reserve_exact(MAXIMUM_PLAINTEXT_LENGTH - this.read_buffer.capacity()); + // unsafe { this.read_buffer.set_len(MAXIMUM_PLAINTEXT_LENGTH) }; + // // ensure message payload no empty, o.w. mysterious Decrypt error may be resulted + // let len = this + // .noise + // .read_message(&message.payload.0, &mut this.read_buffer) + // .map_err(|e| { + // debug!( + // "noise read error on {:?}, message: {:#?}", + // this.socket, message + // ); + // io::Error::new( + // io::ErrorKind::InvalidData, + // format!("Noise failed to read message: {}", e), + // ) + // })?; + // this.read_buffer.truncate(len); + // trace!( + // pldlen = message.payload.0.len(), + // plainlen = len, + // "tls message ready for {:?}, type: {:?}, version: {:?}", + // this.socket, + // message.typ, + // message.version, + // ); + // } else { + // // no ready tls frame, proceed to read the inner socket + // break 'read_ready; + // } } // Note: the best practice is to be conservative on making syscalls // so here prefer to return progress if any, over proceeding to read the inner socket @@ -156,38 +232,34 @@ impl AsyncRead for SnowyStream { break 'read_more; } // otherwise, read the underlying socket - match this.tls_deframer.read(&mut SyncReadAdapter { - io: &mut this.socket, - cx, - }) { - Ok(n) => { - if n == 0 { - // per trait's doc: - // If no data was read (buf.filled().len() is unchanged), it implies - // that EOF has been reached. - this.state.shutdown_read(); - if this.tls_deframer.has_pending() { + // trace!(prev_buflen=this.pending_read_filled, "Reading socket"); + let mut buf = ReadBuf::new(&mut this.pending_read_buffer[this.pending_read_filled..]); + match Pin::new(&mut this.socket).poll_read(cx, &mut buf) { + Poll::Ready(Ok(())) => { + // per trait's doc: + // If no data was read (buf.filled().len() is unchanged), it implies + // that EOF has been reached. + if buf.filled().is_empty() { + if this.pending_read_filled > 0 { // ready frames in tls_deframer has been drained before reaching here // so pending indicates uncompleted frame - debug_assert!(this.tls_deframer.frames.is_empty()); - trace!(this.tls_deframer.desynced); + // trace!(this.pending_read_filled); return Poll::Ready(Err(io::Error::new( io::ErrorKind::UnexpectedEof, - "Underlaying socket EoF when a TLS frame half-read", + "Underlaying socket reaches EoF when a TLS frame half-read", ))); } break 'read_more; } + this.pending_read_filled += buf.filled().len(); + // trace!(buflen_diff=buf.filled().len(), buflen=this.pending_read_filled, "Read socket done"); // proceed to parse TLS frames } - Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => { - return Poll::Pending; - } - Err(err) => { - // TODO: what are we doing here? - // will caller call poll_read for a second time after a fatal error at all? + Poll::Ready(Err(err)) => { + // TODO: is this necessary? + // would caller call poll_read for a second time after a fatal error at all? match err.kind() { - // ErrorKind are copied are tokio-rustls. Why do not we handle other errors? + // ErrorKind are copied from tokio-rustls. Why do not we handle other errors? io::ErrorKind::ConnectionAborted | io::ErrorKind::UnexpectedEof => { this.state.shutdown_read(); } @@ -196,7 +268,51 @@ impl AsyncRead for SnowyStream { debug!("read socket error on {:?}: {:?}", this, err); return Poll::Ready(Err(err)); } + Poll::Pending => { + return Poll::Pending; + } } + // match this.tls_deframer.read(&mut SyncReadAdapter { + // io: &mut this.socket, + // cx, + // }) { + // Ok(n) => { + // if n == 0 { + // // per trait's doc: + // // If no data was read (buf.filled().len() is unchanged), it implies + // // that EOF has been reached. + // this.state.shutdown_read(); + // if this.tls_deframer.has_pending() { + // // ready frames in tls_deframer has been drained before reaching here + // // so pending indicates uncompleted frame + // debug_assert!(this.tls_deframer.frames.is_empty()); + // trace!(this.tls_deframer.desynced); + // return Poll::Ready(Err(io::Error::new( + // io::ErrorKind::UnexpectedEof, + // "Underlaying socket reaches EoF when a TLS frame half-read", + // ))); + // } + // break 'read_more; + // } + // // proceed to parse TLS frames + // } + // Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => { + // return Poll::Pending; + // } + // Err(err) => { + // // TODO: what are we doing here? + // // will caller call poll_read for a second time after a fatal error at all? + // match err.kind() { + // // ErrorKind are copied are tokio-rustls. Why do not we handle other errors? + // io::ErrorKind::ConnectionAborted | io::ErrorKind::UnexpectedEof => { + // this.state.shutdown_read(); + // } + // _ => {} + // } + // debug!("read socket error on {:?}: {:?}", this, err); + // return Poll::Ready(Err(err)); + // } + // } } Poll::Ready(Ok(())) } diff --git a/tunnel/src/fp.rs b/tunnel/src/fp.rs index 19f59a8..9eb4a40 100644 --- a/tunnel/src/fp.rs +++ b/tunnel/src/fp.rs @@ -6,7 +6,7 @@ use rustls::internal::msgs::codec::Codec; use rustls::internal::msgs::enums::{ExtensionType, NamedCurve}; use rustls::internal::msgs::handshake::{ ClientExtension, ConvertProtocolNameList, HandshakeMessagePayload, HandshakePayload, - KeyShareEntry, ProtocolNameList, UnknownExtension, + KeyShareEntry, ProtocolName, UnknownExtension, }; use rustls::internal::msgs::message::{Message, MessagePayload}; use rustls::{ProtocolVersion, SignatureScheme}; @@ -235,8 +235,7 @@ pub fn overwrite_client_hello_with_fingerprint_spec( if !oldextmap.is_empty() && !drop_extensions_not_in_ja3 { // there might be some extensions in CHP that are not present in ja3 trace!("ja3 overwriting: extension {:?} in original chp not present in ja3, appending to end: {}", oldextmap, !drop_extensions_not_in_ja3); - new_extensions - .extend(oldextmap.into_iter().map(|(_typ, ext)| ext.to_owned())); + new_extensions.extend(oldextmap.into_values().map(|ext| ext.to_owned())); } chp.extensions = new_extensions; } @@ -300,7 +299,7 @@ pub fn overwrite_client_hello_with_fingerprint_spec( try_assign!( *alpn, fp.alpn.as_ref().map(|alpn| { - ProtocolNameList::from_slices( + Vec::::from_slices( &alpn.iter().map(|proto| &proto[..]).collect::>(), ) }) diff --git a/tunnel/src/totp.rs b/tunnel/src/totp.rs index c730253..0253e28 100644 --- a/tunnel/src/totp.rs +++ b/tunnel/src/totp.rs @@ -47,7 +47,7 @@ impl Totp { pub fn check(&self, token: &[u8; N], time: u64) -> bool { let basestep = time / self.step - (self.skew as u64); for i in 0..=self.skew * 2 { - let step_time = (basestep + (i as u64)) * (self.step as u64); + let step_time = (basestep + (i as u64)) * self.step; if &self.generate(step_time) == token { return true; } @@ -69,7 +69,7 @@ impl Totp { let nonce = nonce.as_ref(); let basestep = time / self.step - (self.skew as u64); for i in 0..=self.skew * 2 { - let step_time = (basestep + (i as u64)) * (self.step as u64); + let step_time = (basestep + (i as u64)) * self.step; if &self.sign(step_time, nonce) == sig { return true; } diff --git a/tunnel/src/utils.rs b/tunnel/src/utils.rs index 889ca31..20c3c2b 100644 --- a/tunnel/src/utils.rs +++ b/tunnel/src/utils.rs @@ -5,6 +5,7 @@ use rustls::internal::msgs::handshake::{ ServerExtension, ServerHelloPayload, }; use rustls::internal::msgs::message::{Message, MessageError, MessagePayload, OpaqueMessage}; + use rustls::{ContentType as TlsContentType, Error as RustlsError, ProtocolVersion}; use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf}; @@ -93,32 +94,59 @@ pub async fn read_tls_message( ) -> io::Result> { let mut header = [0xefu8; TLS_RECORD_HEADER_LENGTH]; r.read_exact(&mut header).await?; + let typ = TlsContentType::from(header[0]); - let ver = ProtocolVersion::from(u16_from_be_slice(&header[1..3])); + // Don't accept any new content-types. + if let TlsContentType::Unknown(_) = typ { + return Ok(Err(MessageError::InvalidContentType)); + } + + let version = ProtocolVersion::from(u16_from_be_slice(&header[1..3])); + // Accept only versions 0x03XX for any XX. + match version { + ProtocolVersion::Unknown(ref v) if (v & 0xff00) != 0x0300 => { + return Ok(Err(MessageError::UnknownProtocolVersion)); + } + _ => {} + }; + let len = u16_from_be_slice(&header[3..5]) as usize; + // Reject undersize messages // implemented per section 5.1 of RFC8446 (TLSv1.3) // per section 6.2.1 of RFC5246 (TLSv1.2) if typ != TlsContentType::ApplicationData && len == 0 { - return Ok(Err(MessageError::IllegalLength)); + return Ok(Err(MessageError::InvalidEmptyPayload)); } + // Reject oversize messages if len >= MAXIMUM_CIPHERTEXT_LENGTH { - return Ok(Err(MessageError::IllegalLength)); - } - // Don't accept any new content-types. - if let TlsContentType::Unknown(_) = typ { - return Ok(Err(MessageError::IllegalContentType)); - } - match ver { - // actually TLS 1.1 should never be present; TLS1.0 may be present as a compatiblity trick - ProtocolVersion::TLSv1_0 - | ProtocolVersion::TLSv1_1 - | ProtocolVersion::TLSv1_2 - | ProtocolVersion::TLSv1_3 => {} - _ => return Ok(Err(MessageError::IllegalProtocolVersion)), + return Ok(Err(MessageError::MessageTooLarge)); } + // let mut sub = r + // .sub(len as usize) + // .map_err(|_| MessageError::TooShortForLength)?; + // let payload = Payload::read(&mut sub); + + // let typ = TlsContentType::from(header[0]); + // let ver = ProtocolVersion::from(u16_from_be_slice(&header[1..3])); + // let len = u16_from_be_slice(&header[3..5]) as usize; + // // Reject undersize messages + // // implemented per section 5.1 of RFC8446 (TLSv1.3) + // // per section 6.2.1 of RFC5246 (TLSv1.2) + // if typ != TlsContentType::ApplicationData && len == 0 { + // return Ok(Err(MessageError::TooShortForLength)); + // } + // // Reject oversize messages + // if len >= MAXIMUM_CIPHERTEXT_LENGTH { + // return Ok(Err(MessageError::IllegalLength)); + // } + // // Don't accept any new content-types. + // if let TlsContentType::Unknown(_) = typ { + // return Ok(Err(MessageError::IllegalContentType)); + // } + buf.reserve_exact((TLS_RECORD_HEADER_LENGTH + len).max(buf.len()) - buf.len()); unsafe { buf.set_len(TLS_RECORD_HEADER_LENGTH + len) }; buf[..TLS_RECORD_HEADER_LENGTH].copy_from_slice(&header); @@ -129,7 +157,7 @@ pub async fn read_tls_message( pub fn parse_tls_plain_message(buf: &[u8]) -> Result { OpaqueMessage::read(&mut Reader::init(buf)) .map(|om| om.into_plain_message()) - .map_err(|_e| RustlsError::CorruptMessage) // invalid header + .map_err(|_e| RustlsError::General(String::from("Invalid opaque message"))) // invalid header .and_then(Message::try_from) }