From 9da91bb835533c08608d3f31f048d019f1a81384 Mon Sep 17 00:00:00 2001 From: DJMrTV Date: Fri, 13 Jun 2025 10:05:38 +0200 Subject: [PATCH 1/4] feat: split rmc off from prudp, make macros crate location independent and add tls connection setup --- Cargo.lock | 850 +++++++++++++++++++----------- Cargo.toml | 24 +- macros/src/lib.rs | 14 +- macros/src/protos.rs | 30 +- src/common.rs | 37 ++ src/executables/backend_server.rs | 58 ++ src/executables/proxy_insecure.rs | 131 +++++ src/executables/proxy_secure.rs | 26 + src/lib.rs | 22 +- src/main.rs | 11 +- src/prudp/packet.rs | 22 +- src/prudp/router.rs | 7 +- src/prudp/secure.rs | 10 +- src/prudp/sockaddr.rs | 4 +- src/prudp/socket.rs | 60 ++- src/prudp/unsecure.rs | 10 +- src/reggie.rs | 144 +++++ src/rmc/protocols/mod.rs | 25 +- src/rmc/response.rs | 8 +- src/rmc/structures/mod.rs | 11 + src/rmc/structures/networking.rs | 32 ++ src/rnex_proxy_common.rs | 10 + src/util.rs | 94 ++++ src/web/mod.rs | 6 +- 24 files changed, 1222 insertions(+), 424 deletions(-) create mode 100644 src/common.rs create mode 100644 src/executables/backend_server.rs create mode 100644 src/executables/proxy_insecure.rs create mode 100644 src/executables/proxy_secure.rs create mode 100644 src/reggie.rs create mode 100644 src/rmc/structures/networking.rs create mode 100644 src/rnex_proxy_common.rs create mode 100644 src/util.rs diff --git a/Cargo.lock b/Cargo.lock index fbff00b..8c90196 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "adler2" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aho-corasick" @@ -43,9 +43,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "async-stream" @@ -66,18 +66,18 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] name = "async-trait" -version = "0.1.86" +version = "0.1.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -109,27 +109,25 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-lc-rs" -version = "1.12.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea835662a0af02443aa1396d39be523bbf8f11ee6fad20329607c480bea48c3" +checksum = "93fcc8f365936c834db5514fc45aee5b1202d677e6b40e48468aaaa8183ca8c7" dependencies = [ "aws-lc-sys", - "paste", "zeroize", ] [[package]] name = "aws-lc-sys" -version = "0.25.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71b2ddd3ada61a305e1d8bb6c005d1eaa7d14d903681edfc400406d523a9b491" +checksum = "61b1d86e7705efe1be1b569bab41d4fa1e14e220b60a160f78de2db687add079" dependencies = [ "bindgen", "cc", "cmake", "dunce", "fs_extra", - "paste", ] [[package]] @@ -142,7 +140,7 @@ dependencies = [ "axum-core", "bytes", "futures-util", - "http 1.2.0", + "http 1.3.1", "http-body 1.0.1", "http-body-util", "itoa", @@ -168,7 +166,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.2.0", + "http 1.3.1", "http-body 1.0.1", "http-body-util", "mime", @@ -181,9 +179,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.74" +version = "0.3.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line", "cfg-if", @@ -200,6 +198,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" + [[package]] name = "binascii" version = "0.1.4" @@ -215,7 +219,7 @@ dependencies = [ "bitflags", "cexpr", "clang-sys", - "itertools", + "itertools 0.12.1", "lazy_static", "lazycell", "log", @@ -225,15 +229,15 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.98", + "syn 2.0.102", "which", ] [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "block-buffer" @@ -246,28 +250,28 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee" [[package]] name = "bytemuck" -version = "1.21.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.8.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" +checksum = "7ecc273b49b3205b83d648f0690daa588925572cc5063745bfe547fe7ec8e1a1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -278,15 +282,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.9.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.2.10" +version = "1.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" +checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac" dependencies = [ "jobserver", "libc", @@ -304,9 +308,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "cfg_aliases" @@ -315,17 +319,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] -name = "chrono" -version = "0.4.39" +name = "chacha20" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -351,13 +366,19 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.52" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c682c223677e0e5b6b7f63a64b9351844c3f1b1678a68b7ee617e30fb082620e" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" dependencies = [ "cc", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "cookie" version = "0.18.1" @@ -385,6 +406,15 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -406,10 +436,21 @@ dependencies = [ ] [[package]] -name = "deranged" -version = "0.3.11" +name = "der" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", ] @@ -444,7 +485,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -454,6 +495,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", "subtle", ] @@ -466,7 +508,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -483,9 +525,9 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "either" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "encoding_rs" @@ -498,15 +540,15 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" dependencies = [ "libc", "windows-sys 0.59.0", @@ -534,9 +576,9 @@ dependencies = [ [[package]] name = "fixedbitset" -version = "0.4.2" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "fnv" @@ -630,7 +672,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -688,20 +730,20 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.11.1+wasi-snapshot-preview1", ] [[package]] name = "getrandom" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", "libc", @@ -733,7 +775,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.7.1", + "indexmap 2.9.0", "slab", "tokio", "tokio-util", @@ -742,17 +784,17 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.7" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +checksum = "a9421a676d1b147b16b82c9225157dc629087ef8ec4d5e2960f9437a90dac0a5" dependencies = [ "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "http 1.2.0", - "indexmap 2.7.1", + "http 1.3.1", + "indexmap 2.9.0", "slab", "tokio", "tokio-util", @@ -767,9 +809,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.2" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" [[package]] name = "heck" @@ -779,15 +821,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - -[[package]] -name = "hermit-abi" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hex" @@ -826,9 +862,9 @@ dependencies = [ [[package]] name = "http" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" dependencies = [ "bytes", "fnv", @@ -853,27 +889,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.2.0", + "http 1.3.1", ] [[package]] name = "http-body-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", - "futures-util", - "http 1.2.0", + "futures-core", + "http 1.3.1", "http-body 1.0.1", "pin-project-lite", ] [[package]] name = "httparse" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "httpdate" @@ -914,8 +950,8 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.7", - "http 1.2.0", + "h2 0.4.10", + "http 1.3.1", "http-body 1.0.1", "httparse", "httpdate", @@ -928,11 +964,11 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.6" +version = "0.27.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a01595e11bdcec50946522c32dde3fc6914743000a68b93000965f2f02406d" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ - "http 1.2.0", + "http 1.3.1", "hyper 1.6.0", "hyper-util", "rustls", @@ -973,16 +1009,16 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c293b6b3d21eca78250dc7dbebd6b9210ec5530e038cbfe0661b5c47ab06e8" +checksum = "dc2fdfdbff08affe55bb779f33b053aa1fe5dd5b54c257343c17edfa55711bdb" dependencies = [ "base64", "bytes", "futures-channel", "futures-core", "futures-util", - "http 1.2.0", + "http 1.3.1", "http-body 1.0.1", "hyper 1.6.0", "ipnet", @@ -999,14 +1035,15 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.61" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", + "log", "wasm-bindgen", "windows-core", ] @@ -1139,12 +1176,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.1" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", - "hashbrown 0.15.2", + "hashbrown 0.15.4", "serde", ] @@ -1156,9 +1193,9 @@ checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" [[package]] name = "inout" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ "generic-array", ] @@ -1181,11 +1218,11 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.15" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" +checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ - "hermit-abi 0.4.0", + "hermit-abi", "libc", "windows-sys 0.59.0", ] @@ -1200,17 +1237,27 @@ dependencies = [ ] [[package]] -name = "itoa" -version = "1.0.14" +name = "itertools" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom 0.3.3", "libc", ] @@ -1235,6 +1282,9 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] [[package]] name = "lazycell" @@ -1250,20 +1300,32 @@ checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libloading" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.53.1", ] +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + [[package]] name = "linux-raw-sys" version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + [[package]] name = "litemap" version = "0.8.0" @@ -1272,9 +1334,9 @@ checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" dependencies = [ "autocfg", "scopeguard", @@ -1282,9 +1344,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "loom" @@ -1307,8 +1369,8 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "rand 0.9.0", - "syn 2.0.98", + "rand 0.9.1", + "syn 2.0.102", ] [[package]] @@ -1338,9 +1400,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "mime" @@ -1356,22 +1418,22 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.3" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", ] [[package]] @@ -1383,7 +1445,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http 1.2.0", + "http 1.3.1", "httparse", "memchr", "mime", @@ -1395,9 +1457,9 @@ dependencies = [ [[package]] name = "multimap" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" [[package]] name = "native-tls" @@ -1448,12 +1510,49 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1461,15 +1560,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", ] @@ -1493,15 +1593,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "openssl" -version = "0.10.72" +version = "0.10.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" +checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" dependencies = [ "bitflags", "cfg-if", @@ -1520,7 +1620,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -1531,9 +1631,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.108" +version = "0.9.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847" +checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" dependencies = [ "cc", "libc", @@ -1549,9 +1649,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parking_lot" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" dependencies = [ "lock_api", "parking_lot_core", @@ -1559,9 +1659,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.10" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "cfg-if", "libc", @@ -1596,7 +1696,16 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.98", + "syn 2.0.102", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", ] [[package]] @@ -1607,32 +1716,32 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "petgraph" -version = "0.6.5" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" dependencies = [ "fixedbitset", - "indexmap 2.7.1", + "indexmap 2.9.0", ] [[package]] name = "pin-project" -version = "1.1.8" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.8" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -1647,6 +1756,27 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.32" @@ -1670,28 +1800,28 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy 0.7.35", + "zerocopy", ] [[package]] name = "prettyplease" -version = "0.2.29" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" +checksum = "9dee91521343f4c5c6a63edd65e54f31f5c92fe8978c40a4282f8372194c6a7d" dependencies = [ "proc-macro2", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -1704,16 +1834,16 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", "version_check", "yansi", ] [[package]] name = "prost" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" dependencies = [ "bytes", "prost-derive", @@ -1721,12 +1851,12 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b" +checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" dependencies = [ "heck", - "itertools", + "itertools 0.14.0", "log", "multimap", "once_cell", @@ -1735,37 +1865,37 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.98", + "syn 2.0.102", "tempfile", ] [[package]] name = "prost-derive" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools", + "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] name = "prost-types" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" +checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" dependencies = [ "prost", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -1789,13 +1919,12 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", - "zerocopy 0.8.25", ] [[package]] @@ -1824,7 +1953,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.2.16", ] [[package]] @@ -1833,7 +1962,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.2", + "getrandom 0.3.3", ] [[package]] @@ -1847,31 +1976,31 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" dependencies = [ "bitflags", ] [[package]] name = "ref-cast" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -1920,28 +2049,26 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.18" +version = "0.12.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98ff6b0dbbe4d5a37318f433d4fc82babd21631f194d370409ceb2e40b2f0b5" +checksum = "eabf4c97d9130e2bf606614eb937e86edac8292eaa6f422f995d7e8de1eb1813" dependencies = [ "base64", "bytes", "encoding_rs", "futures-core", - "h2 0.4.7", - "http 1.2.0", + "h2 0.4.10", + "http 1.3.1", "http-body 1.0.1", "http-body-util", "hyper 1.6.0", "hyper-rustls", "hyper-tls", "hyper-util", - "ipnet", "js-sys", "log", "mime", "native-tls", - "once_cell", "percent-encoding", "pin-project-lite", "rustls-pki-types", @@ -1962,15 +2089,14 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.8" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.15", + "getrandom 0.2.16", "libc", - "spin", "untrusted", "windows-sys 0.52.0", ] @@ -1989,7 +2115,7 @@ dependencies = [ "either", "figment", "futures", - "indexmap 2.7.1", + "indexmap 2.9.0", "log", "memchr", "multer", @@ -2021,11 +2147,11 @@ checksum = "575d32d7ec1a9770108c879fc7c47815a80073f96ca07ff9525a94fcede1dd46" dependencies = [ "devise", "glob", - "indexmap 2.7.1", + "indexmap 2.9.0", "proc-macro2", "quote", "rocket_http", - "syn 2.0.98", + "syn 2.0.102", "unicode-xid", "version_check", ] @@ -2041,7 +2167,7 @@ dependencies = [ "futures", "http 0.2.12", "hyper 0.14.32", - "indexmap 2.7.1", + "indexmap 2.9.0", "log", "memchr", "pear", @@ -2058,10 +2184,30 @@ dependencies = [ ] [[package]] -name = "rustc-demangle" -version = "0.1.24" +name = "rsa" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" [[package]] name = "rustc-hash" @@ -2071,22 +2217,35 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.43" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys 0.9.4", "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.23.21" +version = "0.23.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" +checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321" dependencies = [ "aws-lc-rs", "log", @@ -2099,15 +2258,18 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +dependencies = [ + "zeroize", +] [[package]] name = "rustls-webpki" -version = "0.102.8" +version = "0.103.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" dependencies = [ "aws-lc-rs", "ring", @@ -2117,15 +2279,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.19" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "schannel" @@ -2173,29 +2335,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -2205,9 +2367,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" dependencies = [ "serde", ] @@ -2224,6 +2386,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -2241,13 +2414,23 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.2" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + [[package]] name = "simplelog" version = "0.12.2" @@ -2270,9 +2453,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" @@ -2290,6 +2473,16 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "splatoon-server-rust" version = "0.1.0" @@ -2297,6 +2490,7 @@ dependencies = [ "anyhow", "async-trait", "bytemuck", + "chacha20", "chrono", "ctrlc", "dotenv", @@ -2310,15 +2504,20 @@ dependencies = [ "once_cell", "paste", "prost", - "rand 0.9.0", + "rand 0.8.5", "rc4", "reqwest", "rocket", + "rsa", "rustls", + "rustls-pki-types", + "rustls-webpki", "serde", + "sha2", "simplelog", "thiserror", "tokio", + "tokio-rustls", "tokio-stream", "tonic", "tonic-build", @@ -2369,9 +2568,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.98" +version = "2.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "f6397daf94fa90f058bd0fd88429dd9e5738999cca8d701813c80723add80462" dependencies = [ "proc-macro2", "quote", @@ -2395,7 +2594,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -2421,15 +2620,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.15.0" +version = "3.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ - "cfg-if", "fastrand", - "getrandom 0.2.15", + "getrandom 0.3.3", "once_cell", - "rustix", + "rustix 1.0.7", "windows-sys 0.59.0", ] @@ -2444,22 +2642,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -2474,9 +2672,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.37" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", "itoa", @@ -2491,15 +2689,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "time-macros" -version = "0.2.19" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" dependencies = [ "num-conv", "time-core", @@ -2517,9 +2715,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.0" +version = "1.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779" dependencies = [ "backtrace", "bytes", @@ -2540,7 +2738,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -2555,9 +2753,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ "rustls", "tokio", @@ -2576,9 +2774,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.13" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" +checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" dependencies = [ "bytes", "futures-core", @@ -2589,9 +2787,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.20" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", "serde_spanned", @@ -2601,26 +2799,33 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.24" +version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.7.1", + "indexmap 2.9.0", "serde", "serde_spanned", "toml_datetime", + "toml_write", "winnow", ] +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + [[package]] name = "tonic" version = "0.12.3" @@ -2632,8 +2837,8 @@ dependencies = [ "axum", "base64", "bytes", - "h2 0.4.7", - "http 1.2.0", + "h2 0.4.10", + "http 1.3.1", "http-body 1.0.1", "http-body-util", "hyper 1.6.0", @@ -2662,7 +2867,7 @@ dependencies = [ "prost-build", "prost-types", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -2702,14 +2907,14 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.4" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdb0c213ca27a9f57ab69ddb290fd80d970922355b83ae380b395d3986b8a2e" +checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" dependencies = [ "bitflags", "bytes", "futures-util", - "http 1.2.0", + "http 1.3.1", "http-body 1.0.1", "iri-string", "pin-project-lite", @@ -2743,20 +2948,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.28" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +checksum = "1b1ffbcf9c6f6b99d386e7444eb608ba646ae452a36b39737deb9663b610f662" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", "valuable", @@ -2824,9 +3029,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.14" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-xid" @@ -2896,9 +3101,9 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" @@ -2931,7 +3136,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", "wasm-bindgen-shared", ] @@ -2966,7 +3171,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2999,7 +3204,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix", + "rustix 0.38.44", ] [[package]] @@ -3044,28 +3249,54 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.52.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-targets 0.52.6", + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.102", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.102", ] [[package]] name = "windows-link" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" +checksum = "d3bfe459f85da17560875b8bf1423d6f113b7a87a5d942e7da0ac71be7c61f8b" [[package]] name = "windows-registry" -version = "0.4.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" +checksum = "b3bab093bdd303a1240bb99b8aba8ea8a69ee19d34c9e2ef9594e708a4878820" dependencies = [ + "windows-link", "windows-result", "windows-strings", - "windows-targets 0.53.0", ] [[package]] @@ -3079,9 +3310,9 @@ dependencies = [ [[package]] name = "windows-strings" -version = "0.3.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ "windows-link", ] @@ -3137,9 +3368,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +checksum = "30357ec391cde730f8fbfcdc29adc47518b06504528df977ab5af02ef23fdee9" dependencies = [ "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", @@ -3291,9 +3522,9 @@ checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winnow" -version = "0.7.2" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" +checksum = "74c7b26e3480b707944fc872477815d29a8e429d2f93a1ce000f5fa84a15cbcd" dependencies = [ "memchr", ] @@ -3342,38 +3573,17 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", "synstructure", ] -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "byteorder", - "zerocopy-derive 0.7.35", -] - [[package]] name = "zerocopy" version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" dependencies = [ - "zerocopy-derive 0.8.25", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.98", + "zerocopy-derive", ] [[package]] @@ -3384,7 +3594,7 @@ checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] [[package]] @@ -3404,7 +3614,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", "synstructure", ] @@ -3444,5 +3654,5 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.102", ] diff --git a/Cargo.toml b/Cargo.toml index 6d88cf4..64ffb4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,8 +25,8 @@ simplelog = "0.12.2" chrono = "0.4.39" log = "0.4.25" anyhow = "1.0.95" -rand = "0.9.0-beta.3" -rustls = "^0.23.21" +rand = "0.8.5" + hmac = "0.12.1" md-5 = "^0.10.6" tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread", "net", "sync", "fs"] } @@ -45,6 +45,15 @@ futures = "0.3.31" reqwest = "0.12.18" json = "0.12.4" ctrlc = "3.4.7" +rsa = "0.9.8" +sha2 = "0.10.9" +chacha20 = "0.9.1" + +rustls = "0.23.27" + +rustls-pki-types = "1.12.0" +rustls-webpki = "0.103.3" +tokio-rustls = "0.26.2" @@ -57,3 +66,14 @@ default = ["secure", "auth"] secure = [] auth = [] +[[bin]] +name = "proxy_insecure" +path = "src/executables/proxy_insecure.rs" + +[[bin]] +name = "proxy_secure" +path = "src/executables/proxy_secure.rs" + +[[bin]] +name = "backend_server" +path = "src/executables/backend_server.rs" \ No newline at end of file diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 5c08c0e..122a0a4 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -189,7 +189,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream { quote! { #pre_inner - crate::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{ + splatoon_server_rust::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{ #serialize_base_content })?; @@ -218,7 +218,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream { quote! { #pre_inner - Ok(crate::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{ + Ok(splatoon_server_rust::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{ #deserialize_base_content })?) } @@ -229,14 +229,14 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream { let ident = derive_input.ident; let tokens = quote! { - impl crate::rmc::structures::RmcSerialize for #ident{ - fn serialize(&self, writer: &mut dyn ::std::io::Write) -> crate::rmc::structures::Result<()>{ + impl splatoon_server_rust::rmc::structures::RmcSerialize for #ident{ + fn serialize(&self, writer: &mut dyn ::std::io::Write) -> splatoon_server_rust::rmc::structures::Result<()>{ #serialize_base_content } - fn deserialize(reader: &mut dyn ::std::io::Read) -> crate::rmc::structures::Result{ + fn deserialize(reader: &mut dyn ::std::io::Read) -> splatoon_server_rust::rmc::structures::Result{ #deserialize_base_content } } @@ -367,8 +367,8 @@ pub fn rmc_struct(attr: TokenStream, input: TokenStream) -> TokenStream{ } - impl crate::rmc::protocols::RmcCallable for #struct_name{ - async fn rmc_call(&self, remote_response_connection: &crate::prudp::socket::SendingConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ + impl splatoon_server_rust::rmc::protocols::RmcCallable for #struct_name{ + async fn rmc_call(&self, remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ ::rmc_call(self, remote_response_connection, protocol_id, method_id, call_id, rest).await; } } diff --git a/macros/src/protos.rs b/macros/src/protos.rs index 32d04c3..d7d84c1 100644 --- a/macros/src/protos.rs +++ b/macros/src/protos.rs @@ -73,7 +73,7 @@ impl RmcProtocolData{ for (param_name, param_type) in parameters{ quote!{ let Ok(#param_name) = - <#param_type as crate::rmc::structures::RmcSerialize>::deserialize( + <#param_type as splatoon_server_rust::rmc::structures::RmcSerialize>::deserialize( &mut cursor ) else }.to_tokens(tokens); @@ -84,7 +84,7 @@ impl RmcProtocolData{ quote! { { log::error!(#error_msg); - return Err(crate::rmc::response::ErrorCode::Core_InvalidArgument); + return Err(splatoon_server_rust::rmc::response::ErrorCode::Core_InvalidArgument); }; }.to_tokens(tokens) } else { @@ -116,7 +116,7 @@ impl RmcProtocolData{ quote!{ let retval = retval?; let mut vec = Vec::new(); - crate::rmc::structures::RmcSerialize::serialize(&retval, &mut vec).ok(); + splatoon_server_rust::rmc::structures::RmcSerialize::serialize(&retval, &mut vec).ok(); Ok(vec) }.to_tokens(tokens); } @@ -126,7 +126,7 @@ impl RmcProtocolData{ quote!{ async fn rmc_call_proto( &self, - remote_response_connection: &crate::prudp::socket::SendingConnection, + remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, method_id: u32, call_id: u32, data: Vec, @@ -165,7 +165,7 @@ impl RmcProtocolData{ }.to_tokens(tokens); if self.has_returns { quote! { - Err(crate::rmc::response::ErrorCode::Core_NotImplemented) + Err(splatoon_server_rust::rmc::response::ErrorCode::Core_NotImplemented) }.to_tokens(tokens); } }); @@ -176,7 +176,7 @@ impl RmcProtocolData{ if *has_returns{ quote!{ - crate::rmc::response::send_result( + splatoon_server_rust::rmc::response::send_result( remote_response_connection, ret, #id, @@ -209,7 +209,7 @@ impl RmcProtocolData{ // boilerplate tokens which all raw traits need quote!{ #[doc(hidden)] - pub trait #remote_name: crate::rmc::protocols::HasRmcConnection + pub trait #remote_name: splatoon_server_rust::rmc::protocols::HasRmcConnection }.to_tokens(tokens); // generate the body of the raw protocol trait @@ -247,12 +247,12 @@ impl RmcProtocolData{ for (param_name, param_type) in parameters{ quote!{ - crate::result::ResultExtension::display_err_or_some( - <#param_type as crate::rmc::structures::RmcSerialize>::serialize( + splatoon_server_rust::result::ResultExtension::display_err_or_some( + <#param_type as splatoon_server_rust::rmc::structures::RmcSerialize>::serialize( &#param_name, &mut cursor ) - ).ok_or(crate::rmc::response::ErrorCode::Core_InvalidArgument) + ).ok_or(splatoon_server_rust::rmc::response::ErrorCode::Core_InvalidArgument) }.to_tokens(tokens); if self.has_returns { quote! { @@ -268,25 +268,25 @@ impl RmcProtocolData{ quote!{ let call_id = rand::random(); - let message = crate::rmc::message::RMCMessage{ + let message = splatoon_server_rust::rmc::message::RMCMessage{ call_id, method_id: #method_id, protocol_id: #proto_id, rest_of_data: send_data }; - let rmc_conn = ::get_connection(self); + let rmc_conn = ::get_connection(self); }.to_tokens(tokens); if *has_returns{ quote!{ - crate::result::ResultExtension::display_err_or_some( + splatoon_server_rust::result::ResultExtension::display_err_or_some( rmc_conn.make_raw_call(&message).await - ).ok_or(crate::rmc::response::ErrorCode::Core_Exception) + ).ok_or(splatoon_server_rust::rmc::response::ErrorCode::Core_Exception) }.to_tokens(tokens); } else { quote!{ - crate::result::ResultExtension::display_err_or_some( + splatoon_server_rust::result::ResultExtension::display_err_or_some( rmc_conn.make_raw_call_no_response(&message).await ); }.to_tokens(tokens); diff --git a/src/common.rs b/src/common.rs new file mode 100644 index 0000000..a8b40c6 --- /dev/null +++ b/src/common.rs @@ -0,0 +1,37 @@ +use std::fs; +use std::fs::File; +use chrono::{Local, SecondsFormat}; +use log::LevelFilter; +use simplelog::{ColorChoice, CombinedLogger, Config, TermLogger, TerminalMode, WriteLogger}; + +pub fn setup(){ + CombinedLogger::init(vec![ + TermLogger::new( + LevelFilter::Info, + Config::default(), + TerminalMode::Mixed, + ColorChoice::Auto, + ), + WriteLogger::new(LevelFilter::max(), Config::default(), { + fs::create_dir_all("log").unwrap(); + let date = Local::now().to_rfc3339_opts(SecondsFormat::Secs, false); + // this fixes windows being windows + let date = date.replace(":", "-"); + let filename = format!("{}.log", date); + if cfg!(windows) { + File::create(format!("log\\{}", filename)).unwrap() + } else { + File::create(format!("log/{}", filename)).unwrap() + } + }), + ]) + .unwrap(); + + /*ctrlc::set_handler(||{ + FORCE_EXIT.call_once_force(|_|{ + println!("attempting exit"); + }); + }).unwrap();*/ + + dotenv::dotenv().ok(); +} \ No newline at end of file diff --git a/src/executables/backend_server.rs b/src/executables/backend_server.rs new file mode 100644 index 0000000..71da3e2 --- /dev/null +++ b/src/executables/backend_server.rs @@ -0,0 +1,58 @@ +use log::error; +use once_cell::sync::Lazy; +use rustls::client::danger::HandshakeSignatureValid; +use rustls::pki_types::{CertificateDer, TrustAnchor, UnixTime}; +use rustls::server::danger::{ClientCertVerified, ClientCertVerifier}; +use rustls::server::{ClientCertVerifierBuilder, WebPkiClientVerifier}; +use rustls::{ + DigitallySignedStruct, DistinguishedName, Error, RootCertStore, ServerConfig, ServerConnection, + SignatureScheme, +}; +use rustls_pki_types::PrivateKeyDer; +use splatoon_server_rust::common::setup; +use splatoon_server_rust::reggie::{get_configured_tls_acceptor, TestStruct, ROOT_TRUST_ANCHOR, SELF_CERT, SELF_KEY}; +use std::borrow::ToOwned; +use std::fs; +use std::io::Cursor; +use std::net::{IpAddr, SocketAddr, SocketAddrV4}; +use std::sync::Arc; +use macros::{method_id, rmc_proto, rmc_struct}; +use tokio::io::AsyncReadExt; +use tokio::net::{TcpListener, TcpSocket}; +use tokio::task; +use tokio_rustls::TlsAcceptor; +use splatoon_server_rust::define_rmc_proto; +use splatoon_server_rust::rmc::protocols::new_rmc_gateway_connection; +use splatoon_server_rust::rmc::response::ErrorCode; +use splatoon_server_rust::rmc::structures::RmcSerialize; + + + + +#[tokio::main] +async fn main() { + setup(); + + let acceptor = get_configured_tls_acceptor().await; + + let listen = TcpListener::bind("192.168.178.120:2376").await.unwrap(); + + while let Ok((stream, addr)) = listen.accept().await { + let mut stream = match acceptor.accept(stream).await { + Ok(v) => v, + Err(e) => { + error!("an error ocurred whilest accepting tls connection: {:?}", e); + continue; + } + }; + + task::spawn(async move { + new_rmc_gateway_connection(stream.into(), |_| { + Arc::new(TestStruct) + }); + + println!("lost connection lol"); + }); + + } +} diff --git a/src/executables/proxy_insecure.rs b/src/executables/proxy_insecure.rs new file mode 100644 index 0000000..b147163 --- /dev/null +++ b/src/executables/proxy_insecure.rs @@ -0,0 +1,131 @@ +mod proxy_secure; + +use std::env; +use std::ffi::CStr; +use std::io::{Read, Write}; +use std::net::{Ipv4Addr, SocketAddrV4, TcpListener, TcpStream}; +use bytemuck::{Pod, Zeroable}; +use chacha20::{ChaCha20, Key}; +use chacha20::cipher::{Iv, KeyIvInit, StreamCipher}; +use log::error; +use once_cell::sync::Lazy; +use rsa::pkcs8::{DecodePrivateKey, DecodePublicKey, Document}; +use rsa::{BigUint, Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey}; +use rsa::pkcs1::EncodeRsaPublicKey; +use rsa::pss::BlindedSigningKey; +use rsa::signature::{RandomizedSigner, SignatureEncoding}; +use sha2::Sha256; +use tokio::net::TcpSocket; +use tokio::task; +use splatoon_server_rust::common::setup; +use splatoon_server_rust::prudp::packet::VirtualPort; +use splatoon_server_rust::prudp::router::Router; +use splatoon_server_rust::prudp::unsecure::Unsecure; +use splatoon_server_rust::reggie::{establish_tls_connection_to, UnitPacketRead, UnitPacketWrite}; +use splatoon_server_rust::rmc::structures::RmcSerialize; +use splatoon_server_rust::rnex_proxy_common::ConnectionInitData; + +static OWN_IP_PRIVATE: Lazy = Lazy::new(|| { + env::var("SERVER_IP") + .ok() + .and_then(|s| s.parse().ok()) + .expect("no public ip specified") +}); + +static OWN_IP_PUBLIC: Lazy = + Lazy::new(|| env::var("SERVER_IP_PUBLIC").unwrap_or(OWN_IP_PRIVATE.to_string())); + +static SERVER_PORT: Lazy = Lazy::new(|| { + env::var("AUTH_SERVER_PORT") + .ok() + .and_then(|s| s.parse().ok()) + .unwrap_or(10000) +}); + +static FORWARD_DESTINATION: Lazy = + Lazy::new(|| env::var("FORWARD_DESTINATION").unwrap_or(OWN_IP_PRIVATE.to_string())); + +static RSA_PRIVKEY: Lazy = Lazy::new(|| { + let path = env::var("RSA_PRIVKEY") + .expect("RSA_PRIVKEY not set"); + + RsaPrivateKey::read_pkcs8_pem_file(&path) + .expect("unable to read private key") +}); + +static RSA_PUBKEY: Lazy = Lazy::new(|| { + RSA_PRIVKEY.to_public_key() +}); + +static PUBKEY_ENCODED: Lazy = Lazy::new(|| { + RSA_PUBKEY.to_pkcs1_der().expect("unable to convert pubkey to der") +}); + +static RSA_SIGNKEY: Lazy> = Lazy::new(|| + BlindedSigningKey::::new(RSA_PRIVKEY.clone()) +); + +#[tokio::main] +async fn main() { + setup(); + + let (router_secure, _) = Router::new(SocketAddrV4::new(*OWN_IP_PRIVATE, *SERVER_PORT)) + .await + .expect("unable to start router"); + + let mut socket_secure = router_secure + .add_socket(VirtualPort::new(1, 10), Unsecure( + "6f599f81" + )) + .await + .expect("unable to add socket"); + + // let conn = socket_secure.connect(auth_sockaddr).await.unwrap(); + + loop { + let Some(mut conn) = socket_secure.accept().await else { + error!("server crashed"); + return; + }; + + task::spawn(async move { + let mut stream + = establish_tls_connection_to("192.168.178.120:2376", "account.spfn.net").await; + + if let Err(e) = stream.send_buffer(&ConnectionInitData{ + prudpsock_addr: conn.socket_addr + }.to_data()).await{ + error!("error connecting to backend: {}", e); + return; + }; + + loop { + tokio::select! { + data = conn.recv() => { + let Some(data) = data else { + break; + }; + + if let Err(e) = stream.send_buffer(&data[..]).await{ + error!("error sending data to backend: {}", e); + break; + } + }, + data = stream.read_buffer() => { + let data = match data{ + Ok(d) => d, + Err(e) => { + error!("error reveiving data from backend: {}", e); + break; + } + }; + + if conn.send(data).await == None{ + return; + } + }, + } + } + }); + } +} \ No newline at end of file diff --git a/src/executables/proxy_secure.rs b/src/executables/proxy_secure.rs new file mode 100644 index 0000000..950680a --- /dev/null +++ b/src/executables/proxy_secure.rs @@ -0,0 +1,26 @@ +use splatoon_server_rust::reggie::RemoteRmcTestProto; +use std::fs; +use std::net::IpAddr; +use std::sync::Arc; +use rustls::ClientConfig; +use rustls_pki_types::ServerName; +use tokio::io::AsyncWriteExt; +use tokio::net::TcpStream; +use tokio_rustls::{TlsConnector, TlsStream}; +use splatoon_server_rust::common::setup; +use splatoon_server_rust::reggie::{establish_tls_connection_to, get_configured_tls_connector, RemoteTestProto, UnitPacketWrite}; +use splatoon_server_rust::rmc::protocols::{new_rmc_gateway_connection, OnlyRemote}; +use splatoon_server_rust::rmc::structures::RmcSerialize; + + +#[tokio::main] +async fn main(){ + setup(); + + let mut stream + = establish_tls_connection_to("192.168.178.120:2376", "account.spfn.net").await; + + let remo = new_rmc_gateway_connection(stream.into(), |r| Arc::new(OnlyRemote::::new(r)) ); + + println!("{:?}", remo.test().await); +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 01d0d4d..f16450f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,17 @@ -mod endianness; -mod prudp; +extern crate self as splatoon_server_rust; + +pub mod endianness; +pub mod prudp; pub mod rmc; //mod protocols; -mod grpc; -mod kerberos; -mod nex; -mod result; -mod versions; -mod web; +pub mod grpc; +pub mod kerberos; +pub mod nex; +pub mod result; +pub mod versions; +pub mod web; +pub mod common; +pub mod reggie; +pub mod rnex_proxy_common; +pub mod util; diff --git a/src/main.rs b/src/main.rs index a052541..68539bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,8 @@ //! also the first and only current usage of rnex, expect this and rnex to be split into seperate //! repos soon. +extern crate self as splatoon_server_rust; + use crate::nex::account::Account; use crate::nex::auth_handler::{AuthHandler, RemoteAuthClientProtocol}; use crate::nex::remote_console::RemoteConsole; @@ -59,6 +61,10 @@ mod nex; mod result; mod versions; mod web; +pub mod reggie; +pub mod util; + + static KERBEROS_SERVER_PASSWORD: Lazy = Lazy::new(|| { env::var("AUTH_SERVER_PASSWORD") @@ -135,7 +141,7 @@ async fn main() { dotenv::dotenv().ok(); - start_servers().await; + //start_servers().await; } /* @@ -278,7 +284,7 @@ async fn start_secure_server() -> SecureServer{ socket, } }*/ - +/* async fn start_auth() -> JoinHandle<()> { tokio::spawn(async { let (router_secure, _) = Router::new(SocketAddrV4::new(*OWN_IP_PRIVATE, *AUTH_SERVER_PORT)) @@ -414,3 +420,4 @@ async fn start_servers() { #[cfg(feature = "secure")] secure_server.await.expect("auth server crashed"); } +*/ \ No newline at end of file diff --git a/src/prudp/packet.rs b/src/prudp/packet.rs index ab72874..2bcd9c9 100644 --- a/src/prudp/packet.rs +++ b/src/prudp/packet.rs @@ -144,7 +144,7 @@ impl Debug for VirtualPort { #[repr(C)] #[derive(Debug, Copy, Clone, Pod, Zeroable, SwapEndian, Eq, PartialEq)] -pub struct PRUDPHeader { +pub struct PRUDPV1Header { pub magic: [u8; 2], pub version: u8, pub packet_specific_size: u8, @@ -157,7 +157,7 @@ pub struct PRUDPHeader { pub sequence_id: u16, } -impl Default for PRUDPHeader{ +impl Default for PRUDPV1Header { fn default() -> Self { Self{ magic: [0xEA, 0xD0], @@ -239,8 +239,8 @@ impl PacketOption{ } #[derive(Debug, Default, Clone, Eq, PartialEq)] -pub struct PRUDPPacket { - pub header: PRUDPHeader, +pub struct PRUDPV1Packet { + pub header: PRUDPV1Header, pub packet_signature: [u8; 16], pub payload: Vec, pub options: Vec, @@ -277,9 +277,9 @@ impl Into for OptionId { } } -impl PRUDPPacket { +impl PRUDPV1Packet { pub fn new(reader: &mut (impl Read + Seek)) -> Result { - let header: PRUDPHeader = reader.read_struct(IS_BIG_ENDIAN)?; + let header: PRUDPV1Header = reader.read_struct(IS_BIG_ENDIAN)?; if header.magic[0] != 0xEA || header.magic[1] != 0xD0 { @@ -372,7 +372,7 @@ impl PRUDPPacket { Self{ - header: PRUDPHeader{ + header: PRUDPV1Header { types_and_flags: flags, sequence_id: self.header.sequence_id, substream_id: self.header.substream_id, @@ -444,7 +444,7 @@ impl PRUDPPacket { pub fn base_response_packet(&self) -> Self { Self { - header: PRUDPHeader { + header: PRUDPV1Header { magic: [0xEA, 0xD0], types_and_flags: TypesFlags(0), destination_port: self.header.source_port, @@ -481,10 +481,10 @@ impl PRUDPPacket { mod test { use crate::prudp::packet::flags::{NEED_ACK, RELIABLE}; use crate::prudp::packet::types::DATA; - use super::{OptionId, PacketOption, PRUDPHeader, TypesFlags, VirtualPort}; + use super::{OptionId, PacketOption, PRUDPV1Header, TypesFlags, VirtualPort}; #[test] fn size_test() { - assert_eq!(size_of::(), 14); + assert_eq!(size_of::(), 14); } #[test] @@ -511,7 +511,7 @@ mod test { #[test] fn header_read(){ - let header = PRUDPHeader{ + let header = PRUDPV1Header { version: 0, destination_port: VirtualPort(0), substream_id: 0, diff --git a/src/prudp/router.rs b/src/prudp/router.rs index 85c2ba2..ce58b90 100644 --- a/src/prudp/router.rs +++ b/src/prudp/router.rs @@ -15,7 +15,7 @@ use tokio::select; use tokio::sync::RwLock; use tokio::time::sleep; use crate::prudp::socket::{new_socket_pair, AnyInternalSocket, CryptoHandler, ExternalSocket}; -use crate::prudp::packet::{PRUDPPacket, VirtualPort}; +use crate::prudp::packet::{PRUDPV1Packet, VirtualPort}; use crate::prudp::router::Error::VirtualPortTaken; static SERVER_DATAGRAMS: Lazy = Lazy::new(||{ @@ -31,6 +31,7 @@ pub struct Router { socket: Arc, _no_outside_construction: PhantomData<()> } + #[derive(Debug, Error)] pub enum Error{ #[error("tried to register socket to a port which is already taken (port: {0})")] @@ -43,7 +44,7 @@ impl Router { let mut stream = Cursor::new(&udp_message); while stream.position() as usize != udp_message.len() { - let packet = match PRUDPPacket::new(&mut stream){ + let packet = match PRUDPV1Packet::new(&mut stream){ Ok(p) => p, Err(e) => { error!("Somebody({}) is fucking with the servers or their connection is bad (reason: {})", addr, e); @@ -155,7 +156,7 @@ impl Router { } // returns Some(()) i - pub(crate) async fn add_socket(&self, virtual_port: VirtualPort, encryption: E) + pub async fn add_socket(&self, virtual_port: VirtualPort, encryption: E) -> Result{ let mut endpoints = self.endpoints.write().await; diff --git a/src/prudp/secure.rs b/src/prudp/secure.rs index 486500f..ecdd70a 100644 --- a/src/prudp/secure.rs +++ b/src/prudp/secure.rs @@ -8,7 +8,7 @@ use typenum::U5; use crate::endianness::{IS_BIG_ENDIAN, ReadExtensions}; use crate::kerberos::{derive_key, TicketInternalData}; use crate::nex::account::Account; -use crate::prudp::packet::PRUDPPacket; +use crate::prudp::packet::PRUDPV1Packet; use crate::prudp::socket::{CryptoHandler, CryptoHandlerConnectionInstance, EncryptionPair}; use crate::prudp::unsecure::UnsecureInstance; use crate::rmc::structures::RmcSerialize; @@ -150,7 +150,7 @@ impl CryptoHandler for Secure { )) } - fn sign_pre_handshake(&self, packet: &mut PRUDPPacket) { + fn sign_pre_handshake(&self, packet: &mut PRUDPV1Packet) { packet.set_sizes(); packet.calculate_and_assign_signature(self.0, None, None); } @@ -176,17 +176,17 @@ impl CryptoHandlerConnectionInstance for SecureInstance { self.pid } - fn sign_connect(&self, packet: &mut PRUDPPacket) { + fn sign_connect(&self, packet: &mut PRUDPV1Packet) { packet.set_sizes(); packet.calculate_and_assign_signature(self.access_key, None, Some(self.self_signature)); } - fn sign_packet(&self, packet: &mut PRUDPPacket) { + fn sign_packet(&self, packet: &mut PRUDPV1Packet) { packet.set_sizes(); packet.calculate_and_assign_signature(self.access_key, Some(self.session_key), Some(self.self_signature)); } - fn verify_packet(&self, packet: &PRUDPPacket) -> bool { + fn verify_packet(&self, packet: &PRUDPV1Packet) -> bool { true } } \ No newline at end of file diff --git a/src/prudp/sockaddr.rs b/src/prudp/sockaddr.rs index fe6a9d8..4e42fcc 100644 --- a/src/prudp/sockaddr.rs +++ b/src/prudp/sockaddr.rs @@ -1,11 +1,13 @@ use std::io::Write; use std::net::SocketAddrV4; use hmac::{Hmac, Mac}; +use macros::RmcSerialize; use crate::prudp::packet::VirtualPort; type Md5Hmac = Hmac; -#[derive(Eq, PartialEq, Hash, Debug, Copy, Clone, Ord, PartialOrd)] +#[derive(Eq, PartialEq, Hash, Debug, Copy, Clone, Ord, PartialOrd, RmcSerialize)] +#[rmc_struct(0)] pub struct PRUDPSockAddr{ pub regular_socket_addr: SocketAddrV4, pub virtual_port: VirtualPort diff --git a/src/prudp/socket.rs b/src/prudp/socket.rs index 5bb08f9..20b4244 100644 --- a/src/prudp/socket.rs +++ b/src/prudp/socket.rs @@ -4,7 +4,7 @@ use crate::prudp::packet::types::{CONNECT, DATA, DISCONNECT, PING, SYN}; use crate::prudp::packet::PacketOption::{ ConnectionSignature, FragmentId, InitialSequenceId, MaximumSubstreamId, SupportedFunctions, }; -use crate::prudp::packet::{PRUDPHeader, PRUDPPacket, PacketOption, TypesFlags, VirtualPort}; +use crate::prudp::packet::{PRUDPV1Header, PRUDPV1Packet, PacketOption, TypesFlags, VirtualPort}; use crate::prudp::router::{Error, Router}; use crate::prudp::sockaddr::PRUDPSockAddr; use async_trait::async_trait; @@ -67,7 +67,7 @@ struct InternalConnection { crypto_handler_instance: E, data_sender: Sender>, socket: Arc, - packet_queue: HashMap, + packet_queue: HashMap, last_packet_time: Instant, } @@ -88,7 +88,7 @@ impl InternalConnection { } #[inline] - async fn send_raw_packet(&self, mut prudp_packet: PRUDPPacket) { + async fn send_raw_packet(&self, mut prudp_packet: PRUDPV1Packet) { prudp_packet.set_sizes(); let mut vec = Vec::new(); @@ -128,7 +128,7 @@ pub(super) struct InternalSocket { internal_connections: Arc< Mutex>>>>, >, - connection_establishment_data_sender: Mutex>>, + connection_establishment_data_sender: Mutex>>, connection_sender: Sender, } @@ -170,7 +170,7 @@ impl Deref for InternalSocket { pub(super) trait AnyInternalSocket: Send + Sync + Deref + 'static { - async fn receive_packet(&self, address: PRUDPSockAddr, packet: PRUDPPacket); + async fn receive_packet(&self, address: PRUDPSockAddr, packet: PRUDPV1Packet); async fn connect(&self, address: PRUDPSockAddr) -> Option<()>; } @@ -186,8 +186,8 @@ pub(super) trait AnyInternalConnection: #[async_trait] impl AnyInternalConnection for InternalConnection { async fn send_data_packet(&mut self, data: Vec) { - let mut packet = PRUDPPacket { - header: PRUDPHeader { + let mut packet = PRUDPV1Packet { + header: PRUDPV1Header { sequence_id: self.next_server_count(), substream_id: 0, session_id: self.session_id, @@ -214,8 +214,8 @@ impl AnyInternalConnection for InternalConne async fn close_connection(&mut self) { // jon confirmed that this should be a safe way to dc a client - let mut packet = PRUDPPacket { - header: PRUDPHeader { + let mut packet = PRUDPV1Packet { + header: PRUDPV1Header { sequence_id: self.next_server_count(), substream_id: 0, session_id: self.session_id, @@ -269,7 +269,7 @@ impl InternalSocket { Some(conn) } - async fn send_packet_unbuffered(&self, dest: PRUDPSockAddr, mut packet: PRUDPPacket) { + async fn send_packet_unbuffered(&self, dest: PRUDPSockAddr, mut packet: PRUDPV1Packet) { packet.set_sizes(); let mut vec = Vec::new(); @@ -284,7 +284,7 @@ impl InternalSocket { .expect("failed to send data back"); } - async fn handle_syn(&self, address: PRUDPSockAddr, packet: PRUDPPacket) { + async fn handle_syn(&self, address: PRUDPSockAddr, packet: PRUDPV1Packet) { info!("got syn"); let mut response = packet.base_response_packet(); @@ -328,8 +328,8 @@ impl InternalSocket { let mut conn = conn.lock().await; if conn.last_packet_time < (Instant::now() - Duration::from_secs(5)) { - conn.send_raw_packet(PRUDPPacket { - header: PRUDPHeader { + conn.send_raw_packet(PRUDPV1Packet { + header: PRUDPV1Header { sequence_id: 0, substream_id: 0, session_id: 0, @@ -408,7 +408,7 @@ impl InternalSocket { .expect("connection to external socket lost"); } - async fn handle_connect(&self, address: PRUDPSockAddr, packet: PRUDPPacket) { + async fn handle_connect(&self, address: PRUDPSockAddr, packet: PRUDPV1Packet) { info!("got connect"); let Some(MaximumSubstreamId(max_substream)) = packet .options @@ -479,7 +479,7 @@ impl InternalSocket { self.send_packet_unbuffered(address, response).await; } - async fn handle_data(&self, address: PRUDPSockAddr, mut packet: PRUDPPacket) { + async fn handle_data(&self, address: PRUDPSockAddr, mut packet: PRUDPV1Packet) { info!("got data"); if packet.header.types_and_flags.get_flags() & (NEED_ACK | RELIABLE) @@ -524,7 +524,7 @@ impl InternalSocket { } } - async fn handle_ping(&self, address: PRUDPSockAddr, packet: PRUDPPacket) { + async fn handle_ping(&self, address: PRUDPSockAddr, packet: PRUDPV1Packet) { let connections = self.internal_connections.lock().await; let Some(conn) = connections.get(&address) else { error!("tried to send data on inactive connection!"); @@ -544,7 +544,7 @@ impl InternalSocket { self.send_packet_unbuffered(address, response).await; } - async fn handle_disconnect(&self, address: PRUDPSockAddr, packet: PRUDPPacket) { + async fn handle_disconnect(&self, address: PRUDPSockAddr, packet: PRUDPV1Packet) { let connections = self.internal_connections.lock().await; let Some(conn) = connections.get(&address) else { error!("tried to send data on inactive connection!"); @@ -571,7 +571,7 @@ impl InternalSocket { #[async_trait] impl AnyInternalSocket for InternalSocket { - async fn receive_packet(&self, address: PRUDPSockAddr, packet: PRUDPPacket) { + async fn receive_packet(&self, address: PRUDPSockAddr, packet: PRUDPV1Packet) { // todo: handle acks and resending if let Some(conn) = self.get_connection(address).await { @@ -643,8 +643,8 @@ impl AnyInternalSocket for InternalSocket { let remote_signature = address.calculate_connection_signature(); - let packet = PRUDPPacket { - header: PRUDPHeader { + let packet = PRUDPV1Packet { + header: PRUDPV1Header { source_port: self.virtual_port, destination_port: address.virtual_port, types_and_flags: TypesFlags::default().types(SYN).flags(NEED_ACK), @@ -674,8 +674,8 @@ impl AnyInternalSocket for InternalSocket { return None; }; - let packet = PRUDPPacket { - header: PRUDPHeader { + let packet = PRUDPV1Packet { + header: PRUDPV1Header { source_port: self.virtual_port, destination_port: address.virtual_port, types_and_flags: TypesFlags::default().types(CONNECT).flags(NEED_ACK), @@ -746,9 +746,9 @@ pub trait CryptoHandlerConnectionInstance: Send + Sync + 'static { fn encrypt_outgoing(&mut self, substream: u8, data: &mut [u8]); fn get_user_id(&self) -> u32; - fn sign_connect(&self, packet: &mut PRUDPPacket); - fn sign_packet(&self, packet: &mut PRUDPPacket); - fn verify_packet(&self, packet: &PRUDPPacket) -> bool; + fn sign_connect(&self, packet: &mut PRUDPV1Packet); + fn sign_packet(&self, packet: &mut PRUDPV1Packet); + fn verify_packet(&self, packet: &PRUDPV1Packet) -> bool; } pub trait CryptoHandler: Send + Sync + 'static { @@ -762,7 +762,7 @@ pub trait CryptoHandler: Send + Sync + 'static { substream_count: u8, ) -> Option<(Vec, Self::CryptoConnectionInstance)>; - fn sign_pre_handshake(&self, packet: &mut PRUDPPacket); + fn sign_pre_handshake(&self, packet: &mut PRUDPV1Packet); } impl Deref for ExternalConnection { @@ -813,6 +813,12 @@ impl SendingConnection { impl Drop for InternalConnection { fn drop(&mut self) { - println!("yatta"); + println!("yatta(internal conn)"); + } +} + +impl Drop for CommonConnection { + fn drop(&mut self) { + println!("yatta(common conn)"); } } diff --git a/src/prudp/unsecure.rs b/src/prudp/unsecure.rs index 12e15ca..6d7d9ff 100644 --- a/src/prudp/unsecure.rs +++ b/src/prudp/unsecure.rs @@ -1,7 +1,7 @@ use once_cell::sync::Lazy; use rc4::{Key, KeyInit, Rc4, StreamCipher}; use typenum::U5; -use crate::prudp::packet::PRUDPPacket; +use crate::prudp::packet::PRUDPV1Packet; use crate::prudp::socket::{CryptoHandler, CryptoHandlerConnectionInstance, EncryptionPair}; pub struct Unsecure(pub &'static str); @@ -43,7 +43,7 @@ impl CryptoHandler for Unsecure { )) } - fn sign_pre_handshake(&self, packet: &mut PRUDPPacket) { + fn sign_pre_handshake(&self, packet: &mut PRUDPV1Packet) { packet.set_sizes(); packet.calculate_and_assign_signature(self.0, None, None); } @@ -68,17 +68,17 @@ impl CryptoHandlerConnectionInstance for UnsecureInstance { 0 } - fn sign_connect(&self, packet: &mut PRUDPPacket) { + fn sign_connect(&self, packet: &mut PRUDPV1Packet) { packet.set_sizes(); packet.calculate_and_assign_signature(self.key, None, Some(self.self_signature)); } - fn sign_packet(&self, packet: &mut PRUDPPacket) { + fn sign_packet(&self, packet: &mut PRUDPV1Packet) { packet.set_sizes(); packet.calculate_and_assign_signature(self.key, None, Some(self.self_signature)); } - fn verify_packet(&self, packet: &PRUDPPacket) -> bool { + fn verify_packet(&self, packet: &PRUDPV1Packet) -> bool { true } } \ No newline at end of file diff --git a/src/reggie.rs b/src/reggie.rs new file mode 100644 index 0000000..449c7dd --- /dev/null +++ b/src/reggie.rs @@ -0,0 +1,144 @@ +use std::{fs, io}; +use std::sync::Arc; +use macros::{method_id, rmc_proto, rmc_struct}; +use once_cell::sync::Lazy; +use rustls::{ClientConfig, RootCertStore, ServerConfig}; +use rustls::client::WebPkiServerVerifier; +use rustls::server::WebPkiClientVerifier; +use rustls_pki_types::{CertificateDer, PrivateKeyDer, ServerName, TrustAnchor}; +use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; +use tokio::net::TcpStream; +use tokio_rustls::{TlsAcceptor, TlsConnector}; +use tokio_rustls::client::TlsStream; +use webpki::anchor_from_trusted_cert; +use crate::define_rmc_proto; +use crate::endianness::IS_BIG_ENDIAN; +use crate::rmc::response::ErrorCode; +use crate::rmc::structures::RmcSerialize; + +pub static SELF_CERT: Lazy> = Lazy::new(|| CertificateDer::from(fs::read("/opt/reggie/certs/SELF.crt").expect("failed to read self cpub ertificate"))); +pub static ROOT_CA: Lazy> = Lazy::new(|| CertificateDer::from(fs::read("/opt/reggie/certs/CA.crt").expect("failed to read root certipub ficate"))); +pub static SELF_KEY: Lazy> = Lazy::new(|| PrivateKeyDer::try_from(fs::read("/opt/reggie/certs/SELF.key").expect("failed to read self pub key")).expect("failed to read self key")); +pub static ROOT_TRUST_ANCHOR: Lazy> = Lazy::new(|| anchor_from_trusted_cert(&*ROOT_CA).expect("unable to create root ca trust anchor")); + + + +pub fn get_root_store() -> RootCertStore { + RootCertStore { + roots: vec![ + ROOT_TRUST_ANCHOR.clone() + ], + } +} + +pub fn get_root_cert_verifier() -> RootCertStore { + RootCertStore { + roots: vec![ + ROOT_TRUST_ANCHOR.clone() + ], + } +} + + +pub async fn get_configured_tls_acceptor() -> TlsAcceptor{ + let store = get_root_store(); + + let cert_verifier = WebPkiClientVerifier::builder(store.into()) + .build() + .expect("unable to build cert verifier"); + + let config = ServerConfig::builder() + //.with_no_client_auth() + .with_client_cert_verifier(cert_verifier) + .with_single_cert(vec![ + SELF_CERT.clone(), + ROOT_CA.clone() + ], SELF_KEY.clone_key()) + .expect("unable to create server config"); + + TlsAcceptor::from(Arc::new(config)) +} + +pub async fn get_configured_tls_connector() -> TlsConnector{ + let store = get_root_store(); + + let cert_verifier = WebPkiServerVerifier::builder(store.into()) + .build() + .expect("unable to build cert verifier"); + + let config = ClientConfig::builder() + //.with_root_certificates(get_root_store()) + .with_webpki_verifier(cert_verifier) + .with_client_auth_cert(vec![ + SELF_CERT.clone(), + ROOT_CA.clone() + ], SELF_KEY.clone_key()) + .expect("unable to create client config"); + + + TlsConnector::from(Arc::new(config)) +} + +pub trait UnitPacketRead: AsyncRead + Unpin{ + async fn read_buffer(&mut self) -> Result, io::Error>{ + let mut len_raw: [u8; 4] = [0; 4]; + + self.read_exact(&mut len_raw).await?; + + let len = u32::from_le_bytes(len_raw); + + let mut vec = vec![0u8; len as _]; + + self.read_exact(&mut vec).await?; + + Ok(vec) + } +} + +impl UnitPacketRead for T{} +pub trait UnitPacketWrite: AsyncWrite + Unpin{ + async fn send_buffer(&mut self, data: &[u8]) -> Result<(), io::Error> { + let mut dest_data = Vec::new(); + + data.serialize(&mut dest_data).expect("ran out of memory or something"); + + self.write_all(&dest_data[..]).await?; + + self.flush().await?; + + Ok(()) + } +} + +impl UnitPacketWrite for T{} + +pub async fn establish_tls_connection_to(address: &str, server_name: &'static str) -> TlsStream{ + let connector = get_configured_tls_connector().await; + + let stream = TcpStream::connect(address).await.unwrap(); + + let stream = connector.connect(ServerName::try_from(server_name).unwrap(), stream).await + .expect("unable to connect via tls"); + + stream +} + +#[rmc_proto(1)] +pub trait RmcTestProto{ + #[method_id(1)] + async fn test(&self) -> Result; +} + +define_rmc_proto!( + proto TestProto{ + RmcTestProto + } +); +#[rmc_struct(TestProto)] +pub struct TestStruct; + +impl RmcTestProto for TestStruct{ + async fn test(&self) -> Result { + Ok("heya".into()) + } +} diff --git a/src/rmc/protocols/mod.rs b/src/rmc/protocols/mod.rs index 53e6c40..9333937 100644 --- a/src/rmc/protocols/mod.rs +++ b/src/rmc/protocols/mod.rs @@ -9,6 +9,7 @@ pub mod nat_traversal; pub mod matchmake_ext; pub mod ranking; +use crate::util::{SendingBufferConnection, SplittableBufferConnection}; use crate::prudp::socket::{ExternalConnection, SendingConnection}; use crate::rmc::message::RMCMessage; use crate::rmc::protocols::RemoteCallError::ConnectionBroke; @@ -45,7 +46,7 @@ pub enum RemoteCallError { InvalidResponse(#[from] structures::Error), } -pub struct RmcConnection(pub SendingConnection, pub RmcResponseReceiver); +pub struct RmcConnection(pub SendingBufferConnection, pub RmcResponseReceiver); pub struct RmcResponseReceiver(Arc, Arc>>); @@ -141,7 +142,7 @@ pub trait RmcCallable { //type Remote: RemoteObject; fn rmc_call( &self, - responder: &SendingConnection, + responder: &SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, @@ -156,7 +157,7 @@ macro_rules! define_rmc_proto { }) => { paste::paste!{ pub trait []: std::any::Any $( + [] + $protocol)* { - async fn rmc_call(&self, remote_response_connection: &crate::prudp::socket::SendingConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ + async fn rmc_call(&self, remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ match protocol_id{ $( []::PROTOCOL_ID => ]>::rmc_call_proto(self, remote_response_connection, method_id, call_id, rest).await, @@ -166,16 +167,16 @@ macro_rules! define_rmc_proto { } } - pub struct [](crate::rmc::protocols::RmcConnection); + pub struct [](splatoon_server_rust::rmc::protocols::RmcConnection); - impl crate::rmc::protocols::RemoteInstantiatable for []{ - fn new(conn: crate::rmc::protocols::RmcConnection) -> Self{ + impl splatoon_server_rust::rmc::protocols::RemoteInstantiatable for []{ + fn new(conn: splatoon_server_rust::rmc::protocols::RmcConnection) -> Self{ Self(conn) } } - impl crate::rmc::protocols::HasRmcConnection for []{ - fn get_connection(&self) -> &crate::rmc::protocols::RmcConnection{ + impl splatoon_server_rust::rmc::protocols::HasRmcConnection for []{ + fn get_connection(&self) -> &splatoon_server_rust::rmc::protocols::RmcConnection{ &self.0 } } @@ -191,7 +192,7 @@ macro_rules! define_rmc_proto { impl RmcCallable for () { async fn rmc_call( &self, - remote_response_connection: &crate::prudp::socket::SendingConnection, + remote_response_connection: &SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, @@ -222,13 +223,13 @@ impl OnlyRemote{ } impl RmcCallable for OnlyRemote{ - fn rmc_call(&self, responder: &SendingConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec) -> impl std::future::Future + Send { + fn rmc_call(&self, responder: &SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec) -> impl std::future::Future + Send { async{} } } async fn handle_incoming( - mut connection: ExternalConnection, + mut connection: SplittableBufferConnection, remote: Arc, notify: Arc, incoming: Arc>>, @@ -278,7 +279,7 @@ async fn handle_incoming( info!("rmc disconnected") } -pub fn new_rmc_gateway_connection(conn: ExternalConnection, create_internal: F) -> Arc +pub fn new_rmc_gateway_connection(conn: SplittableBufferConnection, create_internal: F) -> Arc where F: FnOnce(RmcConnection) -> Arc, { diff --git a/src/rmc/response.rs b/src/rmc/response.rs index f63c345..c49552f 100644 --- a/src/rmc/response.rs +++ b/src/rmc/response.rs @@ -5,7 +5,7 @@ use bytemuck::bytes_of; use log::error; use v_byte_macros::EnumTryInto; use crate::endianness::{ReadExtensions, IS_BIG_ENDIAN}; -use crate::prudp::packet::{PRUDPPacket}; +use crate::prudp::packet::{PRUDPV1Packet}; use crate::prudp::packet::flags::{NEED_ACK, RELIABLE}; use crate::prudp::packet::PacketOption::FragmentId; use crate::prudp::packet::types::DATA; @@ -13,6 +13,8 @@ use crate::prudp::socket::{ExternalConnection, SendingConnection}; use crate::rmc::response::ErrorCode::Core_Exception; use crate::rmc::structures::qresult::ERROR_MASK; use crate::rmc::structures::RmcSerialize; +use crate::util::SendingBufferConnection; + pub enum RMCResponseResult { Success { call_id: u32, @@ -145,7 +147,7 @@ pub fn generate_response(protocol_id: u8, response: RMCResponseResult) -> io::Re } pub async fn send_result( - connection: &SendingConnection, + connection: &SendingBufferConnection, result: Result, ErrorCode>, protocol_id: u8, method_id: u32, @@ -173,7 +175,7 @@ pub async fn send_result( send_response(connection, response).await } -pub async fn send_response(connection: &SendingConnection, rmcresponse: RMCResponse) { +pub async fn send_response(connection: &SendingBufferConnection, rmcresponse: RMCResponse) { connection.send(rmcresponse.to_data()).await; } diff --git a/src/rmc/structures/mod.rs b/src/rmc/structures/mod.rs index d1ed8b3..d6c765c 100644 --- a/src/rmc/structures/mod.rs +++ b/src/rmc/structures/mod.rs @@ -33,10 +33,19 @@ pub mod primitives; pub mod matchmake; pub mod variant; pub mod ranking; +mod networking; pub trait RmcSerialize: Sized{ fn serialize(&self, writer: &mut dyn Write) -> Result<()>; fn deserialize(reader: &mut dyn Read) -> Result; + + fn to_data(&self) -> Vec{ + let mut data = Vec::new(); + + self.serialize(&mut data).expect("out of memory or something"); + + data + } } impl RmcSerialize for (){ @@ -46,4 +55,6 @@ impl RmcSerialize for (){ fn deserialize(reader: &mut dyn Read) -> Result { Ok(()) } + + } \ No newline at end of file diff --git a/src/rmc/structures/networking.rs b/src/rmc/structures/networking.rs new file mode 100644 index 0000000..2218ae9 --- /dev/null +++ b/src/rmc/structures/networking.rs @@ -0,0 +1,32 @@ +use std::io::{Read, Write}; +use std::net::{Ipv4Addr, SocketAddrV4}; +use crate::prudp::packet::VirtualPort; +use crate::rmc::structures::RmcSerialize; + +impl RmcSerialize for SocketAddrV4{ + fn serialize(&self, writer: &mut dyn Write) -> crate::rmc::structures::Result<()> { + self.ip().to_bits().serialize(writer)?; + self.port().serialize(writer)?; + + Ok(()) + } + + fn deserialize(reader: &mut dyn Read) -> crate::rmc::structures::Result { + let ip = u32::deserialize(reader)?; + let port = u16::deserialize(reader)?; + + Ok(SocketAddrV4::new(Ipv4Addr::from_bits(ip), port)) + } +} + +impl RmcSerialize for VirtualPort{ + fn serialize(&self, writer: &mut dyn Write) -> crate::rmc::structures::Result<()> { + self.0.serialize(writer)?; + + Ok(()) + } + + fn deserialize(reader: &mut dyn Read) -> crate::rmc::structures::Result { + Ok(Self(u8::deserialize(reader)?)) + } +} \ No newline at end of file diff --git a/src/rnex_proxy_common.rs b/src/rnex_proxy_common.rs new file mode 100644 index 0000000..a4ee7e6 --- /dev/null +++ b/src/rnex_proxy_common.rs @@ -0,0 +1,10 @@ +use macros::RmcSerialize; +use crate::kerberos::KerberosDateTime; +use crate::prudp::sockaddr::PRUDPSockAddr; + +#[derive(Debug, RmcSerialize)] +#[rmc_struct(0)] +pub struct ConnectionInitData{ + pub prudpsock_addr: PRUDPSockAddr, +} + diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 0000000..03664d8 --- /dev/null +++ b/src/util.rs @@ -0,0 +1,94 @@ +use std::cell::UnsafeCell; +use std::marker::PhantomData; +use std::ops::Deref; +use log::error; +use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::sync::mpsc::{channel, Receiver, Sender}; +use tokio::task; +use splatoon_server_rust::reggie::{UnitPacketRead, UnitPacketWrite}; + +#[derive(Clone)] +pub struct SendingBufferConnection(Sender>); + +pub struct SplittableBufferConnection(SendingBufferConnection, Receiver>); + +impl AsRef for SplittableBufferConnection{ + fn as_ref(&self) -> &SendingBufferConnection { + &self.0 + } +} + +impl Deref for SplittableBufferConnection{ + type Target = SendingBufferConnection; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + + + +impl From for SplittableBufferConnection{ + fn from(value: T) -> Self { + Self::new(value) + } +} + +impl SplittableBufferConnection { + fn new(stream: T) -> Self { + let (outside_send, inside_recv) = channel::>(10); + let (inside_send, outside_recv) = channel::>(10); + + task::spawn(async move { + let sender = inside_send; + let mut recver = inside_recv; + let mut stream = stream; + loop { + tokio::select! { + data = recver.recv() => { + let Some(data) = data else { + break; + }; + + if let Err(e) = stream.send_buffer(&data[..]).await{ + error!("error sending data to backend: {}", e); + break; + } + }, + data = stream.read_buffer() => { + let data = match data{ + Ok(d) => d, + Err(e) => { + error!("error reveiving data from backend: {}", e); + break; + } + }; + + if let Err(e) = sender.send(data).await{ + error!("a send error occurred {}", e); + return; + } + }, + } + } + }); + + Self(SendingBufferConnection(outside_send), outside_recv) + } +} + +impl SendingBufferConnection{ + pub async fn send(&self, buffer: Vec) -> Option<()>{ + self.0.send(buffer).await.ok() + } +} + +impl SplittableBufferConnection{ + pub async fn recv(&mut self) -> Option>{ + self.1.recv().await + } + + pub fn duplicate_sender(&self) -> SendingBufferConnection{ + self.0.clone() + } +} diff --git a/src/web/mod.rs b/src/web/mod.rs index ee43898..16a661b 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -45,7 +45,7 @@ async fn players_in_match(mmm: &State>, gid: u32) -> Optio Some(Json(gathering.connected_players.iter().filter_map(|p| p.upgrade()).map(|p| p.pid).collect())) } - +/* #[get("/player//disconnect")] async fn disconnect_player(_auth: RnexApiAuth, mmm: &State>, pid: u32) -> Option<()>{ // this doesnt work and is broken, there might be some other way to remotely close gatherings... @@ -59,7 +59,7 @@ async fn disconnect_player(_auth: RnexApiAuth, mmm: &State Some(()) -} +}*/ #[get("/gathering//close")] async fn close_gathering(_auth: RnexApiAuth, mmm: &State>, gid: u32) -> Option<()>{ @@ -89,7 +89,7 @@ async fn close_gathering(_auth: RnexApiAuth, mmm: &State>, pub async fn start_web(mgr: Arc) -> JoinHandle<()> { tokio::spawn(async move { rocket::build() - .mount("/", routes![gatherings, players_in_match, close_gathering, disconnect_player]) + .mount("/", routes![gatherings, players_in_match, close_gathering]) .manage(mgr) .launch().await .expect("unable to start webserver"); From 35cee0759194ff19e0935fd573f5bc9c0a8b749c Mon Sep 17 00:00:00 2001 From: DJMrTV Date: Fri, 13 Jun 2025 10:10:04 +0200 Subject: [PATCH 2/4] fix: rename crate to rust_nex --- Cargo.lock | 84 +++++++++++++++---------------- Cargo.toml | 2 +- macros/src/lib.rs | 14 +++--- macros/src/protos.rs | 30 +++++------ src/executables/backend_server.rs | 12 ++--- src/executables/proxy_insecure.rs | 14 +++--- src/lib.rs | 2 +- src/main.rs | 2 +- src/rmc/protocols/mod.rs | 12 ++--- src/util.rs | 2 +- 10 files changed, 87 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c90196..e420127 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2203,6 +2203,48 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rust-nex" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "bytemuck", + "chacha20", + "chrono", + "ctrlc", + "dotenv", + "futures", + "hex", + "hmac", + "json", + "log", + "macros", + "md-5", + "once_cell", + "paste", + "prost", + "rand 0.8.5", + "rc4", + "reqwest", + "rocket", + "rsa", + "rustls", + "rustls-pki-types", + "rustls-webpki", + "serde", + "sha2", + "simplelog", + "thiserror", + "tokio", + "tokio-rustls", + "tokio-stream", + "tonic", + "tonic-build", + "typenum", + "v_byte_macros", +] + [[package]] name = "rustc-demangle" version = "0.1.25" @@ -2483,48 +2525,6 @@ dependencies = [ "der", ] -[[package]] -name = "splatoon-server-rust" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-trait", - "bytemuck", - "chacha20", - "chrono", - "ctrlc", - "dotenv", - "futures", - "hex", - "hmac", - "json", - "log", - "macros", - "md-5", - "once_cell", - "paste", - "prost", - "rand 0.8.5", - "rc4", - "reqwest", - "rocket", - "rsa", - "rustls", - "rustls-pki-types", - "rustls-webpki", - "serde", - "sha2", - "simplelog", - "thiserror", - "tokio", - "tokio-rustls", - "tokio-stream", - "tonic", - "tonic-build", - "typenum", - "v_byte_macros", -] - [[package]] name = "stable-pattern" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 64ffb4b..83c5de6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "splatoon-server-rust" +name = "rust-nex" version = "0.1.0" edition = "2021" diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 122a0a4..835ea6b 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -189,7 +189,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream { quote! { #pre_inner - splatoon_server_rust::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{ + rust_nex::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{ #serialize_base_content })?; @@ -218,7 +218,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream { quote! { #pre_inner - Ok(splatoon_server_rust::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{ + Ok(rust_nex::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{ #deserialize_base_content })?) } @@ -229,14 +229,14 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream { let ident = derive_input.ident; let tokens = quote! { - impl splatoon_server_rust::rmc::structures::RmcSerialize for #ident{ - fn serialize(&self, writer: &mut dyn ::std::io::Write) -> splatoon_server_rust::rmc::structures::Result<()>{ + impl rust_nex::rmc::structures::RmcSerialize for #ident{ + fn serialize(&self, writer: &mut dyn ::std::io::Write) -> rust_nex::rmc::structures::Result<()>{ #serialize_base_content } - fn deserialize(reader: &mut dyn ::std::io::Read) -> splatoon_server_rust::rmc::structures::Result{ + fn deserialize(reader: &mut dyn ::std::io::Read) -> rust_nex::rmc::structures::Result{ #deserialize_base_content } } @@ -367,8 +367,8 @@ pub fn rmc_struct(attr: TokenStream, input: TokenStream) -> TokenStream{ } - impl splatoon_server_rust::rmc::protocols::RmcCallable for #struct_name{ - async fn rmc_call(&self, remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ + impl rust_nex::rmc::protocols::RmcCallable for #struct_name{ + async fn rmc_call(&self, remote_response_connection: &rust_nex::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ ::rmc_call(self, remote_response_connection, protocol_id, method_id, call_id, rest).await; } } diff --git a/macros/src/protos.rs b/macros/src/protos.rs index d7d84c1..8efedb4 100644 --- a/macros/src/protos.rs +++ b/macros/src/protos.rs @@ -73,7 +73,7 @@ impl RmcProtocolData{ for (param_name, param_type) in parameters{ quote!{ let Ok(#param_name) = - <#param_type as splatoon_server_rust::rmc::structures::RmcSerialize>::deserialize( + <#param_type as rust_nex::rmc::structures::RmcSerialize>::deserialize( &mut cursor ) else }.to_tokens(tokens); @@ -84,7 +84,7 @@ impl RmcProtocolData{ quote! { { log::error!(#error_msg); - return Err(splatoon_server_rust::rmc::response::ErrorCode::Core_InvalidArgument); + return Err(rust_nex::rmc::response::ErrorCode::Core_InvalidArgument); }; }.to_tokens(tokens) } else { @@ -116,7 +116,7 @@ impl RmcProtocolData{ quote!{ let retval = retval?; let mut vec = Vec::new(); - splatoon_server_rust::rmc::structures::RmcSerialize::serialize(&retval, &mut vec).ok(); + rust_nex::rmc::structures::RmcSerialize::serialize(&retval, &mut vec).ok(); Ok(vec) }.to_tokens(tokens); } @@ -126,7 +126,7 @@ impl RmcProtocolData{ quote!{ async fn rmc_call_proto( &self, - remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, + remote_response_connection: &rust_nex::util::SendingBufferConnection, method_id: u32, call_id: u32, data: Vec, @@ -165,7 +165,7 @@ impl RmcProtocolData{ }.to_tokens(tokens); if self.has_returns { quote! { - Err(splatoon_server_rust::rmc::response::ErrorCode::Core_NotImplemented) + Err(rust_nex::rmc::response::ErrorCode::Core_NotImplemented) }.to_tokens(tokens); } }); @@ -176,7 +176,7 @@ impl RmcProtocolData{ if *has_returns{ quote!{ - splatoon_server_rust::rmc::response::send_result( + rust_nex::rmc::response::send_result( remote_response_connection, ret, #id, @@ -209,7 +209,7 @@ impl RmcProtocolData{ // boilerplate tokens which all raw traits need quote!{ #[doc(hidden)] - pub trait #remote_name: splatoon_server_rust::rmc::protocols::HasRmcConnection + pub trait #remote_name: rust_nex::rmc::protocols::HasRmcConnection }.to_tokens(tokens); // generate the body of the raw protocol trait @@ -247,12 +247,12 @@ impl RmcProtocolData{ for (param_name, param_type) in parameters{ quote!{ - splatoon_server_rust::result::ResultExtension::display_err_or_some( - <#param_type as splatoon_server_rust::rmc::structures::RmcSerialize>::serialize( + rust_nex::result::ResultExtension::display_err_or_some( + <#param_type as rust_nex::rmc::structures::RmcSerialize>::serialize( &#param_name, &mut cursor ) - ).ok_or(splatoon_server_rust::rmc::response::ErrorCode::Core_InvalidArgument) + ).ok_or(rust_nex::rmc::response::ErrorCode::Core_InvalidArgument) }.to_tokens(tokens); if self.has_returns { quote! { @@ -268,25 +268,25 @@ impl RmcProtocolData{ quote!{ let call_id = rand::random(); - let message = splatoon_server_rust::rmc::message::RMCMessage{ + let message = rust_nex::rmc::message::RMCMessage{ call_id, method_id: #method_id, protocol_id: #proto_id, rest_of_data: send_data }; - let rmc_conn = ::get_connection(self); + let rmc_conn = ::get_connection(self); }.to_tokens(tokens); if *has_returns{ quote!{ - splatoon_server_rust::result::ResultExtension::display_err_or_some( + rust_nex::result::ResultExtension::display_err_or_some( rmc_conn.make_raw_call(&message).await - ).ok_or(splatoon_server_rust::rmc::response::ErrorCode::Core_Exception) + ).ok_or(rust_nex::rmc::response::ErrorCode::Core_Exception) }.to_tokens(tokens); } else { quote!{ - splatoon_server_rust::result::ResultExtension::display_err_or_some( + rust_nex::result::ResultExtension::display_err_or_some( rmc_conn.make_raw_call_no_response(&message).await ); }.to_tokens(tokens); diff --git a/src/executables/backend_server.rs b/src/executables/backend_server.rs index 71da3e2..4dd5d71 100644 --- a/src/executables/backend_server.rs +++ b/src/executables/backend_server.rs @@ -9,8 +9,8 @@ use rustls::{ SignatureScheme, }; use rustls_pki_types::PrivateKeyDer; -use splatoon_server_rust::common::setup; -use splatoon_server_rust::reggie::{get_configured_tls_acceptor, TestStruct, ROOT_TRUST_ANCHOR, SELF_CERT, SELF_KEY}; +use rust_nex::common::setup; +use rust_nex::reggie::{get_configured_tls_acceptor, TestStruct, ROOT_TRUST_ANCHOR, SELF_CERT, SELF_KEY}; use std::borrow::ToOwned; use std::fs; use std::io::Cursor; @@ -21,10 +21,10 @@ use tokio::io::AsyncReadExt; use tokio::net::{TcpListener, TcpSocket}; use tokio::task; use tokio_rustls::TlsAcceptor; -use splatoon_server_rust::define_rmc_proto; -use splatoon_server_rust::rmc::protocols::new_rmc_gateway_connection; -use splatoon_server_rust::rmc::response::ErrorCode; -use splatoon_server_rust::rmc::structures::RmcSerialize; +use rust_nex::define_rmc_proto; +use rust_nex::rmc::protocols::new_rmc_gateway_connection; +use rust_nex::rmc::response::ErrorCode; +use rust_nex::rmc::structures::RmcSerialize; diff --git a/src/executables/proxy_insecure.rs b/src/executables/proxy_insecure.rs index b147163..17454f2 100644 --- a/src/executables/proxy_insecure.rs +++ b/src/executables/proxy_insecure.rs @@ -17,13 +17,13 @@ use rsa::signature::{RandomizedSigner, SignatureEncoding}; use sha2::Sha256; use tokio::net::TcpSocket; use tokio::task; -use splatoon_server_rust::common::setup; -use splatoon_server_rust::prudp::packet::VirtualPort; -use splatoon_server_rust::prudp::router::Router; -use splatoon_server_rust::prudp::unsecure::Unsecure; -use splatoon_server_rust::reggie::{establish_tls_connection_to, UnitPacketRead, UnitPacketWrite}; -use splatoon_server_rust::rmc::structures::RmcSerialize; -use splatoon_server_rust::rnex_proxy_common::ConnectionInitData; +use rust_nex::common::setup; +use rust_nex::prudp::packet::VirtualPort; +use rust_nex::prudp::router::Router; +use rust_nex::prudp::unsecure::Unsecure; +use rust_nex::reggie::{establish_tls_connection_to, UnitPacketRead, UnitPacketWrite}; +use rust_nex::rmc::structures::RmcSerialize; +use rust_nex::rnex_proxy_common::ConnectionInitData; static OWN_IP_PRIVATE: Lazy = Lazy::new(|| { env::var("SERVER_IP") diff --git a/src/lib.rs b/src/lib.rs index f16450f..775b940 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -extern crate self as splatoon_server_rust; +extern crate self as rust_nex; pub mod endianness; pub mod prudp; diff --git a/src/main.rs b/src/main.rs index 68539bf..af9a3bd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ //! also the first and only current usage of rnex, expect this and rnex to be split into seperate //! repos soon. -extern crate self as splatoon_server_rust; +extern crate self as rust_nex; use crate::nex::account::Account; use crate::nex::auth_handler::{AuthHandler, RemoteAuthClientProtocol}; diff --git a/src/rmc/protocols/mod.rs b/src/rmc/protocols/mod.rs index 9333937..6c9b1c3 100644 --- a/src/rmc/protocols/mod.rs +++ b/src/rmc/protocols/mod.rs @@ -157,7 +157,7 @@ macro_rules! define_rmc_proto { }) => { paste::paste!{ pub trait []: std::any::Any $( + [] + $protocol)* { - async fn rmc_call(&self, remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ + async fn rmc_call(&self, remote_response_connection: &rust_nex::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec){ match protocol_id{ $( []::PROTOCOL_ID => ]>::rmc_call_proto(self, remote_response_connection, method_id, call_id, rest).await, @@ -167,16 +167,16 @@ macro_rules! define_rmc_proto { } } - pub struct [](splatoon_server_rust::rmc::protocols::RmcConnection); + pub struct [](rust_nex::rmc::protocols::RmcConnection); - impl splatoon_server_rust::rmc::protocols::RemoteInstantiatable for []{ - fn new(conn: splatoon_server_rust::rmc::protocols::RmcConnection) -> Self{ + impl rust_nex::rmc::protocols::RemoteInstantiatable for []{ + fn new(conn: rust_nex::rmc::protocols::RmcConnection) -> Self{ Self(conn) } } - impl splatoon_server_rust::rmc::protocols::HasRmcConnection for []{ - fn get_connection(&self) -> &splatoon_server_rust::rmc::protocols::RmcConnection{ + impl rust_nex::rmc::protocols::HasRmcConnection for []{ + fn get_connection(&self) -> &rust_nex::rmc::protocols::RmcConnection{ &self.0 } } diff --git a/src/util.rs b/src/util.rs index 03664d8..7556fc2 100644 --- a/src/util.rs +++ b/src/util.rs @@ -5,7 +5,7 @@ use log::error; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::sync::mpsc::{channel, Receiver, Sender}; use tokio::task; -use splatoon_server_rust::reggie::{UnitPacketRead, UnitPacketWrite}; +use rust_nex::reggie::{UnitPacketRead, UnitPacketWrite}; #[derive(Clone)] pub struct SendingBufferConnection(Sender>); From 405a5e1ba141f85d50449523a460c06091792f9f Mon Sep 17 00:00:00 2001 From: DJMrTV Date: Fri, 13 Jun 2025 10:11:05 +0200 Subject: [PATCH 3/4] fix: fix incorrect imports in some places --- src/executables/proxy_secure.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/executables/proxy_secure.rs b/src/executables/proxy_secure.rs index 950680a..dbbafe1 100644 --- a/src/executables/proxy_secure.rs +++ b/src/executables/proxy_secure.rs @@ -1,4 +1,4 @@ -use splatoon_server_rust::reggie::RemoteRmcTestProto; +use rust_nex::reggie::RemoteRmcTestProto; use std::fs; use std::net::IpAddr; use std::sync::Arc; @@ -7,10 +7,10 @@ use rustls_pki_types::ServerName; use tokio::io::AsyncWriteExt; use tokio::net::TcpStream; use tokio_rustls::{TlsConnector, TlsStream}; -use splatoon_server_rust::common::setup; -use splatoon_server_rust::reggie::{establish_tls_connection_to, get_configured_tls_connector, RemoteTestProto, UnitPacketWrite}; -use splatoon_server_rust::rmc::protocols::{new_rmc_gateway_connection, OnlyRemote}; -use splatoon_server_rust::rmc::structures::RmcSerialize; +use rust_nex::common::setup; +use rust_nex::reggie::{establish_tls_connection_to, get_configured_tls_connector, RemoteTestProto, UnitPacketWrite}; +use rust_nex::rmc::protocols::{new_rmc_gateway_connection, OnlyRemote}; +use rust_nex::rmc::structures::RmcSerialize; #[tokio::main] From 29f3ab6348db34a7a56f5ce18b93d48f87d1cc53 Mon Sep 17 00:00:00 2001 From: DJMrTV Date: Fri, 13 Jun 2025 12:36:28 +0200 Subject: [PATCH 4/4] feat: secure proxy should work now as well --- Cargo.toml | 9 +- src/executables/backend_server.rs | 58 ----------- src/executables/backend_server_insecure.rs | 100 ++++++++++++++++++ src/executables/backend_server_secure.rs | 84 ++++++++++++++++ src/executables/common.rs | 29 ++++++ src/executables/mod.rs | 1 + src/executables/proxy_insecure.rs | 27 ++--- src/executables/proxy_secure.rs | 112 +++++++++++++++++---- src/grpc/account.rs | 4 +- src/lib.rs | 1 + src/main.rs | 2 +- src/reggie.rs | 11 +- src/rnex_proxy_common.rs | 2 + 13 files changed, 337 insertions(+), 103 deletions(-) delete mode 100644 src/executables/backend_server.rs create mode 100644 src/executables/backend_server_insecure.rs create mode 100644 src/executables/backend_server_secure.rs create mode 100644 src/executables/common.rs create mode 100644 src/executables/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 83c5de6..9a393b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,5 +75,10 @@ name = "proxy_secure" path = "src/executables/proxy_secure.rs" [[bin]] -name = "backend_server" -path = "src/executables/backend_server.rs" \ No newline at end of file +name = "backend_server_insecure" +path = "src/executables/backend_server_insecure.rs" + + +[[bin]] +name = "backend_server_secure" +path = "src/executables/backend_server_secure.rs" \ No newline at end of file diff --git a/src/executables/backend_server.rs b/src/executables/backend_server.rs deleted file mode 100644 index 4dd5d71..0000000 --- a/src/executables/backend_server.rs +++ /dev/null @@ -1,58 +0,0 @@ -use log::error; -use once_cell::sync::Lazy; -use rustls::client::danger::HandshakeSignatureValid; -use rustls::pki_types::{CertificateDer, TrustAnchor, UnixTime}; -use rustls::server::danger::{ClientCertVerified, ClientCertVerifier}; -use rustls::server::{ClientCertVerifierBuilder, WebPkiClientVerifier}; -use rustls::{ - DigitallySignedStruct, DistinguishedName, Error, RootCertStore, ServerConfig, ServerConnection, - SignatureScheme, -}; -use rustls_pki_types::PrivateKeyDer; -use rust_nex::common::setup; -use rust_nex::reggie::{get_configured_tls_acceptor, TestStruct, ROOT_TRUST_ANCHOR, SELF_CERT, SELF_KEY}; -use std::borrow::ToOwned; -use std::fs; -use std::io::Cursor; -use std::net::{IpAddr, SocketAddr, SocketAddrV4}; -use std::sync::Arc; -use macros::{method_id, rmc_proto, rmc_struct}; -use tokio::io::AsyncReadExt; -use tokio::net::{TcpListener, TcpSocket}; -use tokio::task; -use tokio_rustls::TlsAcceptor; -use rust_nex::define_rmc_proto; -use rust_nex::rmc::protocols::new_rmc_gateway_connection; -use rust_nex::rmc::response::ErrorCode; -use rust_nex::rmc::structures::RmcSerialize; - - - - -#[tokio::main] -async fn main() { - setup(); - - let acceptor = get_configured_tls_acceptor().await; - - let listen = TcpListener::bind("192.168.178.120:2376").await.unwrap(); - - while let Ok((stream, addr)) = listen.accept().await { - let mut stream = match acceptor.accept(stream).await { - Ok(v) => v, - Err(e) => { - error!("an error ocurred whilest accepting tls connection: {:?}", e); - continue; - } - }; - - task::spawn(async move { - new_rmc_gateway_connection(stream.into(), |_| { - Arc::new(TestStruct) - }); - - println!("lost connection lol"); - }); - - } -} diff --git a/src/executables/backend_server_insecure.rs b/src/executables/backend_server_insecure.rs new file mode 100644 index 0000000..6e7f3a3 --- /dev/null +++ b/src/executables/backend_server_insecure.rs @@ -0,0 +1,100 @@ +use rust_nex::reggie::UnitPacketRead; +use log::{error, info}; +use once_cell::sync::Lazy; +use rustls::client::danger::HandshakeSignatureValid; +use rustls::pki_types::{CertificateDer, TrustAnchor, UnixTime}; +use rustls::server::danger::{ClientCertVerified, ClientCertVerifier}; +use rustls::server::{ClientCertVerifierBuilder, WebPkiClientVerifier}; +use rustls::{ + DigitallySignedStruct, DistinguishedName, Error, RootCertStore, ServerConfig, ServerConnection, + SignatureScheme, +}; +use rustls_pki_types::PrivateKeyDer; +use rust_nex::common::setup; +use rust_nex::reggie::{get_configured_tls_acceptor, TestStruct, ROOT_TRUST_ANCHOR, SELF_CERT, SELF_KEY}; +use std::borrow::ToOwned; +use std::{env, fs}; +use std::io::Cursor; +use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4}; +use std::sync::Arc; +use macros::{method_id, rmc_proto, rmc_struct}; +use tokio::io::AsyncReadExt; +use tokio::net::{TcpListener, TcpSocket}; +use tokio::task; +use tokio_rustls::TlsAcceptor; +use rust_nex::define_rmc_proto; +use rust_nex::executables::common::{OWN_IP_PRIVATE, SECURE_SERVER_ACCOUNT, SERVER_PORT}; +use rust_nex::nex::auth_handler::AuthHandler; +use rust_nex::rmc::protocols::new_rmc_gateway_connection; +use rust_nex::rmc::response::ErrorCode; +use rust_nex::rmc::structures::RmcSerialize; +use rust_nex::rnex_proxy_common::ConnectionInitData; + +pub static SECURE_PROXY_ADDR: Lazy = Lazy::new(|| { + env::var("SECURE_PROXY_ADDR") + .ok() + .and_then(|s| s.parse().ok()) + .expect("no secure proxy ip specified") +}); + +pub static SECURE_PROXY_PORT: Lazy = Lazy::new(|| { + env::var("SECURE_PROXY_PORT") + .ok() + .and_then(|s| s.parse().ok()) + .unwrap_or(10000) +}); + +static SECURE_STATION_URL: Lazy = Lazy::new(|| { + format!( + "prudps:/PID=2;sid=1;stream=10;type=2;address={};port={};CID=1", + *SECURE_PROXY_ADDR, *SECURE_PROXY_PORT + ) +}); + +#[tokio::main] +async fn main() { + setup(); + + let acceptor = get_configured_tls_acceptor().await; + + let listen = TcpListener::bind(SocketAddrV4::new(*OWN_IP_PRIVATE, *SERVER_PORT)).await.unwrap(); + + while let Ok((stream, addr)) = listen.accept().await { + let mut stream = match acceptor.accept(stream).await { + Ok(v) => v, + Err(e) => { + error!("an error ocurred whilest accepting tls connection: {:?}", e); + continue; + } + }; + let buffer = match stream.read_buffer().await{ + Ok(v) => v, + Err(e) => { + error!("an error ocurred whilest reading connection data buffer: {:?}", e); + continue; + } + }; + + let user_connection_data = ConnectionInitData::deserialize(&mut Cursor::new(buffer)); + + let user_connection_data = match user_connection_data{ + Ok(v) => v, + Err(e) => { + error!("an error ocurred whilest reading connection data: {:?}", e); + continue; + } + }; + + task::spawn(async move { + info!("connection to secure backend established"); + new_rmc_gateway_connection(stream.into(), |_| { + Arc::new(AuthHandler { + destination_server_acct: &SECURE_SERVER_ACCOUNT, + build_name: "branch:origin/project/wup-agmj build:3_8_15_2004_0", + station_url: &SECURE_STATION_URL, + }) + }); + }); + + } +} diff --git a/src/executables/backend_server_secure.rs b/src/executables/backend_server_secure.rs new file mode 100644 index 0000000..5744e8c --- /dev/null +++ b/src/executables/backend_server_secure.rs @@ -0,0 +1,84 @@ +use std::io::Cursor; +use rust_nex::rmc::structures::RmcSerialize; +use rust_nex::reggie::UnitPacketRead; +use std::net::SocketAddrV4; +use std::sync::Arc; +use std::sync::atomic::AtomicU32; +use log::{error, info}; +use tokio::net::TcpListener; +use tokio::task; +use rust_nex::common::setup; +use rust_nex::executables::common::{OWN_IP_PRIVATE, SERVER_PORT}; +use rust_nex::nex::matchmake::MatchmakeManager; +use rust_nex::nex::remote_console::RemoteConsole; +use rust_nex::nex::user::User; +use rust_nex::reggie::get_configured_tls_acceptor; +use rust_nex::rmc::protocols::new_rmc_gateway_connection; +use rust_nex::rnex_proxy_common::ConnectionInitData; +use rust_nex::rmc::protocols::RemoteInstantiatable; + + +#[tokio::main] +async fn main() { + setup(); + + let acceptor = get_configured_tls_acceptor().await; + + let listen = TcpListener::bind(SocketAddrV4::new(*OWN_IP_PRIVATE, *SERVER_PORT)).await.unwrap(); + + let mmm = Arc::new(MatchmakeManager{ + gid_counter: AtomicU32::new(1), + sessions: Default::default(), + users: Default::default(), + rv_cid_counter: AtomicU32::new(1), + }); + + let weak_mmm = Arc::downgrade(&mmm); + + MatchmakeManager::initialize_garbage_collect_thread(weak_mmm).await; + + while let Ok((stream, addr)) = listen.accept().await { + let mut stream = match acceptor.accept(stream).await { + Ok(v) => v, + Err(e) => { + error!("an error ocurred whilest accepting tls connection: {:?}", e); + continue; + } + }; + + let buffer = match stream.read_buffer().await{ + Ok(v) => v, + Err(e) => { + error!("an error ocurred whilest reading connection data buffer: {:?}", e); + continue; + } + }; + + let user_connection_data = ConnectionInitData::deserialize(&mut Cursor::new(buffer)); + + let user_connection_data = match user_connection_data{ + Ok(v) => v, + Err(e) => { + error!("an error ocurred whilest reading connection data: {:?}", e); + continue; + } + }; + + + let mmm = mmm.clone(); + task::spawn(async move { + info!("connection to secure backend established"); + new_rmc_gateway_connection(stream.into(), |r| { + Arc::new_cyclic(|this| User{ + this: this.clone(), + ip: user_connection_data.prudpsock_addr, + pid: user_connection_data.pid, + remote: RemoteConsole::new(r), + matchmake_manager: mmm, + station_url: Default::default() + }) + }); + }); + + } +} \ No newline at end of file diff --git a/src/executables/common.rs b/src/executables/common.rs new file mode 100644 index 0000000..0b81da8 --- /dev/null +++ b/src/executables/common.rs @@ -0,0 +1,29 @@ +use std::env; +use std::net::Ipv4Addr; +use once_cell::sync::Lazy; +use crate::nex::account::Account; + +pub static OWN_IP_PRIVATE: Lazy = Lazy::new(|| { + env::var("SERVER_IP") + .ok() + .and_then(|s| s.parse().ok()) + .expect("no private ip specified") +}); + +pub static SERVER_PORT: Lazy = Lazy::new(|| { + env::var("SERVER_PORT") + .ok() + .and_then(|s| s.parse().ok()) + .unwrap_or(10000) +}); + +pub static KERBEROS_SERVER_PASSWORD: Lazy = Lazy::new(|| { + env::var("AUTH_SERVER_PASSWORD") + .ok() + .unwrap_or("password".to_owned()) +}); + +pub static AUTH_SERVER_ACCOUNT: Lazy = + Lazy::new(|| Account::new(1, "Quazal Authentication", &KERBEROS_SERVER_PASSWORD)); +pub static SECURE_SERVER_ACCOUNT: Lazy = + Lazy::new(|| Account::new(2, "Quazal Rendez-Vous", &KERBEROS_SERVER_PASSWORD)); diff --git a/src/executables/mod.rs b/src/executables/mod.rs new file mode 100644 index 0000000..ffac467 --- /dev/null +++ b/src/executables/mod.rs @@ -0,0 +1 @@ +pub mod common; \ No newline at end of file diff --git a/src/executables/proxy_insecure.rs b/src/executables/proxy_insecure.rs index 17454f2..5860f13 100644 --- a/src/executables/proxy_insecure.rs +++ b/src/executables/proxy_insecure.rs @@ -1,4 +1,4 @@ -mod proxy_secure; + use std::env; use std::ffi::CStr; @@ -18,6 +18,7 @@ use sha2::Sha256; use tokio::net::TcpSocket; use tokio::task; use rust_nex::common::setup; +use rust_nex::executables::common::{OWN_IP_PRIVATE, SERVER_PORT}; use rust_nex::prudp::packet::VirtualPort; use rust_nex::prudp::router::Router; use rust_nex::prudp::unsecure::Unsecure; @@ -25,25 +26,12 @@ use rust_nex::reggie::{establish_tls_connection_to, UnitPacketRead, UnitPacketWr use rust_nex::rmc::structures::RmcSerialize; use rust_nex::rnex_proxy_common::ConnectionInitData; -static OWN_IP_PRIVATE: Lazy = Lazy::new(|| { - env::var("SERVER_IP") - .ok() - .and_then(|s| s.parse().ok()) - .expect("no public ip specified") -}); -static OWN_IP_PUBLIC: Lazy = - Lazy::new(|| env::var("SERVER_IP_PUBLIC").unwrap_or(OWN_IP_PRIVATE.to_string())); - -static SERVER_PORT: Lazy = Lazy::new(|| { - env::var("AUTH_SERVER_PORT") - .ok() - .and_then(|s| s.parse().ok()) - .unwrap_or(10000) -}); static FORWARD_DESTINATION: Lazy = - Lazy::new(|| env::var("FORWARD_DESTINATION").unwrap_or(OWN_IP_PRIVATE.to_string())); + Lazy::new(|| env::var("FORWARD_DESTINATION").expect("no forward destination given")); +static FORWARD_DESTINATION_NAME: Lazy = + Lazy::new(|| env::var("FORWARD_DESTINATION_NAME").expect("no forward destination name given")); static RSA_PRIVKEY: Lazy = Lazy::new(|| { let path = env::var("RSA_PRIVKEY") @@ -90,10 +78,11 @@ async fn main() { task::spawn(async move { let mut stream - = establish_tls_connection_to("192.168.178.120:2376", "account.spfn.net").await; + = establish_tls_connection_to(FORWARD_DESTINATION.as_str(), FORWARD_DESTINATION_NAME.as_str()).await; if let Err(e) = stream.send_buffer(&ConnectionInitData{ - prudpsock_addr: conn.socket_addr + prudpsock_addr: conn.socket_addr, + pid: conn.user_id }.to_data()).await{ error!("error connecting to backend: {}", e); return; diff --git a/src/executables/proxy_secure.rs b/src/executables/proxy_secure.rs index dbbafe1..2fea0ac 100644 --- a/src/executables/proxy_secure.rs +++ b/src/executables/proxy_secure.rs @@ -1,26 +1,102 @@ -use rust_nex::reggie::RemoteRmcTestProto; -use std::fs; -use std::net::IpAddr; -use std::sync::Arc; -use rustls::ClientConfig; -use rustls_pki_types::ServerName; -use tokio::io::AsyncWriteExt; -use tokio::net::TcpStream; -use tokio_rustls::{TlsConnector, TlsStream}; -use rust_nex::common::setup; -use rust_nex::reggie::{establish_tls_connection_to, get_configured_tls_connector, RemoteTestProto, UnitPacketWrite}; -use rust_nex::rmc::protocols::{new_rmc_gateway_connection, OnlyRemote}; -use rust_nex::rmc::structures::RmcSerialize; +use std::env; +use std::ffi::CStr; +use std::io::{Read, Write}; +use std::net::{Ipv4Addr, SocketAddrV4, TcpListener, TcpStream}; +use bytemuck::{Pod, Zeroable}; +use chacha20::{ChaCha20, Key}; +use chacha20::cipher::{Iv, KeyIvInit, StreamCipher}; +use log::error; +use once_cell::sync::Lazy; +use rsa::pkcs8::{DecodePrivateKey, DecodePublicKey, Document}; +use rsa::{BigUint, Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey}; +use rsa::pkcs1::EncodeRsaPublicKey; +use rsa::pss::BlindedSigningKey; +use rsa::signature::{RandomizedSigner, SignatureEncoding}; +use sha2::Sha256; +use tokio::net::TcpSocket; +use tokio::task; +use rust_nex::common::setup; +use rust_nex::executables::common::{OWN_IP_PRIVATE, SECURE_SERVER_ACCOUNT, SERVER_PORT}; +use rust_nex::prudp::packet::VirtualPort; +use rust_nex::prudp::router::Router; +use rust_nex::prudp::secure::Secure; +use rust_nex::prudp::unsecure::Unsecure; +use rust_nex::reggie::{establish_tls_connection_to, UnitPacketRead, UnitPacketWrite}; +use rust_nex::rmc::structures::RmcSerialize; +use rust_nex::rnex_proxy_common::ConnectionInitData; + + + +static FORWARD_DESTINATION: Lazy = + Lazy::new(|| env::var("FORWARD_DESTINATION").expect("no forward destination given")); +static FORWARD_DESTINATION_NAME: Lazy = + Lazy::new(|| env::var("FORWARD_DESTINATION_NAME").expect("no forward destination name given")); + #[tokio::main] -async fn main(){ +async fn main() { setup(); - let mut stream - = establish_tls_connection_to("192.168.178.120:2376", "account.spfn.net").await; + let (router_secure, _) = Router::new(SocketAddrV4::new(*OWN_IP_PRIVATE, *SERVER_PORT)) + .await + .expect("unable to start router"); - let remo = new_rmc_gateway_connection(stream.into(), |r| Arc::new(OnlyRemote::::new(r)) ); + let mut socket_secure = router_secure + .add_socket(VirtualPort::new(1, 10), Secure( + "6f599f81", + &SECURE_SERVER_ACCOUNT + )) + .await + .expect("unable to add socket"); - println!("{:?}", remo.test().await); + // let conn = socket_secure.connect(auth_sockaddr).await.unwrap(); + + loop { + let Some(mut conn) = socket_secure.accept().await else { + error!("server crashed"); + return; + }; + + task::spawn(async move { + let mut stream + = establish_tls_connection_to(FORWARD_DESTINATION.as_str(), FORWARD_DESTINATION_NAME.as_str()).await; + + if let Err(e) = stream.send_buffer(&ConnectionInitData{ + prudpsock_addr: conn.socket_addr, + pid: conn.user_id + }.to_data()).await{ + error!("error connecting to backend: {}", e); + return; + }; + + loop { + tokio::select! { + data = conn.recv() => { + let Some(data) = data else { + break; + }; + + if let Err(e) = stream.send_buffer(&data[..]).await{ + error!("error sending data to backend: {}", e); + break; + } + }, + data = stream.read_buffer() => { + let data = match data{ + Ok(d) => d, + Err(e) => { + error!("error reveiving data from backend: {}", e); + break; + } + }; + + if conn.send(data).await == None{ + return; + } + }, + } + } + }); + } } \ No newline at end of file diff --git a/src/grpc/account.rs b/src/grpc/account.rs index 0700a7c..4ec4752 100644 --- a/src/grpc/account.rs +++ b/src/grpc/account.rs @@ -20,7 +20,7 @@ use crate::grpc::protobufs::account::{GetNexPasswordRequest, GetUserDataRequest, static API_KEY: Lazy = Lazy::new(||{ let key = env::var("ACCOUNT_GQL_API_KEY") - .expect("no public ip specified"); + .expect("no graphql ip specified"); key }); @@ -29,7 +29,7 @@ static CLIENT_URI: Lazy = Lazy::new(||{ env::var("ACCOUNT_GQL_URL") .ok() .and_then(|s| s.parse().ok()) - .expect("no public ip specified") + .expect("no graphql ip specified") }); diff --git a/src/lib.rs b/src/lib.rs index 775b940..fb941c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,3 +15,4 @@ pub mod common; pub mod reggie; pub mod rnex_proxy_common; pub mod util; +pub mod executables; diff --git a/src/main.rs b/src/main.rs index af9a3bd..34350ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,7 +94,7 @@ static OWN_IP_PRIVATE: Lazy = Lazy::new(|| { env::var("SERVER_IP") .ok() .and_then(|s| s.parse().ok()) - .expect("no public ip specified") + .expect("no private ip specified") }); static OWN_IP_PUBLIC: Lazy = diff --git a/src/reggie.rs b/src/reggie.rs index 449c7dd..9985ec9 100644 --- a/src/reggie.rs +++ b/src/reggie.rs @@ -1,4 +1,4 @@ -use std::{fs, io}; +use std::{env, fs, io}; use std::sync::Arc; use macros::{method_id, rmc_proto, rmc_struct}; use once_cell::sync::Lazy; @@ -16,9 +16,13 @@ use crate::endianness::IS_BIG_ENDIAN; use crate::rmc::response::ErrorCode; use crate::rmc::structures::RmcSerialize; -pub static SELF_CERT: Lazy> = Lazy::new(|| CertificateDer::from(fs::read("/opt/reggie/certs/SELF.crt").expect("failed to read self cpub ertificate"))); +pub static SERVER_NAME: Lazy = Lazy::new(|| { + env::var("REGGIE_SERVER_NAME").expect("no server name specified") +}); + +pub static SELF_CERT: Lazy> = Lazy::new(|| CertificateDer::from(fs::read(&format!("/opt/reggie/certs/{}.crt", SERVER_NAME.as_str())).expect("failed to read self cpub ertificate"))); pub static ROOT_CA: Lazy> = Lazy::new(|| CertificateDer::from(fs::read("/opt/reggie/certs/CA.crt").expect("failed to read root certipub ficate"))); -pub static SELF_KEY: Lazy> = Lazy::new(|| PrivateKeyDer::try_from(fs::read("/opt/reggie/certs/SELF.key").expect("failed to read self pub key")).expect("failed to read self key")); +pub static SELF_KEY: Lazy> = Lazy::new(|| PrivateKeyDer::try_from(fs::read(&format!("/opt/reggie/certs/{}.key", SERVER_NAME.as_str())).expect("failed to read self pub key")).expect("failed to read self key")); pub static ROOT_TRUST_ANCHOR: Lazy> = Lazy::new(|| anchor_from_trusted_cert(&*ROOT_CA).expect("unable to create root ca trust anchor")); @@ -134,6 +138,7 @@ define_rmc_proto!( RmcTestProto } ); + #[rmc_struct(TestProto)] pub struct TestStruct; diff --git a/src/rnex_proxy_common.rs b/src/rnex_proxy_common.rs index a4ee7e6..f04cf3e 100644 --- a/src/rnex_proxy_common.rs +++ b/src/rnex_proxy_common.rs @@ -6,5 +6,7 @@ use crate::prudp::sockaddr::PRUDPSockAddr; #[rmc_struct(0)] pub struct ConnectionInitData{ pub prudpsock_addr: PRUDPSockAddr, + pub pid: u32, + }