diff --git a/Cargo.lock b/Cargo.lock index 4207289..0f5176f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,32 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.7", - "once_cell", - "version_check", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -37,12 +11,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "anyhow" -version = "1.0.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305" - [[package]] name = "atty" version = "0.2.14" @@ -60,21 +28,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "backtrace" -version = "0.3.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" -dependencies = [ - "addr2line", - "cc", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base64" version = "0.13.0" @@ -87,97 +40,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bolero" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e04b4b486337075414a6d4d249e9486791c3b8077060b5a6569881b6dda7471c" -dependencies = [ - "bolero-afl", - "bolero-engine", - "bolero-generator", - "bolero-honggfuzz", - "bolero-kani", - "bolero-libfuzzer", - "cfg-if 1.0.0", - "libtest-mimic", - "rand 0.8.5", -] - -[[package]] -name = "bolero-afl" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cade016d6eaf3106c52b49152aa88a4793b81bff83a584152776cb36e5bbfd" -dependencies = [ - "bolero-engine", - "cc", -] - -[[package]] -name = "bolero-engine" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cddecd963965dc25ab1ffc372bd301172ee14d6bd2aeaa5903b3b0dfde4c0ca" -dependencies = [ - "anyhow", - "backtrace", - "bolero-generator", - "lazy_static", - "pretty-hex", - "rand 0.8.5", -] - -[[package]] -name = "bolero-generator" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc44dcc608e69e699ef11ab57d699245ba0614abdae98fd76a3025780288182c" -dependencies = [ - "bolero-generator-derive", - "either", - "rand_core 0.6.3", -] - -[[package]] -name = "bolero-generator-derive" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7f404f136d870153b22250635d40520696ac3fd41f36eecb07ed4af3534c6e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "bolero-honggfuzz" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "133d830a082e8e42cca16b3e90bc5bc2fcc4a461a92e3a527262582818dc9b53" -dependencies = [ - "bolero-engine", -] - -[[package]] -name = "bolero-kani" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b602e6dc50279f82ef07c4690065820d4dc067d083b047eec820bcae74d9c157" -dependencies = [ - "bolero-engine", -] - -[[package]] -name = "bolero-libfuzzer" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261c37acc55b55a6376c4af9822313b5ba85e23a8b9f1b53446c4c50c42c4c53" -dependencies = [ - "bolero-engine", - "cc", -] - [[package]] name = "bumpalo" version = "3.11.0" @@ -202,18 +64,22 @@ version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +dependencies = [ + "num-integer", + "num-traits", +] + [[package]] name = "clap" version = "2.34.0" @@ -230,81 +96,20 @@ dependencies = [ ] [[package]] -name = "crossbeam-channel" -version = "0.4.4" +name = "core-foundation" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ - "crossbeam-utils 0.7.2", - "maybe-uninit", + "core-foundation-sys", + "libc", ] [[package]] -name = "crossbeam-channel" -version = "0.5.6" +name = "core-foundation-sys" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils 0.8.11", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils 0.8.11", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" -dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "crossbeam-utils 0.8.11", - "memoffset 0.6.5", - "once_cell", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" -dependencies = [ - "cfg-if 1.0.0", - "once_cell", -] - -[[package]] -name = "cuckoofilter" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b810a8449931679f64cd7eef1bbd0fa315801b6d5d9cdc1ace2804d6529eee18" -dependencies = [ - "byteorder", - "fnv", - "rand 0.7.3", -] +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "deser-hjson" @@ -321,7 +126,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "dirs-sys-next", ] @@ -336,39 +141,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "either" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" - -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - -[[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 = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "futures" version = "0.3.23" @@ -459,14 +231,12 @@ dependencies = [ ] [[package]] -name = "getrandom" -version = "0.1.16" +name = "fxhash" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", + "byteorder", ] [[package]] @@ -475,39 +245,9 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash_hasher" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74721d007512d0cb3338cd20f0654ac913920061a4c4d0d8708edb3f2a698c0c" - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash", -] - -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", + "wasi", ] [[package]] @@ -519,21 +259,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hex-literal" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" - -[[package]] -name = "intrusive-collections" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfe531a7789d7120f3e17d4f3f2cd95f54418ba7354f60b7b622b6644a07888a" -dependencies = [ - "memoffset 0.5.6", -] - [[package]] name = "itoa" version = "1.0.3" @@ -561,24 +286,6 @@ version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" -[[package]] -name = "libm" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565" - -[[package]] -name = "libtest-mimic" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a7b8ac1f53f7be8d895ce6f7f534e49581c85c499b47429634b2cb2995e2ae" -dependencies = [ - "crossbeam-channel 0.4.4", - "rayon", - "structopt", - "termcolor", -] - [[package]] name = "lock_api" version = "0.4.7" @@ -595,48 +302,15 @@ version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" -dependencies = [ - "adler", -] - [[package]] name = "mio" version = "0.8.4" @@ -645,7 +319,7 @@ checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys", ] @@ -659,17 +333,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -677,7 +340,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -690,21 +352,18 @@ dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + [[package]] name = "parking_lot" version = "0.12.1" @@ -721,7 +380,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "redox_syscall", "smallvec", @@ -729,23 +388,12 @@ dependencies = [ ] [[package]] -name = "pin-project" -version = "1.0.12" +name = "pem" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "03c64931a1a212348ec4f3b4362585eca7159d0d09cbdf4a7f74f02173596fd4" dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "base64", ] [[package]] @@ -766,36 +414,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" -[[package]] -name = "pretty-hex" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5c99d529f0d30937f6f4b8a86d988047327bb88d04d2c4afc356de74722131" - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.43" @@ -805,6 +423,59 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quinn" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b435e71d9bfa0d8889927231970c51fb89c58fa63bffcab117c9c7a41e5ef8f" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "fxhash", + "quinn-proto", + "quinn-udp", + "rustls", + "thiserror", + "tokio", + "tracing", + "webpki", +] + +[[package]] +name = "quinn-proto" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fce546b9688f767a57530652488420d419a8b1f44a478b451c3d1ab6d992a55" +dependencies = [ + "bytes", + "fxhash", + "rand", + "ring", + "rustls", + "rustls-native-certs", + "rustls-pemfile 0.2.1", + "slab", + "thiserror", + "tinyvec", + "tracing", + "webpki", +] + +[[package]] +name = "quinn-udp" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f832d8958db3e84d2ec93b5eb2272b45aa23cf7f8fe6e79f578896f4e6c231b" +dependencies = [ + "futures-util", + "libc", + "quinn-proto", + "socket2", + "tokio", + "tracing", +] + [[package]] name = "quote" version = "1.0.21" @@ -814,19 +485,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - [[package]] name = "rand" version = "0.8.5" @@ -834,18 +492,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -855,16 +503,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -873,40 +512,19 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.7", + "getrandom", ] [[package]] -name = "rand_hc" -version = "0.2.0" +name = "rcgen" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +checksum = "5911d1403f4143c9d56a702069d593e8d0f3fab880a85e103604d0893ea31ba7" dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rayon" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" -dependencies = [ - "autocfg", - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" -dependencies = [ - "crossbeam-channel 0.5.6", - "crossbeam-deque", - "crossbeam-utils 0.8.11", - "num_cpus", + "chrono", + "pem", + "ring", + "yasna", ] [[package]] @@ -924,7 +542,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.7", + "getrandom", "redox_syscall", "thiserror", ] @@ -956,24 +574,38 @@ dependencies = [ "term_size", ] -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - [[package]] name = "rustls" version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033" dependencies = [ - "log", "ring", "sct", "webpki", ] +[[package]] +name = "rustls-native-certs" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +dependencies = [ + "openssl-probe", + "rustls-pemfile 1.0.1", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +dependencies = [ + "base64", +] + [[package]] name = "rustls-pemfile" version = "1.0.1" @@ -996,124 +628,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] -name = "s2n-codec" -version = "0.1.0" +name = "schannel" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f679fac8b058b41075ab6c6305f21bd31c125f53db5cf567ae3cd2824291d823" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" dependencies = [ - "byteorder", - "bytes", - "zerocopy", - "zerocopy-derive", -] - -[[package]] -name = "s2n-quic" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "205e5584a6939e8b433770583df7af58b1e16abdfda68e637a5b36585d6011e1" -dependencies = [ - "bytes", - "cfg-if 1.0.0", - "cuckoofilter", - "futures", - "hash_hasher", - "rand 0.8.5", - "rand_chacha 0.3.1", - "ring", - "s2n-codec", - "s2n-quic-core", - "s2n-quic-platform", - "s2n-quic-rustls", - "s2n-quic-transport", - "tokio", - "zerocopy", - "zerocopy-derive", - "zeroize", -] - -[[package]] -name = "s2n-quic-core" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b487350eac0cf639690ff6d8f380773897baafd34bbb4a13a27a9c9bba8f9d73" -dependencies = [ - "bolero", - "bolero-generator", - "byteorder", - "bytes", - "hex-literal", - "num-rational", - "num-traits", - "once_cell", - "s2n-codec", - "subtle", - "zerocopy", - "zerocopy-derive", -] - -[[package]] -name = "s2n-quic-crypto" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3476ea144e146fbb7bac850c3eccdd33f577566e1d65e6c862afbcf922d7fb71" -dependencies = [ - "cfg-if 1.0.0", "lazy_static", - "ring", - "s2n-codec", - "s2n-quic-core", - "zeroize", -] - -[[package]] -name = "s2n-quic-platform" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95c8a16eb5f1298da564d027b785a7758ab72c06defaec211316188894fa67d0" -dependencies = [ - "cfg-if 1.0.0", - "errno", - "futures", - "lazy_static", - "libc", - "pin-project", - "s2n-quic-core", - "socket2", - "tokio", - "zeroize", -] - -[[package]] -name = "s2n-quic-rustls" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75465436e8c4ff0dbc3ad93bf20d38cabf36348fd3fb3ee38ba9f53bd84d830f" -dependencies = [ - "bytes", - "rustls", - "rustls-pemfile", - "s2n-codec", - "s2n-quic-core", - "s2n-quic-crypto", -] - -[[package]] -name = "s2n-quic-transport" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7ee56bf3fef30c57dede019ffa79d7ce6a77211635a02355b48cc9335fa911d" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "hashbrown", - "intrusive-collections", - "once_cell", - "s2n-codec", - "s2n-quic-core", - "siphasher", - "smallvec", + "windows-sys", ] [[package]] @@ -1132,6 +653,29 @@ dependencies = [ "untrusted", ] +[[package]] +name = "security-framework" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.143" @@ -1174,24 +718,22 @@ dependencies = [ [[package]] name = "simple-rust-http3-proxy" -version = "0.2.1" +version = "0.3.0" dependencies = [ "clap", "deser-hjson", "futures", + "futures-util", + "pem", + "quinn", + "rcgen", "rust_util", - "s2n-quic", + "rustls", "serde", "serde_json", "tokio", ] -[[package]] -name = "siphasher" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" - [[package]] name = "slab" version = "0.4.7" @@ -1229,36 +771,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -[[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - [[package]] name = "syn" version = "1.0.99" @@ -1270,18 +782,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - [[package]] name = "term" version = "0.7.0" @@ -1303,15 +803,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -1341,6 +832,21 @@ dependencies = [ "syn", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + [[package]] name = "tokio" version = "1.20.1" @@ -1373,30 +879,50 @@ dependencies = [ "syn", ] +[[package]] +name = "tracing" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" +dependencies = [ + "once_cell", +] + [[package]] name = "unicode-ident" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" -[[package]] -name = "unicode-segmentation" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" - [[package]] name = "unicode-width" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "unicode-xid" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" - [[package]] name = "untrusted" version = "0.7.1" @@ -1409,18 +935,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1433,7 +947,7 @@ version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] @@ -1517,15 +1031,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1576,43 +1081,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] -name = "zerocopy" -version = "0.6.0" +name = "yasna" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae0f717764196a220d8c58500e3a3595e2c9054f95d66267f9fd5f6e74ad0fec" +checksum = "e262a29d0e61ccf2b6190d7050d4b237535fc76ce4c1210d9caa316f71dffa75" dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0af017aca1fa6181f5dd7a802456fe6f7666ecdcc18d0910431f0fc89d474e51" -dependencies = [ - "proc-macro2", - "syn", - "synstructure", -] - -[[package]] -name = "zeroize" -version = "1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", + "chrono", ] diff --git a/Cargo.toml b/Cargo.toml index 95aabc7..a784010 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,23 @@ [package] name = "simple-rust-http3-proxy" -version = "0.2.1" +version = "0.3.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] tokio = { version = "1", features = ["full"] } -s2n-quic = { version = "1.9", default-features = false, features = ["provider-address-token-default", "provider-tls-rustls"] } +futures-util = "0.3.14" clap = "2.33" rust_util = "0.6" futures = "0.3" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" deser-hjson = "1.0" +pem = "1.0" +rcgen = "0.8.11" +quinn = "0.8.5" +rustls = { version = "0.20.3", default-features = false, features = ["quic"] } [profile.release] codegen-units = 1 diff --git a/src/client.rs b/src/client.rs index 3217f18..d3d17a1 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,9 +1,9 @@ +use std::error::Error; use std::fs; use std::net::SocketAddr; +use quinn::{ClientConfig, Endpoint}; use rust_util::{util_time, XResult}; -use s2n_quic::{Client, Connection}; -use s2n_quic::client::Connect; use tokio::net::TcpListener; use tokio::sync::mpsc::channel; @@ -34,15 +34,13 @@ pub async fn run(listen_config: &ListenConfig) -> XResult<()> { listen_config.proxy_address, listen_config.proxy_server_name); let cert_pem = opt_result!(fs::read_to_string(&listen_config.cert_pem_file), "Read cert pem file: {}, failed: {}", &listen_config.cert_pem_file); - let client = Client::builder() - .with_tls(cert_pem.as_str())? - .with_io("0.0.0.0:0")? - .start()?; + let cert_bytes = opt_result!(pem::parse(&cert_pem), "Parse cert pem failed: {}").contents; + let addr: SocketAddr = listen_config.proxy_address.parse()?; let server_name = opt_value_result!(&listen_config.proxy_server_name, "proxy_server_name in config is require in client mode"); - let mut connection_opt: Option = None; + let mut endpoint_opt: Option = None; loop { let (client_stream_time, client_stream) = match inbound_stream_channel_receiver.recv().await { Some(time_and_stream) => time_and_stream, @@ -58,34 +56,50 @@ pub async fn run(listen_config: &ListenConfig) -> XResult<()> { continue; } - if let None = connection_opt { - let connect = Connect::new(addr).with_server_name(server_name.as_str()); - let mut connection = match client.connect(connect).await { - Ok(connection) => connection, + if let None = endpoint_opt { + let endpoint = match make_client_endpoint("0.0.0.0:0".parse().unwrap(), &[&cert_bytes]) { + Ok(client) => client, Err(e) => { - failure!("Connect to server failed: {}", e); + failure!("Make client endpoint failed: {}", e); continue; } }; - connection.keep_alive(true).ok(); - connection_opt = Some(connection); + endpoint_opt = Some(endpoint); } - let connection = connection_opt.as_mut().unwrap(); - let server_stream = match connection.open_bidirectional_stream().await { - Ok(stream) => stream, - Err(e) => { - failure!("Open stream in connection to server failed: {}", e); - connection_opt = None; - continue; - } - }; - let connection_id = connection.id(); + let endpoint = endpoint_opt.as_mut().unwrap(); + + let connect = endpoint.connect(addr, &server_name).unwrap(); + let quinn::NewConnection { connection, .. } = connect.await.unwrap(); + let (send, recv) = connection.open_bi().await.unwrap(); + let remote_addr = format!("{}", connection.remote_address()); + let local_addr = connection.local_ip().map(|ip| format!("{}", ip)).unwrap_or_else(|| "".to_string()); tokio::spawn(async move { - let conn_count = format!("{}-{}-{}", util_time::get_current_millis(), connection_id, server_stream.id()); - if let Err(e) = io_util::transfer_for_client_to_server(client_stream, server_stream, conn_count).await { + let remote_addr = remote_addr.clone(); + let local_addr = local_addr.clone(); + let conn_count = format!("{}", util_time::get_current_millis()); + if let Err(e) = io_util::transfer_for_client_to_server(client_stream, recv, send, &remote_addr, &local_addr, conn_count).await { failure!("Client - Server error: {}", e); } }); } +} + +fn make_client_endpoint( + bind_addr: SocketAddr, + server_certs: &[&[u8]], +) -> Result> { + let client_cfg = configure_client(server_certs)?; + let mut endpoint = Endpoint::client(bind_addr)?; + endpoint.set_default_client_config(client_cfg); + Ok(endpoint) +} + +fn configure_client(server_certs: &[&[u8]]) -> Result> { + let mut certs = rustls::RootCertStore::empty(); + for cert in server_certs { + certs.add(&rustls::Certificate(cert.to_vec()))?; + } + + Ok(ClientConfig::with_root_certificates(certs)) } \ No newline at end of file diff --git a/src/io_util.rs b/src/io_util.rs index ed9db4d..3c7448e 100644 --- a/src/io_util.rs +++ b/src/io_util.rs @@ -2,9 +2,9 @@ use std::io::{Error, ErrorKind}; use std::time::Duration; use futures::future::try_join; +use quinn::{RecvStream, SendStream}; use rust_util::util_msg; use rust_util::util_msg::MessageType; -use s2n_quic::stream::BidirectionalStream; use tokio::{select, time}; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use tokio::net::TcpStream; @@ -15,31 +15,31 @@ enum StreamDirection { Down, } -pub async fn transfer_for_server_to_remote(inbound: BidirectionalStream, proxy_addr: String, conn_count: String) -> Result<(), String> { +pub async fn transfer_for_server_to_remote(recv: RecvStream, send: SendStream, remote_addr: &str, local_addr: &str, proxy_addr: String, conn_count: String) -> Result<(), String> { let mut outbound = match TcpStream::connect(&proxy_addr).await { Ok(outbound) => outbound, Err(e) => { return Err(format!("[conn {}] Failed to connect to: {}, err: {}", &conn_count, &proxy_addr, e)); } }; - if let (Ok(ref in_peer_addr), Ok(ref in_local_addr), Ok(ref out_local_addr), Ok(ref out_peer_addr)) - = (inbound.connection().remote_addr(), inbound.connection().local_addr(), outbound.local_addr(), outbound.peer_addr()) { + if let (in_peer_addr, in_local_addr, Ok(ref out_local_addr), Ok(ref out_peer_addr)) + = (remote_addr, local_addr, outbound.local_addr(), outbound.peer_addr()) { let peer = format!("{} -> [{} * {}] -> {}", in_peer_addr, in_local_addr, out_local_addr, out_peer_addr); information!("[conn {}] New server-remote tcp connection: {}", &conn_count, peer); } - let (mut ri, mut wi) = inbound.split(); + let (mut ri, mut wi) = (recv, send); let (mut ro, mut wo) = outbound.split(); inner_transfer(&mut ri, &mut wi, &mut ro, &mut wo, conn_count).await } -pub async fn transfer_for_client_to_server(mut inbound: TcpStream, outbound: BidirectionalStream, conn_count: String) -> Result<(), String> { - if let (Ok(ref in_peer_addr), Ok(ref in_local_addr), Ok(ref out_local_addr), Ok(ref out_peer_addr)) - = (inbound.peer_addr(), inbound.local_addr(), outbound.connection().local_addr(), outbound.connection().remote_addr()) { +pub async fn transfer_for_client_to_server(mut inbound: TcpStream, recv: RecvStream, send: SendStream, remote_addr: &str, local_addr: &str, conn_count: String) -> Result<(), String> { + if let (Ok(ref in_peer_addr), Ok(ref in_local_addr), out_local_addr, out_peer_addr) + = (inbound.peer_addr(), inbound.local_addr(), local_addr, remote_addr) { let peer = format!("{} -> [{} * {}] -> {}", in_peer_addr, in_local_addr, out_local_addr, out_peer_addr); information!("[conn {}] New client-server tcp connection: {}", &conn_count, peer); } let (mut ri, mut wi) = inbound.split(); - let (mut ro, mut wo) = outbound.split(); + let (mut ro, mut wo) = (recv, send); inner_transfer(&mut ri, &mut wi, &mut ro, &mut wo, conn_count).await } diff --git a/src/server.rs b/src/server.rs index 2a774e7..f61c647 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,7 +1,12 @@ use std::fs; +use std::net::SocketAddr; +use std::sync::Arc; +use std::time::Duration; +use futures_util::StreamExt; +use quinn::{Endpoint, ServerConfig}; use rust_util::XResult; -use s2n_quic::Server; +use tokio::time::sleep; use crate::config::ListenConfig; use crate::io_util; @@ -14,31 +19,71 @@ pub async fn run(listen_config: &ListenConfig) -> XResult<()> { let key_pem = opt_result!(fs::read_to_string(&key_pem_file), "Read key pem file :{}, failed: {}", &key_pem_file); - let mut server = Server::builder() - .with_tls((cert_pem.as_str(), key_pem.as_str()))? - .with_io(listen_config.listen.as_str())? - .start()?; + let cert_bytes = opt_result!(pem::parse(&cert_pem), "Parse cert pem failed: {}").contents; + let key_bytes = opt_result!(pem::parse(&key_pem), "Parse key pem failed: {}").contents; + + let priv_key = rustls::PrivateKey(key_bytes); + let cert_chain = vec![rustls::Certificate(cert_bytes)]; + + let mut server_config = opt_result!(ServerConfig::with_single_cert(cert_chain, priv_key), "Create server config failed: {}"); + Arc::get_mut(&mut server_config.transport) + .unwrap() + .max_concurrent_uni_streams(0_u8.into()); information!("Listen: {}", &listen_config.listen); - while let Some(mut connection) = server.accept().await { - // spawn a new task for the connection - let proxy_address = listen_config.proxy_address.clone(); - tokio::spawn(async move { - information!("Connection accepted from {:?}", connection.remote_addr()); - while let Ok(Some(stream)) = connection.accept_bidirectional_stream().await { - // spawn a new task for the stream - let connection_id = connection.id(); - let proxy_address = proxy_address.clone(); - tokio::spawn(async move { - information!("Stream opened from {:?}", stream.connection().remote_addr()); - let conn_count = format!("{}-{}-{}", rust_util::util_time::get_current_millis(), connection_id, stream.id()); - if let Err(e) = io_util::transfer_for_server_to_remote(stream, proxy_address, conn_count).await { - failure!("Server - Client error: {}", e); - } - }); + let listen_addr: SocketAddr = opt_result!(listen_config.listen.parse(), "Parse listen address: {} failed: {}", &listen_config.listen); + let (_endpoint, mut incoming) = opt_result!(Endpoint::server(server_config, listen_addr), "Listen server failed: {}"); + let proxy_address = listen_config.proxy_address.clone(); + loop { + let connection = match incoming.next().await { + Some(connection) => connection, + None => { + warning!("Create connection is None"); + sleep(Duration::from_secs(3)).await; + continue; + } + }; + let connection = match connection.await { + Ok(connection) => connection, + Err(e) => { + warning!("Create connection failed: {}", e); + sleep(Duration::from_secs(3)).await; + continue; + } + }; + let quinn::NewConnection { + connection, + mut bi_streams, + .. + } = connection; + let proxy_address = proxy_address.clone(); + tokio::spawn(async move { + information!("Connection accepted from {}", connection.remote_address()); + let remote_addr = format!("{}", connection.remote_address()); + let local_addr = connection.local_ip().map(|ip| format!("{}", ip)).unwrap_or_else(|| "".to_string()); + loop { + match bi_streams.next().await { + None => { + information!("Connection ended"); + break; + } + Some(Err(e)) => { + information!("Connection ended: {}", e); + break; + } + Some(Ok((send, recv))) => { + let remote_addr = remote_addr.clone(); + let local_addr = local_addr.clone(); + let proxy_address = proxy_address.clone(); + tokio::spawn(async move { + information!("Stream opened from {:?}", &remote_addr); + let conn_count = format!("{}", rust_util::util_time::get_current_millis()); + if let Err(e) = io_util::transfer_for_server_to_remote(recv, send, &remote_addr, &local_addr, proxy_address, conn_count).await { + failure!("Server - Client error: {}", e); + } + }); + } + } } - println!("Connection closed from {:?}", connection.remote_addr()); }); } - - Ok(()) }