From c596a3b7c4d367c6386431adb8b2037ededab1ab Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Sat, 22 Mar 2025 00:13:49 -0400 Subject: [PATCH 01/13] Tests passing --- automap/Cargo.lock | 253 ++++++++++++++++++----- dns_utility/Cargo.lock | 217 ++++++++++++++++--- masq_lib/Cargo.toml | 1 + masq_lib/src/test_utils/utils.rs | 10 +- multinode_integration_tests/Cargo.toml | 2 +- node/Cargo.lock | 275 ++++++++++++++++++++----- node/Cargo.toml | 3 - node/src/proxy_server/mod.rs | 50 +++-- node/src/sub_lib/stream_key.rs | 109 ++++++++-- node/tests/financials_test.rs | 44 +++- node/tests/ui_gateway_test.rs | 83 ++++---- node/tests/utils.rs | 15 +- 12 files changed, 829 insertions(+), 233 deletions(-) diff --git a/automap/Cargo.lock b/automap/Cargo.lock index 73d051ebb..ee7e2ba72 100644 --- a/automap/Cargo.lock +++ b/automap/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666" dependencies = [ "actix_derive", - "bitflags", + "bitflags 1.3.2", "bytes 0.4.12", "crossbeam-channel 0.3.9", "failure", @@ -198,6 +198,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + [[package]] name = "bitvec" version = "0.17.4" @@ -310,7 +316,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "textwrap", "unicode-width", @@ -323,7 +329,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -351,8 +357,8 @@ version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d897f47bf7270cf70d370f8f98c1abb6d2d4cf60a6845d30e05bfb90c6568650" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-xid 0.2.4", ] @@ -485,10 +491,10 @@ dependencies = [ "cc", "codespan-reporting", "once_cell", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "scratch", - "syn 2.0.15", + "syn 2.0.100", ] [[package]] @@ -503,9 +509,9 @@ version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -595,8 +601,8 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "synstructure", ] @@ -662,7 +668,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags", + "bitflags 1.3.2", "fuchsia-zircon-sys", ] @@ -709,6 +715,18 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets 0.52.6", +] + [[package]] name = "gimli" version = "0.27.2" @@ -962,9 +980,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libsecp256k1" @@ -1063,6 +1081,7 @@ dependencies = [ "lazy_static", "log 0.4.17", "nix", + "rand 0.9.0", "regex", "serde", "serde_derive", @@ -1198,7 +1217,7 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 1.0.0", "libc", @@ -1379,9 +1398,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -1403,11 +1422,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ - "proc-macro2 1.0.56", + "proc-macro2 1.0.94", ] [[package]] @@ -1473,6 +1492,17 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -1503,6 +1533,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1536,6 +1576,15 @@ dependencies = [ "getrandom 0.2.9", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.1", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -1637,7 +1686,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1765,9 +1814,9 @@ version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -1890,19 +1939,19 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.15" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-ident", ] @@ -1912,8 +1961,8 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "unicode-xid 0.2.4", ] @@ -1951,9 +2000,9 @@ version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -2445,6 +2494,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.84" @@ -2464,8 +2522,8 @@ dependencies = [ "bumpalo", "log 0.4.17", "once_cell", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "wasm-bindgen-shared", ] @@ -2476,7 +2534,7 @@ version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ - "quote 1.0.26", + "quote 1.0.40", "wasm-bindgen-macro-support", ] @@ -2486,8 +2544,8 @@ version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -2519,7 +2577,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49aec794b07318993d1db16156d5a9c750120597a5ee40c6b928d416186cb138" dependencies = [ "base64 0.10.1", - "bitflags", + "bitflags 1.3.2", "byteorder", "rand 0.6.5", "sha-1", @@ -2586,7 +2644,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", ] [[package]] @@ -2595,13 +2653,29 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2610,42 +2684,90 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winreg" version = "0.5.1" @@ -2655,6 +2777,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.9.0", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -2685,3 +2816,23 @@ name = "yansi" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "zerocopy" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +dependencies = [ + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", +] diff --git a/dns_utility/Cargo.lock b/dns_utility/Cargo.lock index 59f5a3bda..6782f8f6e 100644 --- a/dns_utility/Cargo.lock +++ b/dns_utility/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666" dependencies = [ "actix_derive", - "bitflags", + "bitflags 1.3.2", "bytes", "crossbeam-channel 0.3.9", "failure", @@ -160,6 +160,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + [[package]] name = "bitvec" version = "0.17.4" @@ -245,7 +251,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "textwrap", "unicode-width", @@ -258,7 +264,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -276,8 +282,8 @@ version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d897f47bf7270cf70d370f8f98c1abb6d2d4cf60a6845d30e05bfb90c6568650" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-xid 0.2.4", ] @@ -499,8 +505,8 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "synstructure", ] @@ -541,7 +547,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags", + "bitflags 1.3.2", "fuchsia-zircon-sys", ] @@ -588,6 +594,18 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", +] + [[package]] name = "gimli" version = "0.27.2" @@ -780,9 +798,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libsecp256k1" @@ -866,6 +884,7 @@ dependencies = [ "lazy_static", "log 0.4.17", "nix", + "rand 0.9.0", "regex", "serde", "serde_derive", @@ -1001,7 +1020,7 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 1.0.0", "libc", @@ -1139,9 +1158,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -1163,11 +1182,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ - "proc-macro2 1.0.56", + "proc-macro2 1.0.94", ] [[package]] @@ -1221,6 +1240,17 @@ dependencies = [ "rand_hc 0.2.0", ] +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -1241,6 +1271,16 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1265,6 +1305,15 @@ dependencies = [ "getrandom 0.1.16", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.1", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -1357,7 +1406,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1479,9 +1528,9 @@ version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -1604,19 +1653,19 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.15" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-ident", ] @@ -1626,8 +1675,8 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.109", "unicode-xid 0.2.4", ] @@ -1638,7 +1687,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd4bc0637a2b8c0b1a5145cca3e21b707865edc7e32285771536af1ade129468" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -1677,9 +1726,9 @@ version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", ] [[package]] @@ -2160,6 +2209,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "websocket" version = "0.26.5" @@ -2180,7 +2238,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49aec794b07318993d1db16156d5a9c750120597a5ee40c6b928d416186cb138" dependencies = [ "base64 0.10.1", - "bitflags", + "bitflags 1.3.2", "byteorder", "rand 0.6.5", "sha-1", @@ -2232,6 +2290,70 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winreg" version = "0.5.1" @@ -2259,6 +2381,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.9.0", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -2268,3 +2399,23 @@ dependencies = [ "winapi 0.2.8", "winapi-build", ] + +[[package]] +name = "zerocopy" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +dependencies = [ + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", +] diff --git a/masq_lib/Cargo.toml b/masq_lib/Cargo.toml index af1fd5d15..7fbcfb9f8 100644 --- a/masq_lib/Cargo.toml +++ b/masq_lib/Cargo.toml @@ -25,6 +25,7 @@ time = {version = "0.3.11", features = [ "formatting" ]} tiny-hderive = "0.3.0" toml = "0.5.8" websocket = {version = "0.26.2", default-features = false, features = ["sync"]} +rand = { version = "0.9.0", features = ["thread_rng"] } [features] no_test_share = [] diff --git a/masq_lib/src/test_utils/utils.rs b/masq_lib/src/test_utils/utils.rs index fa279a4f4..98c91f7c6 100644 --- a/masq_lib/src/test_utils/utils.rs +++ b/masq_lib/src/test_utils/utils.rs @@ -5,9 +5,10 @@ use crate::test_utils::environment_guard::EnvironmentGuard; use serde_derive::Serialize; use std::fs; use std::path::{Path, PathBuf}; +use std::process::Command; use std::time::Duration; -pub const TEST_DEFAULT_CHAIN: Chain = Chain::EthRopsten; +pub const TEST_DEFAULT_CHAIN: Chain = Chain::BaseSepolia; pub const TEST_DEFAULT_MULTINODE_CHAIN: Chain = Chain::Dev; pub const BASE_TEST_DIR: &str = "generated/test"; const MASQ_SOURCE_CODE_UNAVAILABLE: &str = "MASQ_SOURCE_CODE_UNAVAILABLE"; @@ -49,6 +50,13 @@ pub fn ensure_node_home_directory_exists(module: &str, name: &str) -> PathBuf { home_dir } +pub fn open_all_file_permissions(dir: PathBuf) { + let _ = Command::new("chmod") + .args(&["-R", "777", dir.to_str().unwrap()]) + .output() + .expect("Couldn't chmod 777 files in directory"); +} + pub fn is_running_under_github_actions() -> bool { is_env_variable_set("GITHUB_ACTIONS", "true") } diff --git a/multinode_integration_tests/Cargo.toml b/multinode_integration_tests/Cargo.toml index 18bb5a16d..0030df977 100644 --- a/multinode_integration_tests/Cargo.toml +++ b/multinode_integration_tests/Cargo.toml @@ -18,7 +18,7 @@ lazy_static = "1.4.0" log = "0.4.14" masq_lib = { path = "../masq_lib" } native-tls = "0.2.8" -node = { path = "../node", features = [ "expose_test_privates" ] } +node = { path = "../node" } pretty-hex = "0.2.1" primitive-types = {version = "0.5.0", default-features = false, features = ["default", "rlp", "serde"] } regex = "1.5.4" diff --git a/node/Cargo.lock b/node/Cargo.lock index 63e2b2029..30552a3da 100644 --- a/node/Cargo.lock +++ b/node/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666" dependencies = [ "actix_derive", - "bitflags", + "bitflags 1.2.1", "bytes 0.4.12", "crossbeam-channel 0.3.9", "failure", @@ -259,6 +259,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + [[package]] name = "bitvec" version = "0.17.4" @@ -399,7 +405,7 @@ checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.2.1", "strsim", "textwrap", "unicode-width", @@ -412,7 +418,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.2.1", ] [[package]] @@ -430,8 +436,8 @@ version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-xid 0.2.1", ] @@ -689,8 +695,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" dependencies = [ "convert_case", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "rustc_version 0.3.3", "syn 1.0.85", ] @@ -880,8 +886,8 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "synstructure", ] @@ -1025,7 +1031,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags", + "bitflags 1.2.1", "fuchsia-zircon-sys", ] @@ -1132,6 +1138,18 @@ dependencies = [ "wasi 0.10.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", +] + [[package]] name = "gimli" version = "0.23.0" @@ -1644,9 +1662,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.145" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libsecp256k1" @@ -1834,6 +1852,7 @@ dependencies = [ "lazy_static", "log 0.4.18", "nix 0.23.1", + "rand 0.9.0", "regex", "serde", "serde_derive", @@ -1987,7 +2006,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3b281c45a2dbb0609b854de9df94694fb77eab2fa2933c07d07001dcb29377" dependencies = [ - "bitflags", + "bitflags 1.2.1", "libc", "nix 0.23.1", "smallstr", @@ -2071,7 +2090,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" dependencies = [ - "bitflags", + "bitflags 1.2.1", "cc", "cfg-if 1.0.0", "libc", @@ -2084,7 +2103,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694" dependencies = [ - "bitflags", + "bitflags 1.2.1", "cfg-if 1.0.0", "libc", "static_assertions 1.1.0", @@ -2308,7 +2327,7 @@ version = "0.10.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" dependencies = [ - "bitflags", + "bitflags 1.2.1", "cfg-if 1.0.0", "foreign-types", "libc", @@ -2539,8 +2558,8 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b95af56fee93df76d721d356ac1ca41fccf168bc448eb14049234df764ba3e76" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", ] @@ -2570,9 +2589,12 @@ checksum = "325a6d2ac5dee293c3b2612d4993b98aec1dff096b0a2dae70ed7d95784a05da" [[package]] name = "ppv-lite86" -version = "0.2.9" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] [[package]] name = "pretty-hex" @@ -2629,9 +2651,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -2653,11 +2675,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ - "proc-macro2 1.0.59", + "proc-macro2 1.0.94", ] [[package]] @@ -2734,6 +2756,17 @@ dependencies = [ "rand_hc 0.3.1", ] +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -2764,6 +2797,16 @@ dependencies = [ "rand_core 0.6.3", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -2797,6 +2840,15 @@ dependencies = [ "getrandom 0.2.3", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.1", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -2932,7 +2984,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ - "bitflags", + "bitflags 1.2.1", ] [[package]] @@ -3052,7 +3104,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" dependencies = [ - "bitflags", + "bitflags 1.2.1", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -3194,7 +3246,7 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" dependencies = [ - "bitflags", + "bitflags 1.2.1", "core-foundation 0.9.2", "core-foundation-sys 0.8.3", "libc", @@ -3269,8 +3321,8 @@ version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", ] @@ -3314,8 +3366,8 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", ] @@ -3532,19 +3584,30 @@ version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "unicode-xid 0.2.1", ] +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2 1.0.94", + "quote 1.0.40", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "unicode-xid 0.2.1", ] @@ -3570,7 +3633,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd4bc0637a2b8c0b1a5145cca3e21b707865edc7e32285771536af1ade129468" dependencies = [ - "bitflags", + "bitflags 1.2.1", "core-foundation 0.7.0", "system-configuration-sys", ] @@ -3636,8 +3699,8 @@ version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", ] @@ -4334,7 +4397,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae2faf80ac463422992abf4de234731279c058aaf33171ca70277c98406b124" dependencies = [ - "quote 1.0.28", + "quote 1.0.40", "syn 1.0.85", ] @@ -4395,6 +4458,15 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.78" @@ -4414,8 +4486,8 @@ dependencies = [ "bumpalo", "lazy_static", "log 0.4.18", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "wasm-bindgen-shared", ] @@ -4438,7 +4510,7 @@ version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ - "quote 1.0.28", + "quote 1.0.40", "wasm-bindgen-macro-support", ] @@ -4448,8 +4520,8 @@ version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -4527,7 +4599,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "403f3fd505ff930da84156389639932955fb09705b3dccd1a3d60c8e7ff62776" dependencies = [ "base64 0.10.1", - "bitflags", + "bitflags 1.2.1", "byteorder", "bytes 0.4.12", "futures", @@ -4596,13 +4668,29 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.0", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm 0.42.0", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -4611,42 +4699,90 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winreg" version = "0.5.1" @@ -4683,6 +4819,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.9.0", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -4714,6 +4859,26 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" +[[package]] +name = "zerocopy" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +dependencies = [ + "proc-macro2 1.0.94", + "quote 1.0.40", + "syn 2.0.100", +] + [[package]] name = "zeroize" version = "1.4.3" @@ -4729,8 +4894,8 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65f1a51723ec88c66d5d1fe80c841f17f63587d6691901d66be9bec6c3b51f73" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.94", + "quote 1.0.40", "syn 1.0.85", "synstructure", ] diff --git a/node/Cargo.toml b/node/Cargo.toml index 7d01fd728..93f2dcde1 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -99,8 +99,5 @@ path = "src/main_win.rs" name = "node_lib" path = "src/lib.rs" -[features] -expose_test_privates = [] - #[profile.release] #opt-level = 0 \ No newline at end of file diff --git a/node/src/proxy_server/mod.rs b/node/src/proxy_server/mod.rs index 372b52c37..d830156a8 100644 --- a/node/src/proxy_server/mod.rs +++ b/node/src/proxy_server/mod.rs @@ -565,7 +565,7 @@ impl ProxyServer { let http_data = HttpProtocolPack {}.find_host(&msg.data.clone().into()); match http_data { Some(ref host) if host.port == Some(443) => { - let stream_key = self.find_or_generate_stream_key(msg); + let stream_key = self.find_or_generate_stream_key(msg, msg.peer_addr); self.tunneled_hosts.insert(stream_key, host.name.clone()); self.subs .as_ref() @@ -642,23 +642,31 @@ impl ProxyServer { } } - fn find_or_generate_stream_key(&mut self, ibcd: &InboundClientData) -> StreamKey { + fn find_or_generate_stream_key( + &mut self, + ibcd: &InboundClientData, + server_addr: SocketAddr, + ) -> StreamKey { match self.keys_and_addrs.b_to_a(&ibcd.peer_addr) { Some(stream_key) => { debug!( self.logger, - "make_stream_key() retrieved existing key {} for {}", + "find_or_generate_stream_key() retrieved existing key {} for {}", &stream_key, ibcd.peer_addr ); stream_key } None => { - let stream_key = self.stream_key_factory.make(); + let stream_key = self + .stream_key_factory + .make(self.main_cryptde.public_key(), server_addr); self.keys_and_addrs.insert(stream_key, ibcd.peer_addr); debug!( self.logger, - "make_stream_key() inserted new key {} for {}", &stream_key, ibcd.peer_addr + "find_or_generate_stream_key() inserted new key {} for {}", + &stream_key, + ibcd.peer_addr ); stream_key } @@ -1131,7 +1139,7 @@ impl IBCDHelper for IBCDHelperReal { .expect("Dispatcher is dead"); return Err("Browser request rejected due to missing consuming wallet".to_string()); } - let stream_key = proxy.find_or_generate_stream_key(&msg); + let stream_key = proxy.find_or_generate_stream_key(&msg, source_addr); let timestamp = msg.timestamp; let payload = match proxy.make_payload(msg, &stream_key) { Ok(payload) => { @@ -1267,14 +1275,14 @@ enum ExitServiceSearch { } trait StreamKeyFactory: Send { - fn make(&self) -> StreamKey; + fn make(&self, public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey; } struct StreamKeyFactoryReal {} impl StreamKeyFactory for StreamKeyFactoryReal { - fn make(&self) -> StreamKey { - StreamKey::new() + fn make(&self, public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey { + StreamKey::new(public_key, server_addr) } } @@ -1499,13 +1507,16 @@ mod tests { } struct StreamKeyFactoryMock { - make_parameters: Arc>>, + make_parameters: Arc>>, make_results: RefCell>, } impl StreamKeyFactory for StreamKeyFactoryMock { - fn make(&self) -> StreamKey { - self.make_parameters.lock().unwrap().push(()); + fn make(&self, public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey { + self.make_parameters + .lock() + .unwrap() + .push((public_key.clone(), server_addr)); self.make_results.borrow_mut().remove(0) } } @@ -1518,7 +1529,10 @@ mod tests { } } - fn make_parameters(mut self, params: &Arc>>) -> StreamKeyFactoryMock { + fn make_parameters( + mut self, + params: &Arc>>, + ) -> StreamKeyFactoryMock { self.make_parameters = params.clone(); self } @@ -1693,7 +1707,10 @@ mod tests { let record = recording.get_record::(0); assert_eq!(record, &expected_pkg); let mut make_parameters = make_parameters_arc_a.lock().unwrap(); - assert_eq!(make_parameters.remove(0), ()); + assert_eq!( + make_parameters.remove(0), + (main_cryptde.public_key().clone(), socket_addr) + ); let recording = neighborhood_recording_arc.lock().unwrap(); let record = recording.get_record::(0); assert_eq!( @@ -1809,7 +1826,10 @@ mod tests { let dispatcher_record = dispatcher_recording.get_record::(0); assert_eq!(dispatcher_record, &expected_tdm); let mut make_parameters = make_parameters_arc.lock().unwrap(); - assert_eq!(make_parameters.remove(0), ()); + assert_eq!( + make_parameters.remove(0), + (main_cryptde.public_key().clone(), socket_addr) + ); let hopper_recording = hopper_recording_arc.lock().unwrap(); let hopper_record = hopper_recording.get_record::(0); diff --git a/node/src/sub_lib/stream_key.rs b/node/src/sub_lib/stream_key.rs index f50f67b5d..1535ee77c 100644 --- a/node/src/sub_lib/stream_key.rs +++ b/node/src/sub_lib/stream_key.rs @@ -1,12 +1,23 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. +use crate::sub_lib::cryptde::PublicKey; +use lazy_static::lazy_static; use serde::de::Visitor; use serde::Deserialize; use serde::Deserializer; use serde::Serialize; use serde::Serializer; +use sodiumoxide::randombytes::randombytes_into; use std::fmt; -use uuid::Uuid; +use std::net::SocketAddr; + +lazy_static! { + static ref STREAM_KEY_SALT: [u8; 8] = { + let mut salt = [0; 8]; + randombytes_into(&mut salt); + salt + }; +} #[derive(Hash, PartialEq, Eq, Clone, Copy)] pub struct StreamKey { @@ -72,18 +83,12 @@ impl<'a> Visitor<'a> for StreamKeyVisitor { } } -impl Default for StreamKey { - fn default() -> Self { - Self::new() - } -} - impl StreamKey { - pub fn new() -> StreamKey { + pub fn new(public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey { let mut hash = sha1::Sha1::new(); - let uuid = Uuid::new_v4(); - let uuid_bytes: &[u8] = uuid.as_bytes(); - hash.update(uuid_bytes); + hash.update(public_key.as_ref()); + hash = add_socket_addr_to_hash(hash, server_addr); + hash.update(STREAM_KEY_SALT.as_slice()); StreamKey { hash: hash.digest().bytes(), } @@ -106,21 +111,87 @@ impl StreamKey { type HashType = [u8; sha1::DIGEST_LENGTH]; +fn add_socket_addr_to_hash(mut hash: sha1::Sha1, socket_addr: SocketAddr) -> sha1::Sha1 { + match socket_addr { + SocketAddr::V4(v4) => { + hash.update(v4.ip().octets().as_slice()); + } + SocketAddr::V6(v6) => { + hash.update(v6.ip().octets().as_slice()); + } + } + let port = socket_addr.port(); + hash.update(&[(port & 0xFF) as u8, (port >> 8) as u8]); + hash +} + #[cfg(test)] mod tests { use super::*; - use std::collections::HashSet; + use crate::test_utils::main_cryptde; + use itertools::Itertools; + use std::net::IpAddr; + use std::str::FromStr; #[test] - fn stream_keys_are_unique() { - let mut stream_keys_set = HashSet::new(); + fn stream_keys_with_different_server_addrs_are_different() { + let public_key = main_cryptde().public_key(); + let stream_key_count = 100; + let ip_addr = IpAddr::from_str("1.2.3.4").unwrap(); + let server_addrs = (0..stream_key_count).map(|i| SocketAddr::new(ip_addr, 1024 + i as u16)); + + let stream_keys = server_addrs + .map(|server_addr| StreamKey::new(&public_key, server_addr)) + .collect_vec(); + + (0..(stream_key_count - 1)).for_each(|a| { + ((a + 1)..stream_key_count).for_each(|b| { + assert_ne!(stream_keys[a], stream_keys[b]); + }); + }); + } - for i in 1..=1_000 { - let stream_key = StreamKey::default(); - let is_unique = stream_keys_set.insert(stream_key); + #[test] + fn stream_keys_with_same_host_name_are_same() { + let public_key = main_cryptde().public_key(); + let stream_key_count = 100; + let server_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); + + let stream_keys = (0..stream_key_count) + .map(|_| StreamKey::new(&public_key, server_addr)) + .collect_vec(); + + (1..stream_key_count).for_each(|i| { + assert_eq!(stream_keys[i], stream_keys[0]); + }); + } - assert!(is_unique, "{}", &format!("Stream key {i} is not unique")); - } + #[test] + fn stream_keys_from_different_public_keys_are_different() { + let server_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); + + let stream_keys = vec![PublicKey::new(&[1, 2, 3]), PublicKey::new(&[1, 2, 2])] + .iter() + .map(|public_key| StreamKey::new(public_key, server_addr)) + .collect_vec(); + + assert_ne!(stream_keys[0], stream_keys[1]); + } + + #[test] + fn stream_keys_are_salted() { + let public_key = main_cryptde().public_key(); + let server_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); + + let result = StreamKey::new(&public_key, server_addr); + + let mut hash = sha1::Sha1::new(); + hash.update(public_key.as_ref()); + hash = add_socket_addr_to_hash(hash, server_addr); + let attack = StreamKey { + hash: hash.digest().bytes(), + }; + assert_ne!(attack, result) } #[test] diff --git a/node/tests/financials_test.rs b/node/tests/financials_test.rs index 0874cb39b..a3b2da5bc 100644 --- a/node/tests/financials_test.rs +++ b/node/tests/financials_test.rs @@ -8,7 +8,7 @@ use masq_lib::messages::{ UiShutdownRequest, NODE_UI_PROTOCOL, }; use masq_lib::test_utils::ui_connection::UiConnection; -use masq_lib::test_utils::utils::ensure_node_home_directory_exists; +use masq_lib::test_utils::utils::{ensure_node_home_directory_exists, open_all_file_permissions}; use masq_lib::utils::find_free_port; use node_lib::accountant::db_access_objects::payable_dao::{PayableDao, PayableDaoReal}; use node_lib::accountant::db_access_objects::receivable_dao::{ReceivableDao, ReceivableDaoReal}; @@ -16,15 +16,19 @@ use node_lib::accountant::db_access_objects::utils::{from_time_t, to_time_t}; use node_lib::accountant::gwei_to_wei; use node_lib::test_utils::make_wallet; use std::time::SystemTime; +use masq_lib::constants::POLYGON_MAINNET_FULL_IDENTIFIER; +use node_lib::database::db_initializer::{DbInitializationConfig, DbInitializer, DbInitializerReal}; +use node_lib::db_config::config_dao::{ConfigDao, ConfigDaoReal}; use utils::MASQNode; #[test] -fn financials_command_retrieves_payable_and_receivable_records() { +fn financials_command_retrieves_payable_and_receivable_records_integration() { fdlimit::raise_fd_limit(); + let test_name = "financials_command_retrieves_payable_and_receivable_records_integration"; let port = find_free_port(); let home_dir = ensure_node_home_directory_exists( - "financials_test", - "financials_command_retrieves_payable_and_receivable_records", + "integration", + test_name, ); let now = SystemTime::now(); let timestamp_payable = from_time_t(to_time_t(now) - 678); @@ -36,6 +40,16 @@ fn financials_command_retrieves_payable_and_receivable_records() { let amount_payable = gwei_to_wei(45678357_u64); let amount_receivable_1 = gwei_to_wei(9000_u64); let amount_receivable_2 = gwei_to_wei(345678_u64); + { + let db_initializer = DbInitializerReal{}; + let conn = db_initializer.initialize( + &home_dir, + DbInitializationConfig::test_default() + ).unwrap(); + let config_dao = ConfigDaoReal::new(conn); + config_dao.set("chain_name", Some (POLYGON_MAINNET_FULL_IDENTIFIER.to_string())).unwrap(); + } + open_all_file_permissions(home_dir.clone()); PayableDaoReal::new(make_conn(&home_dir)) .more_money_payable(timestamp_payable, &wallet_payable, amount_payable) .unwrap(); @@ -55,7 +69,7 @@ fn financials_command_retrieves_payable_and_receivable_records() { ) .unwrap(); let mut node = MASQNode::start_standard( - "financials_command_retrieves_payable_and_receivable_records", + test_name, Some(CommandConfig::new().pair("--ui-port", &port.to_string())), false, true, @@ -78,22 +92,30 @@ fn financials_command_retrieves_payable_and_receivable_records() { let after = SystemTime::now(); assert_eq!(response.stats_opt, None); +eprintln! ("response: {:?}", response); let query_results = response.query_results_opt.unwrap(); let payable = query_results.payable_opt.unwrap(); let receivable = query_results.receivable_opt.unwrap(); assert_eq!(payable[0].wallet, wallet_payable.to_string()); assert_eq!(payable[0].balance_gwei, 45678357_u64); assert_eq!(payable[0].pending_payable_hash_opt, None); - assert_eq!(receivable[0].wallet, wallet_receivable_1.to_string()); - assert_eq!(receivable[0].balance_gwei, 9000_i64); - assert_eq!(receivable[1].wallet, wallet_receivable_2.to_string()); - assert_eq!(receivable[1].balance_gwei, 345678_i64); let act_period = after.duration_since(before).unwrap().as_secs(); let age_payable = payable[0].age_s; assert!(age_payable >= 678 && age_payable <= (age_payable + act_period)); - let age_receivable_1 = receivable[0].age_s; + let receivable_indexes = if receivable[0].wallet == wallet_receivable_1.to_string() { + vec![0, 1] + } else { + vec![1, 0] + }; + let first_receivable = &receivable[receivable_indexes[0]]; + let second_receivable = &receivable[receivable_indexes[1]]; + assert_eq!(first_receivable.wallet, wallet_receivable_1.to_string()); + assert_eq!(first_receivable.balance_gwei, 9000_i64); + let age_receivable_1 = first_receivable.age_s; assert!(age_receivable_1 >= 10000 && age_receivable_1 <= (age_receivable_1 + act_period)); - let age_receivable_2 = receivable[1].age_s; + assert_eq!(second_receivable.wallet, wallet_receivable_2.to_string()); + assert_eq!(second_receivable.balance_gwei, 345678_i64); + let age_receivable_2 = second_receivable.age_s; assert!(age_receivable_2 >= 1111 && age_receivable_2 <= (age_receivable_2 + act_period)); client.send(UiShutdownRequest {}); node.wait_for_exit(); diff --git a/node/tests/ui_gateway_test.rs b/node/tests/ui_gateway_test.rs index 042cfda42..1e182a325 100644 --- a/node/tests/ui_gateway_test.rs +++ b/node/tests/ui_gateway_test.rs @@ -15,43 +15,6 @@ use masq_lib::test_utils::utils::ensure_node_home_directory_exists; use masq_lib::utils::{add_chain_specific_directory, find_free_port}; use utils::CommandConfig; -#[test] -fn ui_requests_something_and_gets_corresponding_response() { - fdlimit::raise_fd_limit(); - let port = find_free_port(); - let home_dir = ensure_node_home_directory_exists( - "ui_gateway_test", - "ui_requests_something_and_gets_corresponding_response", - ); - let mut node = utils::MASQNode::start_standard( - "ui_requests_something_and_gets_corresponding_response", - Some( - CommandConfig::new() - .pair("--ui-port", &port.to_string()) - .pair( - "--data-directory", - home_dir.into_os_string().to_str().unwrap(), - ), - ), - true, - true, - false, - true, - ); - node.wait_for_log("UIGateway bound", Some(5000)); - let check_password_request = UiCheckPasswordRequest { - db_password_opt: None, - }; - let mut client = UiConnection::new(port, NODE_UI_PROTOCOL); - - client.send(check_password_request); - let response: UiCheckPasswordResponse = client.skip_until_received().unwrap(); - - assert_eq!(response, UiCheckPasswordResponse { matches: true }); - client.send(UiShutdownRequest {}); - node.wait_for_exit(); -} - #[test] fn log_broadcasts_are_correctly_received_integration() { fdlimit::raise_fd_limit(); @@ -98,14 +61,15 @@ fn daemon_does_not_allow_node_to_keep_his_client_alive_integration() { //for the Daemon's client, so we need to make the Daemon send a close message //breaking any reference to him immediately fdlimit::raise_fd_limit(); + let test_name = "daemon_does_not_allow_node_to_keep_his_client_alive_integration"; let data_directory = ensure_node_home_directory_exists( "ui_gateway_test", - "daemon_does_not_allow_node_to_keep_his_client_alive_integration", + test_name, ); let expected_chain_data_dir = add_chain_specific_directory(DEFAULT_CHAIN, &data_directory); let daemon_port = find_free_port(); let mut daemon = utils::MASQNode::start_daemon( - "daemon_does_not_allow_node_to_keep_his_client_alive_integration", + test_name, Some(CommandConfig::new().pair("--ui-port", daemon_port.to_string().as_str())), true, true, @@ -172,9 +136,10 @@ fn daemon_does_not_allow_node_to_keep_his_client_alive_integration() { #[test] fn cleanup_after_deceased_clients_integration() { fdlimit::raise_fd_limit(); + let test_name = "cleanup_after_deceased_clients_integration"; let port = find_free_port(); let mut node = utils::MASQNode::start_standard( - "cleanup_after_deceased_clients_integration", + test_name, Some( CommandConfig::new() .pair("--chain", DEFAULT_CHAIN.rec().literal_identifier) @@ -211,3 +176,41 @@ fn cleanup_after_deceased_clients_integration() { client_2.send(UiShutdownRequest {}); node.wait_for_exit(); } + +#[test] +fn ui_requests_something_and_gets_corresponding_response_integration() { + fdlimit::raise_fd_limit(); + let test_name = "ui_requests_something_and_gets_corresponding_response"; + let port = find_free_port(); + let home_dir = ensure_node_home_directory_exists( + "ui_gateway_test", + test_name, + ); + let mut node = utils::MASQNode::start_standard( + test_name, + Some( + CommandConfig::new() + .pair("--ui-port", &port.to_string()) + .pair( + "--data-directory", + home_dir.into_os_string().to_str().unwrap(), + ), + ), + true, + true, + false, + true, + ); + node.wait_for_log("UIGateway bound", Some(5000)); + let check_password_request = UiCheckPasswordRequest { + db_password_opt: None, + }; + let mut client = UiConnection::new(port, NODE_UI_PROTOCOL); + + client.send(check_password_request); + let response: UiCheckPasswordResponse = client.skip_until_received().unwrap(); + + assert_eq!(response, UiCheckPasswordResponse { matches: true }); + client.send(UiShutdownRequest {}); + node.wait_for_exit(); +} diff --git a/node/tests/utils.rs b/node/tests/utils.rs index adeec8c7e..6a4e71535 100644 --- a/node/tests/utils.rs +++ b/node/tests/utils.rs @@ -359,10 +359,17 @@ impl MASQNode { ensure_start: bool, command_getter: F, ) -> MASQNode { - let data_dir = if sterile_database { - ensure_node_home_directory_exists("integration", test_name) - } else { - node_home_directory("integration", test_name) + let configured_data_dir_opt = match &config_opt { + Some(config) => config.value_of("--data-directory") + .map(|data_dir_str| PathBuf::from(data_dir_str)), + None => None, + }; + let data_dir = match configured_data_dir_opt { + Some(data_dir) => data_dir, + None => match sterile_database { + true => ensure_node_home_directory_exists("integration", test_name), + false => node_home_directory("integration", test_name), + } }; if sterile_logfile { let _ = Self::remove_logfile(&data_dir); From 1a9f51adb30e90595471f86b1600be824a87d630 Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Sat, 22 Mar 2025 08:26:24 -0400 Subject: [PATCH 02/13] Removed dead code --- node/tests/financials_test.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/node/tests/financials_test.rs b/node/tests/financials_test.rs index a3b2da5bc..b8d5cf18e 100644 --- a/node/tests/financials_test.rs +++ b/node/tests/financials_test.rs @@ -92,7 +92,6 @@ fn financials_command_retrieves_payable_and_receivable_records_integration() { let after = SystemTime::now(); assert_eq!(response.stats_opt, None); -eprintln! ("response: {:?}", response); let query_results = response.query_results_opt.unwrap(); let payable = query_results.payable_opt.unwrap(); let receivable = query_results.receivable_opt.unwrap(); From e24bd9ad242dc5bfb9df1a2969147a07fa463bdd Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Sat, 22 Mar 2025 08:30:01 -0400 Subject: [PATCH 03/13] Moved test back where it belongs --- node/tests/ui_gateway_test.rs | 76 +++++++++++++++++------------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/node/tests/ui_gateway_test.rs b/node/tests/ui_gateway_test.rs index 1e182a325..73d52a2bd 100644 --- a/node/tests/ui_gateway_test.rs +++ b/node/tests/ui_gateway_test.rs @@ -15,6 +15,44 @@ use masq_lib::test_utils::utils::ensure_node_home_directory_exists; use masq_lib::utils::{add_chain_specific_directory, find_free_port}; use utils::CommandConfig; +#[test] +fn ui_requests_something_and_gets_corresponding_response_integration() { + fdlimit::raise_fd_limit(); + let test_name = "ui_requests_something_and_gets_corresponding_response"; + let port = find_free_port(); + let home_dir = ensure_node_home_directory_exists( + "ui_gateway_test", + test_name, + ); + let mut node = utils::MASQNode::start_standard( + test_name, + Some( + CommandConfig::new() + .pair("--ui-port", &port.to_string()) + .pair( + "--data-directory", + home_dir.into_os_string().to_str().unwrap(), + ), + ), + true, + true, + false, + true, + ); + node.wait_for_log("UIGateway bound", Some(5000)); + let check_password_request = UiCheckPasswordRequest { + db_password_opt: None, + }; + let mut client = UiConnection::new(port, NODE_UI_PROTOCOL); + + client.send(check_password_request); + let response: UiCheckPasswordResponse = client.skip_until_received().unwrap(); + + assert_eq!(response, UiCheckPasswordResponse { matches: true }); + client.send(UiShutdownRequest {}); + node.wait_for_exit(); +} + #[test] fn log_broadcasts_are_correctly_received_integration() { fdlimit::raise_fd_limit(); @@ -176,41 +214,3 @@ fn cleanup_after_deceased_clients_integration() { client_2.send(UiShutdownRequest {}); node.wait_for_exit(); } - -#[test] -fn ui_requests_something_and_gets_corresponding_response_integration() { - fdlimit::raise_fd_limit(); - let test_name = "ui_requests_something_and_gets_corresponding_response"; - let port = find_free_port(); - let home_dir = ensure_node_home_directory_exists( - "ui_gateway_test", - test_name, - ); - let mut node = utils::MASQNode::start_standard( - test_name, - Some( - CommandConfig::new() - .pair("--ui-port", &port.to_string()) - .pair( - "--data-directory", - home_dir.into_os_string().to_str().unwrap(), - ), - ), - true, - true, - false, - true, - ); - node.wait_for_log("UIGateway bound", Some(5000)); - let check_password_request = UiCheckPasswordRequest { - db_password_opt: None, - }; - let mut client = UiConnection::new(port, NODE_UI_PROTOCOL); - - client.send(check_password_request); - let response: UiCheckPasswordResponse = client.skip_until_received().unwrap(); - - assert_eq!(response, UiCheckPasswordResponse { matches: true }); - client.send(UiShutdownRequest {}); - node.wait_for_exit(); -} From bcedf603af9f2131b7b3531d346bcd4bd5cf2522 Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Sat, 22 Mar 2025 08:39:51 -0400 Subject: [PATCH 04/13] Formatting --- node/tests/financials_test.rs | 29 ++++++++++++++++------------- node/tests/ui_gateway_test.rs | 10 ++-------- node/tests/utils.rs | 5 +++-- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/node/tests/financials_test.rs b/node/tests/financials_test.rs index b8d5cf18e..9847efa38 100644 --- a/node/tests/financials_test.rs +++ b/node/tests/financials_test.rs @@ -3,6 +3,7 @@ pub mod utils; use crate::utils::{make_conn, CommandConfig}; +use masq_lib::constants::POLYGON_MAINNET_FULL_IDENTIFIER; use masq_lib::messages::{ TopRecordsConfig, TopRecordsOrdering, UiFinancialsRequest, UiFinancialsResponse, UiShutdownRequest, NODE_UI_PROTOCOL, @@ -14,11 +15,12 @@ use node_lib::accountant::db_access_objects::payable_dao::{PayableDao, PayableDa use node_lib::accountant::db_access_objects::receivable_dao::{ReceivableDao, ReceivableDaoReal}; use node_lib::accountant::db_access_objects::utils::{from_time_t, to_time_t}; use node_lib::accountant::gwei_to_wei; +use node_lib::database::db_initializer::{ + DbInitializationConfig, DbInitializer, DbInitializerReal, +}; +use node_lib::db_config::config_dao::{ConfigDao, ConfigDaoReal}; use node_lib::test_utils::make_wallet; use std::time::SystemTime; -use masq_lib::constants::POLYGON_MAINNET_FULL_IDENTIFIER; -use node_lib::database::db_initializer::{DbInitializationConfig, DbInitializer, DbInitializerReal}; -use node_lib::db_config::config_dao::{ConfigDao, ConfigDaoReal}; use utils::MASQNode; #[test] @@ -26,10 +28,7 @@ fn financials_command_retrieves_payable_and_receivable_records_integration() { fdlimit::raise_fd_limit(); let test_name = "financials_command_retrieves_payable_and_receivable_records_integration"; let port = find_free_port(); - let home_dir = ensure_node_home_directory_exists( - "integration", - test_name, - ); + let home_dir = ensure_node_home_directory_exists("integration", test_name); let now = SystemTime::now(); let timestamp_payable = from_time_t(to_time_t(now) - 678); let timestamp_receivable_1 = from_time_t(to_time_t(now) - 10000); @@ -41,13 +40,17 @@ fn financials_command_retrieves_payable_and_receivable_records_integration() { let amount_receivable_1 = gwei_to_wei(9000_u64); let amount_receivable_2 = gwei_to_wei(345678_u64); { - let db_initializer = DbInitializerReal{}; - let conn = db_initializer.initialize( - &home_dir, - DbInitializationConfig::test_default() - ).unwrap(); + let db_initializer = DbInitializerReal {}; + let conn = db_initializer + .initialize(&home_dir, DbInitializationConfig::test_default()) + .unwrap(); let config_dao = ConfigDaoReal::new(conn); - config_dao.set("chain_name", Some (POLYGON_MAINNET_FULL_IDENTIFIER.to_string())).unwrap(); + config_dao + .set( + "chain_name", + Some(POLYGON_MAINNET_FULL_IDENTIFIER.to_string()), + ) + .unwrap(); } open_all_file_permissions(home_dir.clone()); PayableDaoReal::new(make_conn(&home_dir)) diff --git a/node/tests/ui_gateway_test.rs b/node/tests/ui_gateway_test.rs index 73d52a2bd..c38063748 100644 --- a/node/tests/ui_gateway_test.rs +++ b/node/tests/ui_gateway_test.rs @@ -20,10 +20,7 @@ fn ui_requests_something_and_gets_corresponding_response_integration() { fdlimit::raise_fd_limit(); let test_name = "ui_requests_something_and_gets_corresponding_response"; let port = find_free_port(); - let home_dir = ensure_node_home_directory_exists( - "ui_gateway_test", - test_name, - ); + let home_dir = ensure_node_home_directory_exists("ui_gateway_test", test_name); let mut node = utils::MASQNode::start_standard( test_name, Some( @@ -100,10 +97,7 @@ fn daemon_does_not_allow_node_to_keep_his_client_alive_integration() { //breaking any reference to him immediately fdlimit::raise_fd_limit(); let test_name = "daemon_does_not_allow_node_to_keep_his_client_alive_integration"; - let data_directory = ensure_node_home_directory_exists( - "ui_gateway_test", - test_name, - ); + let data_directory = ensure_node_home_directory_exists("ui_gateway_test", test_name); let expected_chain_data_dir = add_chain_specific_directory(DEFAULT_CHAIN, &data_directory); let daemon_port = find_free_port(); let mut daemon = utils::MASQNode::start_daemon( diff --git a/node/tests/utils.rs b/node/tests/utils.rs index 6a4e71535..45eaa6970 100644 --- a/node/tests/utils.rs +++ b/node/tests/utils.rs @@ -360,7 +360,8 @@ impl MASQNode { command_getter: F, ) -> MASQNode { let configured_data_dir_opt = match &config_opt { - Some(config) => config.value_of("--data-directory") + Some(config) => config + .value_of("--data-directory") .map(|data_dir_str| PathBuf::from(data_dir_str)), None => None, }; @@ -369,7 +370,7 @@ impl MASQNode { None => match sterile_database { true => ensure_node_home_directory_exists("integration", test_name), false => node_home_directory("integration", test_name), - } + }, }; if sterile_logfile { let _ = Self::remove_logfile(&data_dir); From 8975ef5a1d28e11f9afd69143bc150fc2452fb2d Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Sat, 22 Mar 2025 08:48:40 -0400 Subject: [PATCH 05/13] Finished TEST_DEFAULT_CHAIN update --- masq_lib/src/test_utils/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/masq_lib/src/test_utils/utils.rs b/masq_lib/src/test_utils/utils.rs index 98c91f7c6..342472aef 100644 --- a/masq_lib/src/test_utils/utils.rs +++ b/masq_lib/src/test_utils/utils.rs @@ -117,7 +117,7 @@ mod tests { #[test] fn constants_have_correct_values() { - assert_eq!(TEST_DEFAULT_CHAIN, Chain::EthRopsten); + assert_eq!(TEST_DEFAULT_CHAIN, Chain::BaseSepolia); assert_eq!(TEST_DEFAULT_MULTINODE_CHAIN, Chain::Dev); assert_eq!(BASE_TEST_DIR, "generated/test"); } From 10735ada8a237f8a82b44b829026935f6ce8e02a Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Sat, 22 Mar 2025 10:39:25 -0400 Subject: [PATCH 06/13] More BaseSepolia stuff --- node/src/actor_system_factory.rs | 4 ++-- .../blockchain_interface_web3/utils.rs | 2 +- node/src/bootstrapper.rs | 12 ++++++------ node/src/daemon/setup_reporter.rs | 18 +++++++++--------- node/src/database/db_initializer.rs | 4 ++-- .../migrations/migration_1_to_2.rs | 2 +- .../migrations/migration_4_to_5.rs | 2 +- node/src/neighborhood/node_record.rs | 4 ++-- node/src/sub_lib/route.rs | 16 ++++++++-------- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/node/src/actor_system_factory.rs b/node/src/actor_system_factory.rs index 20ee55ed2..8ab3426cf 100644 --- a/node/src/actor_system_factory.rs +++ b/node/src/actor_system_factory.rs @@ -1197,7 +1197,7 @@ mod tests { when_pending_too_long_sec: DEFAULT_PENDING_TOO_LONG_SEC, }; let persistent_config = PersistentConfigurationMock::default() - .chain_name_result("eth-ropsten".to_string()) + .chain_name_result("base-sepolia".to_string()) .set_min_hops_result(Ok(())); Bootstrapper::pub_initialize_cryptdes_for_testing( &Some(main_cryptde()), @@ -1953,7 +1953,7 @@ mod tests { #[test] #[should_panic( - expected = "Database with a wrong chain name detected; expected: eth-ropsten, was: eth-mainnet" + expected = "Database with a wrong chain name detected; expected: base-sepolia, was: eth-mainnet" )] fn make_and_start_actors_does_not_tolerate_differences_in_setup_chain_and_database_chain() { let mut bootstrapper_config = BootstrapperConfig::new(); diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs index 2be7d5977..03ed4150b 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs @@ -507,7 +507,7 @@ mod tests { Transactions in the batch:\n\ \n\ gas price: 120 wei\n\ - chain: ropsten\n\ + chain: sepolia\n\ \n\ [wallet address] [payment in wei]\n\ 0x0000000000000000000000000000000077313233 900,000,000,000,000,000\n\ diff --git a/node/src/bootstrapper.rs b/node/src/bootstrapper.rs index 2ef265e69..9e4e72698 100644 --- a/node/src/bootstrapper.rs +++ b/node/src/bootstrapper.rs @@ -1206,11 +1206,11 @@ mod tests { NodeDescriptor::from(( main_cryptde_ref().public_key(), &NodeAddr::new(&IpAddr::from_str("1.2.3.4").unwrap(), &[5123]), - Chain::EthRopsten, + Chain::BaseSepolia, main_cryptde_ref() )) ); - TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://eth-ropsten:.+@1\\.2\\.3\\.4:5123"); + TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://base-sepolia:.+@1\\.2\\.3\\.4:5123"); } #[test] @@ -1322,11 +1322,11 @@ mod tests { NodeDescriptor::from(( main_cryptde_ref().public_key(), &NodeAddr::new(&IpAddr::from_str("1.2.3.4").unwrap(), &[5123]), - Chain::EthRopsten, + Chain::BaseSepolia, main_cryptde_ref() )) ); - TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://eth-ropsten:.+@1\\.2\\.3\\.4:5123"); + TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://base-sepolia:.+@1\\.2\\.3\\.4:5123"); } #[test] @@ -1571,7 +1571,7 @@ mod tests { cryptdes.main }; let expected_descriptor = format!( - "masq://eth-ropsten:{}@2.3.4.5:3456/4567", + "masq://base-sepolia:{}@2.3.4.5:3456/4567", cryptde_ref.public_key_to_descriptor_fragment(cryptde_ref.public_key()) ); TestLogHandler::new().exists_log_containing( @@ -1611,7 +1611,7 @@ mod tests { cryptdes }; let expected_descriptor = format!( - "masq://eth-ropsten:{}@:", + "masq://base-sepolia:{}@:", cryptdes .main .public_key_to_descriptor_fragment(cryptdes.main.public_key()) diff --git a/node/src/daemon/setup_reporter.rs b/node/src/daemon/setup_reporter.rs index 84c1db1e5..1ef47777f 100644 --- a/node/src/daemon/setup_reporter.rs +++ b/node/src/daemon/setup_reporter.rs @@ -1488,7 +1488,7 @@ mod tests { ("mapping-protocol", "pmp", Set), ("min-hops", "2", Set), ("neighborhood-mode", "originate-only", Set), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), ("payment-thresholds","1234|50000|1000|1000|20000|20000",Set), ("rate-pack","1|3|3|8",Set), #[cfg(not(target_os = "windows"))] @@ -1518,7 +1518,7 @@ mod tests { ("mapping-protocol", "pmp", Set), ("min-hops", "2", Set), ("neighborhood-mode", "originate-only", Set), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), ("payment-thresholds","1234|50000|1000|1000|20000|20000",Set), ("rate-pack","1|3|3|8",Set), #[cfg(not(target_os = "windows"))] @@ -1558,7 +1558,7 @@ mod tests { ("mapping-protocol", "igdp"), ("min-hops", "2"), ("neighborhood-mode", "originate-only"), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), ("payment-thresholds","1234|50000|1000|1000|15000|15000"), ("rate-pack","1|3|3|8"), #[cfg(not(target_os = "windows"))] @@ -1593,7 +1593,7 @@ mod tests { ("mapping-protocol", "igdp", Set), ("min-hops", "2", Set), ("neighborhood-mode", "originate-only", Set), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), ("payment-thresholds","1234|50000|1000|1000|15000|15000",Set), ("rate-pack","1|3|3|8",Set), #[cfg(not(target_os = "windows"))] @@ -1634,7 +1634,7 @@ mod tests { ("MASQ_MAPPING_PROTOCOL", "pmp"), ("MASQ_MIN_HOPS", "2"), ("MASQ_NEIGHBORHOOD_MODE", "originate-only"), - ("MASQ_NEIGHBORS", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), + ("MASQ_NEIGHBORS", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), ("MASQ_PAYMENT_THRESHOLDS","12345|50000|1000|1234|19000|20000"), ("MASQ_RATE_PACK","1|3|3|8"), #[cfg(not(target_os = "windows"))] @@ -1666,7 +1666,7 @@ mod tests { ("mapping-protocol", "pmp", Configured), ("min-hops", "2", Configured), ("neighborhood-mode", "originate-only", Configured), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), ("payment-thresholds","12345|50000|1000|1234|19000|20000",Configured), ("rate-pack","1|3|3|8",Configured), #[cfg(not(target_os = "windows"))] @@ -1884,7 +1884,7 @@ mod tests { ("MASQ_MAPPING_PROTOCOL", "pcp"), ("MASQ_MIN_HOPS", "2"), ("MASQ_NEIGHBORHOOD_MODE", "originate-only"), - ("MASQ_NEIGHBORS", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), + ("MASQ_NEIGHBORS", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), ("MASQ_PAYMENT_THRESHOLDS","1234|50000|1000|1000|20000|20000"), ("MASQ_RATE_PACK","1|3|3|8"), #[cfg(not(target_os = "windows"))] @@ -1946,7 +1946,7 @@ mod tests { ("neighborhood-mode", "consume-only", Set), ( "neighbors", - "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@9.10.11.12:9101", + "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@9.10.11.12:9101", Set, ), ("payment-thresholds", "4321|66666|777|987|123456|124444", Set), @@ -1982,7 +1982,7 @@ mod tests { ("mapping-protocol", "pcp", Configured), ("min-hops", "2", Configured), ("neighborhood-mode", "originate-only", Configured), - ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), + ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), ("payment-thresholds","1234|50000|1000|1000|20000|20000",Configured), ("rate-pack","1|3|3|8",Configured), #[cfg(not(target_os = "windows"))] diff --git a/node/src/database/db_initializer.rs b/node/src/database/db_initializer.rs index 3619cc1b4..39c0c332e 100644 --- a/node/src/database/db_initializer.rs +++ b/node/src/database/db_initializer.rs @@ -1153,7 +1153,7 @@ mod tests { init_test_logging(); let home_dir = ensure_node_home_directory_exists( "db_initializer", - "existing_database_with_the_wrong_version_comes_to_migrator_that_makes_it_gradually_migrate_to_upper_versions", + "database_of_old_version_comes_to_migrator_where_it_gradually_migrates_to_upper_versions", ); let updated_db_path_dir = &home_dir.join("updated"); let from_scratch_db_path_dir = &home_dir.join("from_scratch"); @@ -1168,7 +1168,7 @@ mod tests { .initialize( &updated_db_path_dir, DbInitializationConfig::create_or_migrate(ExternalData::new( - Chain::EthRopsten, + Chain::BaseSepolia, NeighborhoodModeLight::Standard, Some("password".to_string()), )), diff --git a/node/src/database/db_migrations/migrations/migration_1_to_2.rs b/node/src/database/db_migrations/migrations/migration_1_to_2.rs index d92bcaf68..23447ba1c 100644 --- a/node/src/database/db_migrations/migrations/migration_1_to_2.rs +++ b/node/src/database/db_migrations/migrations/migration_1_to_2.rs @@ -68,7 +68,7 @@ mod tests { let connection = result.unwrap(); let (chn_value, chn_encrypted) = retrieve_config_row(connection.as_ref(), "chain_name"); let (cs_value, cs_encrypted) = retrieve_config_row(connection.as_ref(), "schema_version"); - assert_eq!(chn_value, Some("eth-ropsten".to_string())); + assert_eq!(chn_value, Some("base-sepolia".to_string())); assert_eq!(chn_encrypted, false); assert_eq!(cs_value, Some("2".to_string())); assert_eq!(cs_encrypted, false); diff --git a/node/src/database/db_migrations/migrations/migration_4_to_5.rs b/node/src/database/db_migrations/migrations/migration_4_to_5.rs index dbc40f1b3..06deb809f 100644 --- a/node/src/database/db_migrations/migrations/migration_4_to_5.rs +++ b/node/src/database/db_migrations/migrations/migration_4_to_5.rs @@ -227,7 +227,7 @@ mod tests { let config_table_after = fetch_all_from_config_table(&conn); assert_eq!(config_table_before, config_table_after); assert_on_schema_5_was_adopted(conn_schema5.as_ref()); - TestLogHandler::new().exists_log_containing("WARN: DbMigrator: Migration from 4 to 5: database belonging to the chain 'eth-ropsten'; \ + TestLogHandler::new().exists_log_containing("WARN: DbMigrator: Migration from 4 to 5: database belonging to the chain 'base-sepolia'; \ we discovered possibly abandoned transactions that are said yet to be pending, these are: \ '0x0000000000000000000000000000000000000000000000000000000002b594d1', \ '0x00000000000000000000000000000000000000000000000000000000000f41d0'; continuing"); diff --git a/node/src/neighborhood/node_record.rs b/node/src/neighborhood/node_record.rs index e490cec1d..d2546e03c 100644 --- a/node/src/neighborhood/node_record.rs +++ b/node/src/neighborhood/node_record.rs @@ -409,7 +409,7 @@ mod tests { result, NodeDescriptor::try_from(( main_cryptde(), - "masq://eth-ropsten:AQIDBA@1.2.3.4:1234/2345" + "masq://base-sepolia:AQIDBA@1.2.3.4:1234/2345" )) .unwrap() ); @@ -424,7 +424,7 @@ mod tests { assert_eq!( result, - NodeDescriptor::try_from((main_cryptde(), "masq://eth-ropsten:AQIDBA@:")).unwrap() + NodeDescriptor::try_from((main_cryptde(), "masq://base-sepolia:AQIDBA@:")).unwrap() ); } diff --git a/node/src/sub_lib/route.rs b/node/src/sub_lib/route.rs index 8415c758b..ecbd0261e 100644 --- a/node/src/sub_lib/route.rs +++ b/node/src/sub_lib/route.rs @@ -781,9 +781,9 @@ mod tests { result, String::from( r#" -Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320", s: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320" } }), component: Hopper } -Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b", s: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b" } }), component: Hopper } -Encrypted with 0x03040506: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e", s: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e" } }), component: Neighborhood } +Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d", s: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d" } }), component: Hopper } +Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a", s: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a" } }), component: Hopper } +Encrypted with 0x03040506: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9", s: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9" } }), component: Neighborhood } "# ) ); @@ -818,11 +818,11 @@ Encrypted with 0x03040506: LiveHop { public_key: 0x, payer: Some(Payer { wallet: result, String::from( r#" -Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320", s: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320" } }), component: Hopper } -Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b", s: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b" } }), component: Hopper } -Encrypted with 0x03040506: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e", s: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e" } }), component: ProxyClient } -Encrypted with 0x02030405: LiveHop { public_key: 0x01020304, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b", s: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b" } }), component: Hopper } -Encrypted with 0x01020304: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320", s: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320" } }), component: ProxyServer } +Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d", s: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d" } }), component: Hopper } +Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a", s: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a" } }), component: Hopper } +Encrypted with 0x03040506: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9", s: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9" } }), component: ProxyClient } +Encrypted with 0x02030405: LiveHop { public_key: 0x01020304, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a", s: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a" } }), component: Hopper } +Encrypted with 0x01020304: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d", s: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d" } }), component: ProxyServer } Encrypted with 0x01020304: Return Route ID: 1234 "# ) From 70e3eadbaaf1c1e262a7c848ed796222ed265cf2 Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Wed, 26 Mar 2025 08:14:19 -0400 Subject: [PATCH 07/13] Corrected host and port detection in protocol packs; about to make ports non-optional --- node/src/proxy_server/http_protocol_pack.rs | 79 ++++++++++----------- node/src/proxy_server/mod.rs | 27 +++---- node/src/proxy_server/tls_protocol_pack.rs | 11 +-- node/src/sub_lib/stream_key.rs | 60 ++++++++-------- 4 files changed, 89 insertions(+), 88 deletions(-) diff --git a/node/src/proxy_server/http_protocol_pack.rs b/node/src/proxy_server/http_protocol_pack.rs index 3904c736f..9c9709317 100644 --- a/node/src/proxy_server/http_protocol_pack.rs +++ b/node/src/proxy_server/http_protocol_pack.rs @@ -24,9 +24,9 @@ impl ProtocolPack for HttpProtocolPack { } fn find_host(&self, data: &PlainData) -> Option { - match HttpProtocolPack::find_url_host(data.as_slice()) { + match HttpProtocolPack::find_header_host(data.as_slice()) { Some(host) => Some(host), - None => HttpProtocolPack::find_header_host(data.as_slice()), + None => HttpProtocolPack::find_url_host(data.as_slice()), } } @@ -67,12 +67,18 @@ impl HttpProtocolPack { match parts.len() { 1 => Some(Host { name: parts.remove(0).to_string(), - port: None, - }), - 2 => Some(Host { - name: parts.remove(0).to_string(), - port: Self::port_from_string(parts.remove(0).to_string()), + port: Some(HTTP_PORT), }), + 2 => { + let name = parts.remove(0).to_string(); + match Self::port_from_string(parts.remove(0).to_string()) { + Ok(port) => Some(Host { + name, + port: Some(port), + }), + Err(_) => None, + } + }, _ => None, } } @@ -91,10 +97,10 @@ impl HttpProtocolPack { ) } - fn port_from_string(port_str: String) -> Option { + fn port_from_string(port_str: String) -> Result { match port_str.parse::() { - Err(_) => None, - Ok(port) => Some(port), + Err(_) => Err(format!("Port '{}' is not a number", port_str)), + Ok(port) => Ok(port), } } } @@ -161,6 +167,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("header.host.com"), host.name); + assert_eq!(Some(HTTP_PORT), host.port); } #[test] @@ -183,21 +190,22 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("192.168.1.230"), host.name); - assert_eq!(None, host.port); + assert_eq!(Some(HTTP_PORT), host.port); } #[test] - fn returns_host_name_and_port_from_url_if_both_exist() { + fn returns_host_name_and_port_from_header_if_both_exist() { let data = PlainData::new(b"OPTIONS http://top.host.com:1234/index.html HTTP/1.1\r\nHost: header.host.com:5432\r\n\r\nbodybody"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(Some(1234), host.port); + assert_eq!(String::from("header.host.com"), host.name); + assert_eq!(Some(5432), host.port); } #[test] fn returns_host_name_from_http_url_if_header_doesnt_exist() { + // Note: that "Host: body.host.com" looks like a header, but it's not: it's content. let data = PlainData::new(b"DELETE http://top.host.com/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); @@ -207,6 +215,7 @@ mod tests { #[test] fn returns_host_name_from_https_url_if_header_doesnt_exist() { + // Note: that "Host: body.host.com" looks like a header, but it's not: it's content. let data = PlainData::new(b"PUT https://top.host.com/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); @@ -221,12 +230,13 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("top.host.com"), host.name); + assert_eq!(Some(HTTP_PORT), host.port); } #[test] fn returns_host_name_from_url_when_no_scheme() { let data = PlainData::new( - b"CONNECT good.url.dude/path.html HTTP/1.1\r\nHost: wrong.url.dude\r\n\r\n", + b"GET wrong.url.dude/path.html HTTP/1.1\r\nHost: good.url.dude\r\n\r\n", ); let host = HttpProtocolPack {}.find_host(&data).unwrap(); @@ -237,12 +247,12 @@ mod tests { #[test] fn can_handle_domain_that_starts_with_http() { let data = PlainData::new( - b"CONNECT http.url.dude/path.html HTTP/1.1\r\nHost: wrong.url.dude\r\n\r\n", + b"GET http.url.dude/path.html HTTP/1.1\r\nHost: good.url.dude\r\n\r\n", ); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("http.url.dude"), host.name); + assert_eq!(String::from("good.url.dude"), host.name); } #[test] @@ -268,39 +278,28 @@ mod tests { fn specifying_a_non_numeric_port_in_the_url() { let data = PlainData::new(b"HEAD http://top.host.com:nanan/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] - fn specifying_a_missing_port_in_the_url() { + fn cant_extract_top_host_if_port_has_syntax_error() { let data = PlainData::new(b"HEAD http://top.host.com:/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] - fn from_integration_test() { + fn explicit_port_is_80_if_it_was_not_specified() { let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("www.example.com"), host.name); - } - - #[test] - fn explicit_port_is_none_if_it_was_not_specified() { - let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); - - let host = HttpProtocolPack {}.find_host(&data).unwrap(); - - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(Some(HTTP_PORT), host.port); } #[test] @@ -317,20 +316,18 @@ mod tests { fn specifying_a_non_numeric_port_in_host_header() { let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com:nannan\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] fn specifying_a_missing_port_in_host_header() { let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com:\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] diff --git a/node/src/proxy_server/mod.rs b/node/src/proxy_server/mod.rs index d830156a8..e7700963e 100644 --- a/node/src/proxy_server/mod.rs +++ b/node/src/proxy_server/mod.rs @@ -565,7 +565,7 @@ impl ProxyServer { let http_data = HttpProtocolPack {}.find_host(&msg.data.clone().into()); match http_data { Some(ref host) if host.port == Some(443) => { - let stream_key = self.find_or_generate_stream_key(msg, msg.peer_addr); + let stream_key = self.find_or_generate_stream_key(msg, &host.name, 443); self.tunneled_hosts.insert(stream_key, host.name.clone()); self.subs .as_ref() @@ -645,7 +645,8 @@ impl ProxyServer { fn find_or_generate_stream_key( &mut self, ibcd: &InboundClientData, - server_addr: SocketAddr, + host_name: &str, + host_port: u16, ) -> StreamKey { match self.keys_and_addrs.b_to_a(&ibcd.peer_addr) { Some(stream_key) => { @@ -660,7 +661,7 @@ impl ProxyServer { None => { let stream_key = self .stream_key_factory - .make(self.main_cryptde.public_key(), server_addr); + .make(self.main_cryptde.public_key(), host_name, host_port); self.keys_and_addrs.insert(stream_key, ibcd.peer_addr); debug!( self.logger, @@ -1139,7 +1140,7 @@ impl IBCDHelper for IBCDHelperReal { .expect("Dispatcher is dead"); return Err("Browser request rejected due to missing consuming wallet".to_string()); } - let stream_key = proxy.find_or_generate_stream_key(&msg, source_addr); + let stream_key = proxy.find_or_generate_stream_key(&msg, "drive-me-in", 0); let timestamp = msg.timestamp; let payload = match proxy.make_payload(msg, &stream_key) { Ok(payload) => { @@ -1275,14 +1276,14 @@ enum ExitServiceSearch { } trait StreamKeyFactory: Send { - fn make(&self, public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey; + fn make(&self, public_key: &PublicKey, host_name: &str, host_port: u16) -> StreamKey; } struct StreamKeyFactoryReal {} impl StreamKeyFactory for StreamKeyFactoryReal { - fn make(&self, public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey { - StreamKey::new(public_key, server_addr) + fn make(&self, public_key: &PublicKey, host_name: &str, host_port: u16) -> StreamKey { + StreamKey::new(public_key, host_name, host_port) } } @@ -1507,16 +1508,16 @@ mod tests { } struct StreamKeyFactoryMock { - make_parameters: Arc>>, + make_parameters: Arc>>, make_results: RefCell>, } impl StreamKeyFactory for StreamKeyFactoryMock { - fn make(&self, public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey { + fn make(&self, public_key: &PublicKey, host_name: &str, host_port: u16) -> StreamKey { self.make_parameters .lock() .unwrap() - .push((public_key.clone(), server_addr)); + .push((public_key.clone(), host_name.to_string(), host_port)); self.make_results.borrow_mut().remove(0) } } @@ -1531,7 +1532,7 @@ mod tests { fn make_parameters( mut self, - params: &Arc>>, + params: &Arc>>, ) -> StreamKeyFactoryMock { self.make_parameters = params.clone(); self @@ -1709,7 +1710,7 @@ mod tests { let mut make_parameters = make_parameters_arc_a.lock().unwrap(); assert_eq!( make_parameters.remove(0), - (main_cryptde.public_key().clone(), socket_addr) + (main_cryptde.public_key().clone(), "nowhere.com".to_string(), HTTP_PORT) ); let recording = neighborhood_recording_arc.lock().unwrap(); let record = recording.get_record::(0); @@ -1828,7 +1829,7 @@ mod tests { let mut make_parameters = make_parameters_arc.lock().unwrap(); assert_eq!( make_parameters.remove(0), - (main_cryptde.public_key().clone(), socket_addr) + (main_cryptde.public_key().clone(), "realdomain.nu".to_string(), 443) ); let hopper_recording = hopper_recording_arc.lock().unwrap(); diff --git a/node/src/proxy_server/tls_protocol_pack.rs b/node/src/proxy_server/tls_protocol_pack.rs index f57177a8f..accdf7419 100644 --- a/node/src/proxy_server/tls_protocol_pack.rs +++ b/node/src/proxy_server/tls_protocol_pack.rs @@ -1,3 +1,4 @@ +use masq_lib::constants::TLS_PORT; // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. use crate::proxy_server::protocol_pack::{Host, ProtocolPack, ServerImpersonator}; use crate::proxy_server::server_impersonator_tls::ServerImpersonatorTls; @@ -13,7 +14,7 @@ impl ProtocolPack for TlsProtocolPack { } fn standard_port(&self) -> u16 { - 443 + TLS_PORT } fn find_host(&self, data: &PlainData) -> Option { @@ -25,7 +26,7 @@ impl ProtocolPack for TlsProtocolPack { return None; } match Self::host_name_from_client_hello(&mut xvsr) { - Ok(name) => Some(Host { name, port: None }), + Ok(name) => Some(Host { name, port: Some(self.standard_port()) }), Err(()) => None, } } @@ -112,7 +113,7 @@ mod tests { fn knows_its_standard_port() { let result = TlsProtocolPack {}.standard_port(); - assert_eq!(result, 443); + assert_eq!(result, TLS_PORT); } #[test] @@ -709,7 +710,7 @@ mod tests { assert_eq!( Some(Host { name: String::from("server.com"), - port: None, + port: Some(TLS_PORT), }), result ); @@ -754,7 +755,7 @@ mod tests { assert_eq!( Some(Host { name: String::from("server.com"), - port: None + port: Some(TLS_PORT) }), result ); diff --git a/node/src/sub_lib/stream_key.rs b/node/src/sub_lib/stream_key.rs index 1535ee77c..11a6d12c0 100644 --- a/node/src/sub_lib/stream_key.rs +++ b/node/src/sub_lib/stream_key.rs @@ -9,7 +9,6 @@ use serde::Serialize; use serde::Serializer; use sodiumoxide::randombytes::randombytes_into; use std::fmt; -use std::net::SocketAddr; lazy_static! { static ref STREAM_KEY_SALT: [u8; 8] = { @@ -84,10 +83,10 @@ impl<'a> Visitor<'a> for StreamKeyVisitor { } impl StreamKey { - pub fn new(public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey { + pub fn new(public_key: &PublicKey, host_name: &str, host_port: u16) -> StreamKey { let mut hash = sha1::Sha1::new(); hash.update(public_key.as_ref()); - hash = add_socket_addr_to_hash(hash, server_addr); + hash = add_host_name_and_port_to_hash(hash, host_name, host_port); hash.update(STREAM_KEY_SALT.as_slice()); StreamKey { hash: hash.digest().bytes(), @@ -111,17 +110,9 @@ impl StreamKey { type HashType = [u8; sha1::DIGEST_LENGTH]; -fn add_socket_addr_to_hash(mut hash: sha1::Sha1, socket_addr: SocketAddr) -> sha1::Sha1 { - match socket_addr { - SocketAddr::V4(v4) => { - hash.update(v4.ip().octets().as_slice()); - } - SocketAddr::V6(v6) => { - hash.update(v6.ip().octets().as_slice()); - } - } - let port = socket_addr.port(); - hash.update(&[(port & 0xFF) as u8, (port >> 8) as u8]); +fn add_host_name_and_port_to_hash(mut hash: sha1::Sha1, host_name: &str, host_port: u16) -> sha1::Sha1 { + hash.update(host_name.as_bytes()); + hash.update(&[(host_port & 0xFF) as u8, (host_port >> 8) as u8]); hash } @@ -130,18 +121,32 @@ mod tests { use super::*; use crate::test_utils::main_cryptde; use itertools::Itertools; - use std::net::IpAddr; - use std::str::FromStr; #[test] - fn stream_keys_with_different_server_addrs_are_different() { + fn stream_keys_with_different_host_names_are_different() { let public_key = main_cryptde().public_key(); let stream_key_count = 100; - let ip_addr = IpAddr::from_str("1.2.3.4").unwrap(); - let server_addrs = (0..stream_key_count).map(|i| SocketAddr::new(ip_addr, 1024 + i as u16)); + let host_names = (0..stream_key_count).map(|i| format!("host_name_{}", i)); + + let stream_keys = host_names + .map(|host_name| StreamKey::new(&public_key, &host_name, 443)) + .collect_vec(); + + (0..(stream_key_count - 1)).for_each(|a| { + ((a + 1)..stream_key_count).for_each(|b| { + assert_ne!(stream_keys[a], stream_keys[b]); + }); + }); + } - let stream_keys = server_addrs - .map(|server_addr| StreamKey::new(&public_key, server_addr)) + #[test] + fn stream_keys_with_different_host_ports_are_different() { + let public_key = main_cryptde().public_key(); + let stream_key_count = 100usize; + let host_ports = (0..stream_key_count).map(|i| (1024 + i) as u16); + + let stream_keys = host_ports + .map(|host_port| StreamKey::new(&public_key, "host-name", host_port)) .collect_vec(); (0..(stream_key_count - 1)).for_each(|a| { @@ -155,10 +160,9 @@ mod tests { fn stream_keys_with_same_host_name_are_same() { let public_key = main_cryptde().public_key(); let stream_key_count = 100; - let server_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); let stream_keys = (0..stream_key_count) - .map(|_| StreamKey::new(&public_key, server_addr)) + .map(|_| StreamKey::new(&public_key, "host-name", 443)) .collect_vec(); (1..stream_key_count).for_each(|i| { @@ -168,11 +172,9 @@ mod tests { #[test] fn stream_keys_from_different_public_keys_are_different() { - let server_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); - let stream_keys = vec![PublicKey::new(&[1, 2, 3]), PublicKey::new(&[1, 2, 2])] .iter() - .map(|public_key| StreamKey::new(public_key, server_addr)) + .map(|public_key| StreamKey::new(public_key, "host-name", 443)) .collect_vec(); assert_ne!(stream_keys[0], stream_keys[1]); @@ -181,13 +183,13 @@ mod tests { #[test] fn stream_keys_are_salted() { let public_key = main_cryptde().public_key(); - let server_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); + let host_name = "host-name"; - let result = StreamKey::new(&public_key, server_addr); + let result = StreamKey::new(&public_key, host_name, 443); let mut hash = sha1::Sha1::new(); hash.update(public_key.as_ref()); - hash = add_socket_addr_to_hash(hash, server_addr); + hash = add_host_name_and_port_to_hash(hash, host_name, 443); let attack = StreamKey { hash: hash.digest().bytes(), }; From 0c50d1ef03bab60fc0614205df69a11cadd7e2f4 Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Thu, 27 Mar 2025 06:58:16 -0400 Subject: [PATCH 08/13] Abandoning this approach; will revert, but wanted to preserve --- .../client_request_payload_factory.rs | 9 +- node/src/proxy_server/http_protocol_pack.rs | 24 +-- node/src/proxy_server/mod.rs | 189 ++++++++++++++++-- node/src/proxy_server/protocol_pack.rs | 7 +- node/src/proxy_server/tls_protocol_pack.rs | 9 +- node/src/sub_lib/stream_key.rs | 18 +- 6 files changed, 205 insertions(+), 51 deletions(-) diff --git a/node/src/proxy_server/client_request_payload_factory.rs b/node/src/proxy_server/client_request_payload_factory.rs index 006f37a13..e610c0151 100644 --- a/node/src/proxy_server/client_request_payload_factory.rs +++ b/node/src/proxy_server/client_request_payload_factory.rs @@ -43,11 +43,8 @@ impl ClientRequestPayloadFactory for ClientRequestPayloadFactoryReal { }; let data = PlainData::new(&ibcd.data); let target_host = protocol_pack.find_host(&data); - let (target_hostname, target_port) = match target_host { - Some(host) => match host.port { - Some(port) => (Some(host.name), port), - None => (Some(host.name), protocol_pack.standard_port()), - }, + let (target_hostname_opt, target_port) = match target_host { + Some(host) => (Some(host.name), host.port), None => (None, protocol_pack.standard_port()), }; Some(ClientRequestPayload_0v1 { @@ -57,7 +54,7 @@ impl ClientRequestPayloadFactory for ClientRequestPayloadFactoryReal { sequence_number, last_data: ibcd.last_data, }, - target_hostname, + target_hostname: target_hostname_opt, target_port, protocol: protocol_pack.proxy_protocol(), originator_public_key: cryptde.public_key().clone(), diff --git a/node/src/proxy_server/http_protocol_pack.rs b/node/src/proxy_server/http_protocol_pack.rs index 9c9709317..e66969084 100644 --- a/node/src/proxy_server/http_protocol_pack.rs +++ b/node/src/proxy_server/http_protocol_pack.rs @@ -1,5 +1,5 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::proxy_server::protocol_pack::{Host, ProtocolPack, ServerImpersonator}; +use crate::proxy_server::protocol_pack::{ProtocolPack, ServerImpersonator}; use crate::proxy_server::server_impersonator_http::ServerImpersonatorHttp; use crate::sub_lib::cryptde::PlainData; use crate::sub_lib::proxy_server::ProxyProtocol; @@ -7,6 +7,7 @@ use lazy_static::lazy_static; use masq_lib::constants::HTTP_PORT; use masq_lib::utils::index_of; use regex::Regex; +use crate::proxy_server::Host; lazy_static! { static ref HOST_PATTERN: Regex = Regex::new(r"^(?:https?://)?([^\s/]+)").expect("bad regex"); @@ -67,15 +68,12 @@ impl HttpProtocolPack { match parts.len() { 1 => Some(Host { name: parts.remove(0).to_string(), - port: Some(HTTP_PORT), + port: HTTP_PORT, }), 2 => { let name = parts.remove(0).to_string(); match Self::port_from_string(parts.remove(0).to_string()) { - Ok(port) => Some(Host { - name, - port: Some(port), - }), + Ok(port) => Some(Host { name, port }), Err(_) => None, } }, @@ -167,7 +165,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("header.host.com"), host.name); - assert_eq!(Some(HTTP_PORT), host.port); + assert_eq!(HTTP_PORT, host.port); } #[test] @@ -190,7 +188,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("192.168.1.230"), host.name); - assert_eq!(Some(HTTP_PORT), host.port); + assert_eq!(HTTP_PORT, host.port); } #[test] @@ -200,7 +198,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("header.host.com"), host.name); - assert_eq!(Some(5432), host.port); + assert_eq!(5432, host.port); } #[test] @@ -230,7 +228,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(Some(HTTP_PORT), host.port); + assert_eq!(HTTP_PORT, host.port); } #[test] @@ -262,7 +260,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(Some(8080), host.port); + assert_eq!(8080, host.port); } #[test] @@ -299,7 +297,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(Some(HTTP_PORT), host.port); + assert_eq!(HTTP_PORT, host.port); } #[test] @@ -309,7 +307,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(Some(8080), host.port); + assert_eq!(8080, host.port); } #[test] diff --git a/node/src/proxy_server/mod.rs b/node/src/proxy_server/mod.rs index e7700963e..229004ec8 100644 --- a/node/src/proxy_server/mod.rs +++ b/node/src/proxy_server/mod.rs @@ -55,12 +55,25 @@ use std::rc::Rc; use std::str::FromStr; use std::time::{Duration, SystemTime}; use tokio::prelude::Future; +use masq_lib::constants::TLS_PORT; pub const CRASH_KEY: &str = "PROXYSERVER"; pub const RETURN_ROUTE_TTL: Duration = Duration::from_secs(120); pub const STREAM_KEY_PURGE_DELAY: Duration = Duration::from_secs(30); +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Host { + pub name: String, + pub port: u16, +} + +impl Host { + pub fn new(name: &str, port: u16) -> Host { + Host { name: name.to_string(), port } + } +} + struct ProxyServerOutSubs { dispatcher: Recipient, hopper: Recipient, @@ -564,8 +577,8 @@ impl ProxyServer { fn tls_connect(&mut self, msg: &InboundClientData) { let http_data = HttpProtocolPack {}.find_host(&msg.data.clone().into()); match http_data { - Some(ref host) if host.port == Some(443) => { - let stream_key = self.find_or_generate_stream_key(msg, &host.name, 443); + Some(ref host) if host.port == TLS_PORT => { + let stream_key = self.find_or_generate_stream_key(msg, Some(Host::new(&host.name, host.port))); self.tunneled_hosts.insert(stream_key, host.name.clone()); self.subs .as_ref() @@ -645,8 +658,7 @@ impl ProxyServer { fn find_or_generate_stream_key( &mut self, ibcd: &InboundClientData, - host_name: &str, - host_port: u16, + host_opt: Option, ) -> StreamKey { match self.keys_and_addrs.b_to_a(&ibcd.peer_addr) { Some(stream_key) => { @@ -661,7 +673,7 @@ impl ProxyServer { None => { let stream_key = self .stream_key_factory - .make(self.main_cryptde.public_key(), host_name, host_port); + .make(self.main_cryptde.public_key(), Some(Host::new("booga", 0))); self.keys_and_addrs.insert(stream_key, ibcd.peer_addr); debug!( self.logger, @@ -1140,7 +1152,7 @@ impl IBCDHelper for IBCDHelperReal { .expect("Dispatcher is dead"); return Err("Browser request rejected due to missing consuming wallet".to_string()); } - let stream_key = proxy.find_or_generate_stream_key(&msg, "drive-me-in", 0); + let stream_key = proxy.find_or_generate_stream_key(&msg, Some(Host::new("drive-me-in", 0))); let timestamp = msg.timestamp; let payload = match proxy.make_payload(msg, &stream_key) { Ok(payload) => { @@ -1276,14 +1288,14 @@ enum ExitServiceSearch { } trait StreamKeyFactory: Send { - fn make(&self, public_key: &PublicKey, host_name: &str, host_port: u16) -> StreamKey; + fn make(&self, public_key: &PublicKey, host_opt: Option) -> StreamKey; } struct StreamKeyFactoryReal {} impl StreamKeyFactory for StreamKeyFactoryReal { - fn make(&self, public_key: &PublicKey, host_name: &str, host_port: u16) -> StreamKey { - StreamKey::new(public_key, host_name, host_port) + fn make(&self, public_key: &PublicKey, host_opt: Option) -> StreamKey { + StreamKey::new(public_key, host_opt) } } @@ -1508,16 +1520,16 @@ mod tests { } struct StreamKeyFactoryMock { - make_parameters: Arc>>, + make_parameters: Arc)>>>, make_results: RefCell>, } impl StreamKeyFactory for StreamKeyFactoryMock { - fn make(&self, public_key: &PublicKey, host_name: &str, host_port: u16) -> StreamKey { + fn make(&self, public_key: &PublicKey, host_opt: Option) -> StreamKey { self.make_parameters .lock() .unwrap() - .push((public_key.clone(), host_name.to_string(), host_port)); + .push((public_key.clone(), host_opt)); self.make_results.borrow_mut().remove(0) } } @@ -1532,7 +1544,7 @@ mod tests { fn make_parameters( mut self, - params: &Arc>>, + params: &Arc)>>>, ) -> StreamKeyFactoryMock { self.make_parameters = params.clone(); self @@ -1710,7 +1722,7 @@ mod tests { let mut make_parameters = make_parameters_arc_a.lock().unwrap(); assert_eq!( make_parameters.remove(0), - (main_cryptde.public_key().clone(), "nowhere.com".to_string(), HTTP_PORT) + (main_cryptde.public_key().clone(), Some(Host::new("nowhere.com", HTTP_PORT))) ); let recording = neighborhood_recording_arc.lock().unwrap(); let record = recording.get_record::(0); @@ -1829,7 +1841,7 @@ mod tests { let mut make_parameters = make_parameters_arc.lock().unwrap(); assert_eq!( make_parameters.remove(0), - (main_cryptde.public_key().clone(), "realdomain.nu".to_string(), 443) + (main_cryptde.public_key().clone(), Some(Host::new("realdomain.nu", 443))) ); let hopper_recording = hopper_recording_arc.lock().unwrap(); @@ -6465,6 +6477,153 @@ mod tests { prove_that_crash_request_handler_is_hooked_up(proxy_server, CRASH_KEY); } + #[test] + fn find_or_generate_stream_key_prioritizes_existing_stream_key_first() { + let host = Host::new("host", 1234); + let stream_key = StreamKey::new(main_cryptde().public_key(), Some(host.clone())); + let socket_addr = SocketAddr::from_str("1.2.3.4:4321").unwrap(); + let mut subject = ProxyServer::new(main_cryptde(), alias_cryptde(), true, None, false, false); + subject.keys_and_addrs.insert(stream_key, socket_addr); + let ibcd = InboundClientData{ + timestamp: SystemTime::now(), + peer_addr: socket_addr, + reception_port: Some(2222), + last_data: true, + is_clandestine: false, + sequence_number: Some(333), + data: b"GET /index.html HTTP/1.1\r\nHost: header.com:3333\r\n\r\n".to_vec(), + }; + + let result = subject.find_or_generate_stream_key(&ibcd, Some(Host::new("passed.in", 9999))); + + assert_eq!(result, stream_key); + } + + #[test] + fn find_or_generate_stream_key_prioritizes_passed_in_host_second() { + let host = Host::new("host.com", 3333); + let stream_key = StreamKey::new(main_cryptde().public_key(), Some(host.clone())); + let socket_addr = SocketAddr::from_str("1.2.3.4:4321").unwrap(); + let mut subject = ProxyServer::new(main_cryptde(), alias_cryptde(), + true, None, false, false); + let ibcd = InboundClientData{ + timestamp: SystemTime::now(), + peer_addr: socket_addr, + reception_port: Some(2222), + last_data: true, + is_clandestine: false, + sequence_number: Some(333), + data: b"GET /index.html HTTP/1.1\r\nHost: header.com:4444\r\n\r\n".to_vec(), + }; + + let result = subject.find_or_generate_stream_key(&ibcd, Some(host.clone())); + + let stream_key = StreamKey::new(main_cryptde().public_key(), Some(host.clone())); + assert_eq!(result, stream_key); + assert_eq!(subject.keys_and_addrs.a_to_b(&stream_key), Some(socket_addr)); + } + + #[test] + fn find_or_generate_stream_key_prioritizes_http_data_host_third() { + let host = Host::new("host.com", 3333); + let stream_key = StreamKey::new(main_cryptde().public_key(), Some(host.clone())); + let socket_addr = SocketAddr::from_str("1.2.3.4:4321").unwrap(); + let mut subject = ProxyServer::new(main_cryptde(), alias_cryptde(), + true, None, false, false); + let ibcd = InboundClientData{ + timestamp: SystemTime::now(), + peer_addr: socket_addr, + reception_port: Some(2222), + last_data: true, + is_clandestine: false, + sequence_number: Some(333), + data: b"GET /index.html HTTP/1.1\r\nHost: header.com:4444\r\n\r\n".to_vec(), + }; + + let result = subject.find_or_generate_stream_key(&ibcd, None); + + let host = Host::new("header.com", 4444); + let stream_key = StreamKey::new(main_cryptde().public_key(), + Some(host)); + assert_eq!(result, stream_key); + assert_eq!(subject.keys_and_addrs.a_to_b(&stream_key), Some(socket_addr)); + } + + #[test] + fn find_or_generate_stream_key_prioritizes_tls_data_host_third() { + let host = Host::new("host.com", 3333); + let stream_key = StreamKey::new(main_cryptde().public_key(), Some(host.clone())); + let socket_addr = SocketAddr::from_str("1.2.3.4:4321").unwrap(); + let mut subject = ProxyServer::new(main_cryptde(), alias_cryptde(), + true, None, false, false); + let ibcd = InboundClientData{ + timestamp: SystemTime::now(), + peer_addr: socket_addr, + reception_port: Some(2222), + last_data: true, + is_clandestine: false, + sequence_number: Some(333), + data: vec![ + 0x16, // content_type: Handshake + 0x00, 0x00, 0x00, 0x00, // version, length: don't care + 0x01, // handshake_type: ClientHello + 0x00, 0x00, 0x00, 0x00, 0x00, // length, version: don't care + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // random: don't care + 0x01, // session_id_length + 0x00, // session_id: don't care + 0x00, 0x01, // cipher_suites_length + 0x00, // cipher_suite: don't care + 0x01, // compression_methods_length + 0x00, // compression_method: don't care + 0x00, 0x13, // extensions_length + 0x00, 0x00, // extension_type: server_name + 0x00, 0x0F, // extension_length + 0x00, 0x0D, // server_name_list_length + 0x00, // server_name_type + 0x00, 0x0A, // server_name_length + b's', b'e', b'r', b'v', b'e', b'r', b'.', b'c', + b'o', b'm', // server_name + ], + }; + + let result = subject.find_or_generate_stream_key(&ibcd, None); + + let host = Host::new("server.com", 443); + let stream_key = StreamKey::new(main_cryptde().public_key(), + Some(host)); + assert_eq!(result, stream_key); + assert_eq!(subject.keys_and_addrs.a_to_b(&stream_key), Some(socket_addr)); + } + + #[test] + fn find_or_generate_stream_key_uses_random_garbage_as_last_resort() { + let host = Host::new("host.com", 3333); + let stream_key = StreamKey::new(main_cryptde().public_key(), Some(host.clone())); + let socket_addr = SocketAddr::from_str("1.2.3.4:4321").unwrap(); + let mut subject = ProxyServer::new(main_cryptde(), alias_cryptde(), + true, None, false, false); + let ibcd = InboundClientData{ + timestamp: SystemTime::now(), + peer_addr: socket_addr, + reception_port: Some(2222), + last_data: true, + is_clandestine: false, + sequence_number: Some(333), + data: vec![], + }; + + let result = subject.find_or_generate_stream_key(&ibcd, None); + + let host = Host::new("44444444", 0x3434); + let stream_key = StreamKey::new(main_cryptde().public_key(), + Some(host)); + assert_eq!(result, stream_key); + assert_eq!(subject.keys_and_addrs.a_to_b(&stream_key), Some(socket_addr)); + } + fn make_exit_service_from_key(public_key: PublicKey) -> ExpectedService { ExpectedService::Exit(public_key, make_wallet("exit wallet"), rate_pack(100)) } diff --git a/node/src/proxy_server/protocol_pack.rs b/node/src/proxy_server/protocol_pack.rs index 38db8e6ff..1be582267 100644 --- a/node/src/proxy_server/protocol_pack.rs +++ b/node/src/proxy_server/protocol_pack.rs @@ -5,12 +5,7 @@ use crate::sub_lib::cryptde::PlainData; use crate::sub_lib::dispatcher::InboundClientData; use crate::sub_lib::proxy_server::ProxyProtocol; use masq_lib::constants::{HTTP_PORT, TLS_PORT}; - -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct Host { - pub name: String, - pub port: Option, -} +use crate::proxy_server::Host; pub trait ProtocolPack: Send + Sync { fn proxy_protocol(&self) -> ProxyProtocol; diff --git a/node/src/proxy_server/tls_protocol_pack.rs b/node/src/proxy_server/tls_protocol_pack.rs index accdf7419..9ea7bb1bb 100644 --- a/node/src/proxy_server/tls_protocol_pack.rs +++ b/node/src/proxy_server/tls_protocol_pack.rs @@ -1,6 +1,7 @@ use masq_lib::constants::TLS_PORT; +use crate::proxy_server::Host; // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::proxy_server::protocol_pack::{Host, ProtocolPack, ServerImpersonator}; +use crate::proxy_server::protocol_pack::{ProtocolPack, ServerImpersonator}; use crate::proxy_server::server_impersonator_tls::ServerImpersonatorTls; use crate::sub_lib::binary_traverser::BinaryTraverser; use crate::sub_lib::cryptde::PlainData; @@ -26,7 +27,7 @@ impl ProtocolPack for TlsProtocolPack { return None; } match Self::host_name_from_client_hello(&mut xvsr) { - Ok(name) => Some(Host { name, port: Some(self.standard_port()) }), + Ok(name) => Some(Host { name, port: TLS_PORT }), Err(()) => None, } } @@ -710,7 +711,7 @@ mod tests { assert_eq!( Some(Host { name: String::from("server.com"), - port: Some(TLS_PORT), + port: TLS_PORT, }), result ); @@ -755,7 +756,7 @@ mod tests { assert_eq!( Some(Host { name: String::from("server.com"), - port: Some(TLS_PORT) + port: TLS_PORT }), result ); diff --git a/node/src/sub_lib/stream_key.rs b/node/src/sub_lib/stream_key.rs index 11a6d12c0..e1212318c 100644 --- a/node/src/sub_lib/stream_key.rs +++ b/node/src/sub_lib/stream_key.rs @@ -9,6 +9,7 @@ use serde::Serialize; use serde::Serializer; use sodiumoxide::randombytes::randombytes_into; use std::fmt; +use crate::proxy_server::Host; lazy_static! { static ref STREAM_KEY_SALT: [u8; 8] = { @@ -83,10 +84,13 @@ impl<'a> Visitor<'a> for StreamKeyVisitor { } impl StreamKey { - pub fn new(public_key: &PublicKey, host_name: &str, host_port: u16) -> StreamKey { + pub fn new(public_key: &PublicKey, host_opt: Option) -> StreamKey { let mut hash = sha1::Sha1::new(); hash.update(public_key.as_ref()); - hash = add_host_name_and_port_to_hash(hash, host_name, host_port); + hash = match host_opt { + Some(host) => add_host_name_and_port_to_hash(hash, &host.name, host.port), + None => todo!("Drive in making fake hostname and port from CryptDE"), + }; hash.update(STREAM_KEY_SALT.as_slice()); StreamKey { hash: hash.digest().bytes(), @@ -129,7 +133,7 @@ mod tests { let host_names = (0..stream_key_count).map(|i| format!("host_name_{}", i)); let stream_keys = host_names - .map(|host_name| StreamKey::new(&public_key, &host_name, 443)) + .map(|host_name| StreamKey::new(&public_key, Some(Host::new(&host_name, 443)))) .collect_vec(); (0..(stream_key_count - 1)).for_each(|a| { @@ -146,7 +150,7 @@ mod tests { let host_ports = (0..stream_key_count).map(|i| (1024 + i) as u16); let stream_keys = host_ports - .map(|host_port| StreamKey::new(&public_key, "host-name", host_port)) + .map(|host_port| StreamKey::new(&public_key, Some(Host::new("host-name", host_port)))) .collect_vec(); (0..(stream_key_count - 1)).for_each(|a| { @@ -162,7 +166,7 @@ mod tests { let stream_key_count = 100; let stream_keys = (0..stream_key_count) - .map(|_| StreamKey::new(&public_key, "host-name", 443)) + .map(|_| StreamKey::new(&public_key, Some(Host::new("host-name", 443)))) .collect_vec(); (1..stream_key_count).for_each(|i| { @@ -174,7 +178,7 @@ mod tests { fn stream_keys_from_different_public_keys_are_different() { let stream_keys = vec![PublicKey::new(&[1, 2, 3]), PublicKey::new(&[1, 2, 2])] .iter() - .map(|public_key| StreamKey::new(public_key, "host-name", 443)) + .map(|public_key| StreamKey::new(public_key, Some(Host::new("host-name", 443)))) .collect_vec(); assert_ne!(stream_keys[0], stream_keys[1]); @@ -185,7 +189,7 @@ mod tests { let public_key = main_cryptde().public_key(); let host_name = "host-name"; - let result = StreamKey::new(&public_key, host_name, 443); + let result = StreamKey::new(&public_key, Some(Host::new(host_name, 443))); let mut hash = sha1::Sha1::new(); hash.update(public_key.as_ref()); From 45ea8b4ec73b2ca06e0121ae43b3f25a715f256e Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Thu, 27 Mar 2025 06:58:48 -0400 Subject: [PATCH 09/13] Revert "More BaseSepolia stuff" This reverts commit 10735ada8a237f8a82b44b829026935f6ce8e02a. --- node/src/actor_system_factory.rs | 4 ++-- .../blockchain_interface_web3/utils.rs | 2 +- node/src/bootstrapper.rs | 12 ++++++------ node/src/daemon/setup_reporter.rs | 18 +++++++++--------- node/src/database/db_initializer.rs | 4 ++-- .../migrations/migration_1_to_2.rs | 2 +- .../migrations/migration_4_to_5.rs | 2 +- node/src/neighborhood/node_record.rs | 4 ++-- node/src/sub_lib/route.rs | 16 ++++++++-------- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/node/src/actor_system_factory.rs b/node/src/actor_system_factory.rs index 8ab3426cf..20ee55ed2 100644 --- a/node/src/actor_system_factory.rs +++ b/node/src/actor_system_factory.rs @@ -1197,7 +1197,7 @@ mod tests { when_pending_too_long_sec: DEFAULT_PENDING_TOO_LONG_SEC, }; let persistent_config = PersistentConfigurationMock::default() - .chain_name_result("base-sepolia".to_string()) + .chain_name_result("eth-ropsten".to_string()) .set_min_hops_result(Ok(())); Bootstrapper::pub_initialize_cryptdes_for_testing( &Some(main_cryptde()), @@ -1953,7 +1953,7 @@ mod tests { #[test] #[should_panic( - expected = "Database with a wrong chain name detected; expected: base-sepolia, was: eth-mainnet" + expected = "Database with a wrong chain name detected; expected: eth-ropsten, was: eth-mainnet" )] fn make_and_start_actors_does_not_tolerate_differences_in_setup_chain_and_database_chain() { let mut bootstrapper_config = BootstrapperConfig::new(); diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs index 03ed4150b..2be7d5977 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs @@ -507,7 +507,7 @@ mod tests { Transactions in the batch:\n\ \n\ gas price: 120 wei\n\ - chain: sepolia\n\ + chain: ropsten\n\ \n\ [wallet address] [payment in wei]\n\ 0x0000000000000000000000000000000077313233 900,000,000,000,000,000\n\ diff --git a/node/src/bootstrapper.rs b/node/src/bootstrapper.rs index 9e4e72698..2ef265e69 100644 --- a/node/src/bootstrapper.rs +++ b/node/src/bootstrapper.rs @@ -1206,11 +1206,11 @@ mod tests { NodeDescriptor::from(( main_cryptde_ref().public_key(), &NodeAddr::new(&IpAddr::from_str("1.2.3.4").unwrap(), &[5123]), - Chain::BaseSepolia, + Chain::EthRopsten, main_cryptde_ref() )) ); - TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://base-sepolia:.+@1\\.2\\.3\\.4:5123"); + TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://eth-ropsten:.+@1\\.2\\.3\\.4:5123"); } #[test] @@ -1322,11 +1322,11 @@ mod tests { NodeDescriptor::from(( main_cryptde_ref().public_key(), &NodeAddr::new(&IpAddr::from_str("1.2.3.4").unwrap(), &[5123]), - Chain::BaseSepolia, + Chain::EthRopsten, main_cryptde_ref() )) ); - TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://base-sepolia:.+@1\\.2\\.3\\.4:5123"); + TestLogHandler::new().exists_log_matching("INFO: Bootstrapper: MASQ Node local descriptor: masq://eth-ropsten:.+@1\\.2\\.3\\.4:5123"); } #[test] @@ -1571,7 +1571,7 @@ mod tests { cryptdes.main }; let expected_descriptor = format!( - "masq://base-sepolia:{}@2.3.4.5:3456/4567", + "masq://eth-ropsten:{}@2.3.4.5:3456/4567", cryptde_ref.public_key_to_descriptor_fragment(cryptde_ref.public_key()) ); TestLogHandler::new().exists_log_containing( @@ -1611,7 +1611,7 @@ mod tests { cryptdes }; let expected_descriptor = format!( - "masq://base-sepolia:{}@:", + "masq://eth-ropsten:{}@:", cryptdes .main .public_key_to_descriptor_fragment(cryptdes.main.public_key()) diff --git a/node/src/daemon/setup_reporter.rs b/node/src/daemon/setup_reporter.rs index 1ef47777f..84c1db1e5 100644 --- a/node/src/daemon/setup_reporter.rs +++ b/node/src/daemon/setup_reporter.rs @@ -1488,7 +1488,7 @@ mod tests { ("mapping-protocol", "pmp", Set), ("min-hops", "2", Set), ("neighborhood-mode", "originate-only", Set), - ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), + ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), ("payment-thresholds","1234|50000|1000|1000|20000|20000",Set), ("rate-pack","1|3|3|8",Set), #[cfg(not(target_os = "windows"))] @@ -1518,7 +1518,7 @@ mod tests { ("mapping-protocol", "pmp", Set), ("min-hops", "2", Set), ("neighborhood-mode", "originate-only", Set), - ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), + ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), ("payment-thresholds","1234|50000|1000|1000|20000|20000",Set), ("rate-pack","1|3|3|8",Set), #[cfg(not(target_os = "windows"))] @@ -1558,7 +1558,7 @@ mod tests { ("mapping-protocol", "igdp"), ("min-hops", "2"), ("neighborhood-mode", "originate-only"), - ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), + ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), ("payment-thresholds","1234|50000|1000|1000|15000|15000"), ("rate-pack","1|3|3|8"), #[cfg(not(target_os = "windows"))] @@ -1593,7 +1593,7 @@ mod tests { ("mapping-protocol", "igdp", Set), ("min-hops", "2", Set), ("neighborhood-mode", "originate-only", Set), - ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), + ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Set), ("payment-thresholds","1234|50000|1000|1000|15000|15000",Set), ("rate-pack","1|3|3|8",Set), #[cfg(not(target_os = "windows"))] @@ -1634,7 +1634,7 @@ mod tests { ("MASQ_MAPPING_PROTOCOL", "pmp"), ("MASQ_MIN_HOPS", "2"), ("MASQ_NEIGHBORHOOD_MODE", "originate-only"), - ("MASQ_NEIGHBORS", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), + ("MASQ_NEIGHBORS", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), ("MASQ_PAYMENT_THRESHOLDS","12345|50000|1000|1234|19000|20000"), ("MASQ_RATE_PACK","1|3|3|8"), #[cfg(not(target_os = "windows"))] @@ -1666,7 +1666,7 @@ mod tests { ("mapping-protocol", "pmp", Configured), ("min-hops", "2", Configured), ("neighborhood-mode", "originate-only", Configured), - ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), + ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), ("payment-thresholds","12345|50000|1000|1234|19000|20000",Configured), ("rate-pack","1|3|3|8",Configured), #[cfg(not(target_os = "windows"))] @@ -1884,7 +1884,7 @@ mod tests { ("MASQ_MAPPING_PROTOCOL", "pcp"), ("MASQ_MIN_HOPS", "2"), ("MASQ_NEIGHBORHOOD_MODE", "originate-only"), - ("MASQ_NEIGHBORS", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), + ("MASQ_NEIGHBORS", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678"), ("MASQ_PAYMENT_THRESHOLDS","1234|50000|1000|1000|20000|20000"), ("MASQ_RATE_PACK","1|3|3|8"), #[cfg(not(target_os = "windows"))] @@ -1946,7 +1946,7 @@ mod tests { ("neighborhood-mode", "consume-only", Set), ( "neighbors", - "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@9.10.11.12:9101", + "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@9.10.11.12:9101", Set, ), ("payment-thresholds", "4321|66666|777|987|123456|124444", Set), @@ -1982,7 +1982,7 @@ mod tests { ("mapping-protocol", "pcp", Configured), ("min-hops", "2", Configured), ("neighborhood-mode", "originate-only", Configured), - ("neighbors", "masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://base-sepolia:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), + ("neighbors", "masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@1.2.3.4:1234,masq://eth-ropsten:MTIzNDU2Nzg5MTEyMzQ1Njc4OTIxMjM0NTY3ODkzMTI@5.6.7.8:5678", Configured), ("payment-thresholds","1234|50000|1000|1000|20000|20000",Configured), ("rate-pack","1|3|3|8",Configured), #[cfg(not(target_os = "windows"))] diff --git a/node/src/database/db_initializer.rs b/node/src/database/db_initializer.rs index 39c0c332e..3619cc1b4 100644 --- a/node/src/database/db_initializer.rs +++ b/node/src/database/db_initializer.rs @@ -1153,7 +1153,7 @@ mod tests { init_test_logging(); let home_dir = ensure_node_home_directory_exists( "db_initializer", - "database_of_old_version_comes_to_migrator_where_it_gradually_migrates_to_upper_versions", + "existing_database_with_the_wrong_version_comes_to_migrator_that_makes_it_gradually_migrate_to_upper_versions", ); let updated_db_path_dir = &home_dir.join("updated"); let from_scratch_db_path_dir = &home_dir.join("from_scratch"); @@ -1168,7 +1168,7 @@ mod tests { .initialize( &updated_db_path_dir, DbInitializationConfig::create_or_migrate(ExternalData::new( - Chain::BaseSepolia, + Chain::EthRopsten, NeighborhoodModeLight::Standard, Some("password".to_string()), )), diff --git a/node/src/database/db_migrations/migrations/migration_1_to_2.rs b/node/src/database/db_migrations/migrations/migration_1_to_2.rs index 23447ba1c..d92bcaf68 100644 --- a/node/src/database/db_migrations/migrations/migration_1_to_2.rs +++ b/node/src/database/db_migrations/migrations/migration_1_to_2.rs @@ -68,7 +68,7 @@ mod tests { let connection = result.unwrap(); let (chn_value, chn_encrypted) = retrieve_config_row(connection.as_ref(), "chain_name"); let (cs_value, cs_encrypted) = retrieve_config_row(connection.as_ref(), "schema_version"); - assert_eq!(chn_value, Some("base-sepolia".to_string())); + assert_eq!(chn_value, Some("eth-ropsten".to_string())); assert_eq!(chn_encrypted, false); assert_eq!(cs_value, Some("2".to_string())); assert_eq!(cs_encrypted, false); diff --git a/node/src/database/db_migrations/migrations/migration_4_to_5.rs b/node/src/database/db_migrations/migrations/migration_4_to_5.rs index 06deb809f..dbc40f1b3 100644 --- a/node/src/database/db_migrations/migrations/migration_4_to_5.rs +++ b/node/src/database/db_migrations/migrations/migration_4_to_5.rs @@ -227,7 +227,7 @@ mod tests { let config_table_after = fetch_all_from_config_table(&conn); assert_eq!(config_table_before, config_table_after); assert_on_schema_5_was_adopted(conn_schema5.as_ref()); - TestLogHandler::new().exists_log_containing("WARN: DbMigrator: Migration from 4 to 5: database belonging to the chain 'base-sepolia'; \ + TestLogHandler::new().exists_log_containing("WARN: DbMigrator: Migration from 4 to 5: database belonging to the chain 'eth-ropsten'; \ we discovered possibly abandoned transactions that are said yet to be pending, these are: \ '0x0000000000000000000000000000000000000000000000000000000002b594d1', \ '0x00000000000000000000000000000000000000000000000000000000000f41d0'; continuing"); diff --git a/node/src/neighborhood/node_record.rs b/node/src/neighborhood/node_record.rs index d2546e03c..e490cec1d 100644 --- a/node/src/neighborhood/node_record.rs +++ b/node/src/neighborhood/node_record.rs @@ -409,7 +409,7 @@ mod tests { result, NodeDescriptor::try_from(( main_cryptde(), - "masq://base-sepolia:AQIDBA@1.2.3.4:1234/2345" + "masq://eth-ropsten:AQIDBA@1.2.3.4:1234/2345" )) .unwrap() ); @@ -424,7 +424,7 @@ mod tests { assert_eq!( result, - NodeDescriptor::try_from((main_cryptde(), "masq://base-sepolia:AQIDBA@:")).unwrap() + NodeDescriptor::try_from((main_cryptde(), "masq://eth-ropsten:AQIDBA@:")).unwrap() ); } diff --git a/node/src/sub_lib/route.rs b/node/src/sub_lib/route.rs index ecbd0261e..8415c758b 100644 --- a/node/src/sub_lib/route.rs +++ b/node/src/sub_lib/route.rs @@ -781,9 +781,9 @@ mod tests { result, String::from( r#" -Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d", s: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d" } }), component: Hopper } -Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a", s: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a" } }), component: Hopper } -Encrypted with 0x03040506: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9", s: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9" } }), component: Neighborhood } +Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320", s: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320" } }), component: Hopper } +Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b", s: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b" } }), component: Hopper } +Encrypted with 0x03040506: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e", s: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e" } }), component: Neighborhood } "# ) ); @@ -818,11 +818,11 @@ Encrypted with 0x03040506: LiveHop { public_key: 0x, payer: Some(Payer { wallet: result, String::from( r#" -Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d", s: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d" } }), component: Hopper } -Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a", s: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a" } }), component: Hopper } -Encrypted with 0x03040506: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9", s: "8649b8f6db6232cb1e4f1f04786ad4ef33488c968e64bec74ecd893d6d05c1b9" } }), component: ProxyClient } -Encrypted with 0x02030405: LiveHop { public_key: 0x01020304, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a", s: "4324a40295bb36ef2b927fb24250fe42397a57b861ea152bbbe4f84150d4ff5a" } }), component: Hopper } -Encrypted with 0x01020304: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d", s: "3e3a92d7284c2c2ff7119e9f7a7e183b062a335a598e965a47c36a2f288b6f8d" } }), component: ProxyServer } +Encrypted with 0x01020304: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320", s: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320" } }), component: Hopper } +Encrypted with 0x02030405: LiveHop { public_key: 0x03040506, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b", s: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b" } }), component: Hopper } +Encrypted with 0x03040506: LiveHop { public_key: 0x02030405, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e", s: "9ca23557adf96d7aed407a06ce96851a4184e947a7b29b6c3872eef902fcba1e" } }), component: ProxyClient } +Encrypted with 0x02030405: LiveHop { public_key: 0x01020304, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 1, r: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b", s: "63be72962f19dda7802220ed48c0d8199d510b45608a3789c50f61912b98a15b" } }), component: Hopper } +Encrypted with 0x01020304: LiveHop { public_key: 0x, payer: Some(Payer { wallet: Wallet { kind: Address(0x71d0fc7d1c570b1ed786382b551a09391c91e33d) }, proof: Signature { v: 0, r: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320", s: "8b663e5a10f40c3307e6fb5340482a5e11df78dafc619ceff97f11fa79fea320" } }), component: ProxyServer } Encrypted with 0x01020304: Return Route ID: 1234 "# ) From f4f6403d6f9ce396b677340278e10afb03e91af6 Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Thu, 27 Mar 2025 07:18:49 -0400 Subject: [PATCH 10/13] Everything's compiling now --- node/src/dispatcher.rs | 24 ++--- node/src/hopper/consuming_service.rs | 4 +- node/src/hopper/mod.rs | 4 +- node/src/hopper/routing_service.rs | 46 ++++----- .../client_request_payload_factory.rs | 16 +-- node/src/proxy_server/mod.rs | 98 +++++++++---------- node/src/stream_handler_pool.rs | 8 +- node/src/stream_reader.rs | 16 +-- node/src/sub_lib/dispatcher.rs | 12 +-- node/src/sub_lib/stream_key.rs | 24 ++--- 10 files changed, 126 insertions(+), 126 deletions(-) diff --git a/node/src/dispatcher.rs b/node/src/dispatcher.rs index b3de16740..067ddf22a 100644 --- a/node/src/dispatcher.rs +++ b/node/src/dispatcher.rs @@ -260,12 +260,12 @@ mod tests { let proxy_server = Recorder::new(); let recording_arc = proxy_server.get_recording(); let awaiter = proxy_server.get_awaiter(); - let peer_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let reception_port = Some(8080); let data: Vec = vec![9, 10, 11]; let ibcd_in = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port, sequence_number: Some(0), last_data: false, @@ -285,10 +285,10 @@ mod tests { let recording = recording_arc.lock().unwrap(); let message = recording.get_record::(0); - let actual_socket_addr = message.peer_addr.clone(); + let actual_socket_addr = message.client_addr.clone(); let actual_data = message.data.clone(); - assert_eq!(actual_socket_addr, peer_addr); + assert_eq!(actual_socket_addr, client_addr); assert_eq!(actual_data, data); assert_eq!(recording.len(), 1); } @@ -299,12 +299,12 @@ mod tests { let subject = Dispatcher::new(NODE_DESCRIPTOR.clone(), false); let subject_addr = subject.start(); let (hopper, hopper_awaiter, hopper_recording_arc) = make_recorder(); - let peer_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let reception_port = Some(8080); let data: Vec = vec![9, 10, 11]; let ibcd_in = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port, last_data: false, is_clandestine: true, @@ -324,10 +324,10 @@ mod tests { let hopper_recording = hopper_recording_arc.lock().unwrap(); let message = hopper_recording.get_record::(0); - let actual_socket_addr = message.peer_addr.clone(); + let actual_socket_addr = message.client_addr.clone(); let actual_data = message.data.clone(); - assert_eq!(actual_socket_addr, peer_addr); + assert_eq!(actual_socket_addr, client_addr); assert_eq!(actual_data, data); assert_eq!(hopper_recording.len(), 1); } @@ -339,12 +339,12 @@ mod tests { let subject = Dispatcher::new(NODE_DESCRIPTOR.clone(), false); let subject_addr = subject.start(); let subject_ibcd = subject_addr.recipient::(); - let peer_addr = SocketAddr::from_str("1.2.3.4:8765").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:8765").unwrap(); let reception_port = Some(1234); let data: Vec = vec![9, 10, 11]; let ibcd_in = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port, last_data: false, is_clandestine: false, @@ -365,12 +365,12 @@ mod tests { let subject = Dispatcher::new(NODE_DESCRIPTOR.clone(), false); let subject_addr = subject.start(); let subject_ibcd = subject_addr.recipient::(); - let peer_addr = SocketAddr::from_str("1.2.3.4:8765").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:8765").unwrap(); let reception_port = Some(1234); let data: Vec = vec![9, 10, 11]; let ibcd_in = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port, last_data: false, is_clandestine: true, diff --git a/node/src/hopper/consuming_service.rs b/node/src/hopper/consuming_service.rs index 7593e36ed..b0df18b1f 100644 --- a/node/src/hopper/consuming_service.rs +++ b/node/src/hopper/consuming_service.rs @@ -95,7 +95,7 @@ impl ConsumingService { fn zero_hop(&self, encrypted_package: CryptData) { let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0), + client_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0), reception_port: None, last_data: false, is_clandestine: true, @@ -302,7 +302,7 @@ mod tests { *record, InboundClientData { timestamp: record.timestamp, - peer_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0), + client_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0), reception_port: None, last_data: false, is_clandestine: true, diff --git a/node/src/hopper/mod.rs b/node/src/hopper/mod.rs index 49e93bec4..8cfe5e955 100644 --- a/node/src/hopper/mod.rs +++ b/node/src/hopper/mod.rs @@ -171,7 +171,7 @@ mod tests { fn panics_if_routing_service_is_unbound() { let main_cryptde = main_cryptde(); let alias_cryptde = alias_cryptde(); - let peer_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let route = route_to_proxy_client(&main_cryptde.public_key(), main_cryptde); let serialized_payload = serde_cbor::ser::to_vec(&make_meaningless_message_type()).unwrap(); let data = main_cryptde @@ -189,7 +189,7 @@ mod tests { let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr, + client_addr, reception_port: None, last_data: false, is_clandestine: false, diff --git a/node/src/hopper/routing_service.rs b/node/src/hopper/routing_service.rs index 3ebaaab65..18573eb59 100644 --- a/node/src/hopper/routing_service.rs +++ b/node/src/hopper/routing_service.rs @@ -63,9 +63,9 @@ impl RoutingService { self.logger, "Instructed to route {} bytes of InboundClientData ({}) from Dispatcher", data_size, - ibcd.peer_addr + ibcd.client_addr ); - let peer_addr = ibcd.peer_addr; + let peer_addr = ibcd.client_addr; let last_data = ibcd.last_data; let ibcd_but_data = ibcd.clone_but_data(); @@ -79,7 +79,7 @@ impl RoutingService { self.logger, "Couldn't decode CORES package in {}-byte buffer from {}: {:?}", ibcd.data.len(), - ibcd.peer_addr, + ibcd.client_addr, e ); return; @@ -185,7 +185,7 @@ impl RoutingService { .expect("Encryption of LiveCoresPackage failed"); let inbound_client_data = InboundClientData { timestamp: ibcd_but_data.timestamp, - peer_addr: ibcd_but_data.peer_addr, + client_addr: ibcd_but_data.client_addr, reception_port: ibcd_but_data.reception_port, last_data: ibcd_but_data.last_data, is_clandestine: ibcd_but_data.is_clandestine, @@ -554,7 +554,7 @@ mod tests { let data_enc = encodex(cryptdes.main, &cryptdes.main.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: false, @@ -602,7 +602,7 @@ mod tests { let data_enc = encodex(cryptdes.main, &cryptdes.main.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: false, @@ -649,7 +649,7 @@ mod tests { let data_enc = encodex(main_cryptde, main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: false, @@ -701,7 +701,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: false, @@ -755,7 +755,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: true, @@ -828,7 +828,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, sequence_number: None, last_data: true, @@ -887,7 +887,7 @@ mod tests { let lcp_enc = encodex(main_cryptde, main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), reception_port: None, last_data: false, is_clandestine: true, @@ -968,7 +968,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), reception_port: None, last_data: false, is_clandestine: true, @@ -1044,7 +1044,7 @@ mod tests { let data_enc = encodex(cryptde, &cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.3.2.4:5678").unwrap(), reception_port: None, last_data: false, is_clandestine: true, @@ -1124,7 +1124,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1220,7 +1220,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1266,7 +1266,7 @@ mod tests { *record, InboundClientData { timestamp: record.timestamp, - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1306,7 +1306,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1407,7 +1407,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1591,7 +1591,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1665,7 +1665,7 @@ mod tests { let data_enc = encodex(main_cryptde, &main_cryptde.public_key(), &lcp).unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1712,7 +1712,7 @@ mod tests { init_test_logging(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1770,7 +1770,7 @@ mod tests { .unwrap(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, @@ -1840,7 +1840,7 @@ mod tests { let lcp = LiveCoresPackage::new(Route { hops: vec![] }, CryptData::new(&[])); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: None, last_data: true, is_clandestine: true, diff --git a/node/src/proxy_server/client_request_payload_factory.rs b/node/src/proxy_server/client_request_payload_factory.rs index 006f37a13..36fa03fdf 100644 --- a/node/src/proxy_server/client_request_payload_factory.rs +++ b/node/src/proxy_server/client_request_payload_factory.rs @@ -88,7 +88,7 @@ mod tests { let data = PlainData::new(&b"GET http://borkoed.com:2345/fleebs.html HTTP/1.1\r\n\r\n"[..]); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: Some(HTTP_PORT), sequence_number: Some(1), last_data: false, @@ -125,7 +125,7 @@ mod tests { let data = PlainData::new(&b"GET http://borkoed.com/fleebs.html HTTP/1.1\r\n\r\n"[..]); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: Some(HTTP_PORT), sequence_number: Some(1), last_data: false, @@ -180,7 +180,7 @@ mod tests { ]); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), sequence_number: Some(0), reception_port: Some(443), last_data: false, @@ -230,7 +230,7 @@ mod tests { ]); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: Some(443), last_data: true, is_clandestine: false, @@ -267,7 +267,7 @@ mod tests { let test_name = "makes_no_payload_if_origin_port_is_not_specified"; let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), sequence_number: Some(0), reception_port: None, last_data: false, @@ -293,7 +293,7 @@ mod tests { let test_name = "makes_no_payload_if_origin_port_is_unknown"; let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:5678").unwrap(), reception_port: Some(1234), sequence_number: Some(0), last_data: false, @@ -315,7 +315,7 @@ mod tests { fn use_sequence_from_inbound_client_data_in_client_request_payload() { let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:80").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:80").unwrap(), reception_port: Some(HTTP_PORT), sequence_number: Some(1), last_data: false, @@ -344,7 +344,7 @@ mod tests { let test_name = "makes_no_payload_if_sequence_number_is_unknown"; let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:80").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:80").unwrap(), reception_port: Some(HTTP_PORT), last_data: false, is_clandestine: false, diff --git a/node/src/proxy_server/mod.rs b/node/src/proxy_server/mod.rs index d830156a8..7cfc3a80d 100644 --- a/node/src/proxy_server/mod.rs +++ b/node/src/proxy_server/mod.rs @@ -565,14 +565,14 @@ impl ProxyServer { let http_data = HttpProtocolPack {}.find_host(&msg.data.clone().into()); match http_data { Some(ref host) if host.port == Some(443) => { - let stream_key = self.find_or_generate_stream_key(msg, msg.peer_addr); + let stream_key = self.find_or_generate_stream_key(msg, msg.client_addr); self.tunneled_hosts.insert(stream_key, host.name.clone()); self.subs .as_ref() .expect("Dispatcher unbound in ProxyServer") .dispatcher .try_send(TransmitDataMsg { - endpoint: Endpoint::Socket(msg.peer_addr), + endpoint: Endpoint::Socket(msg.client_addr), last_data: false, sequence_number: msg.sequence_number, data: b"HTTP/1.1 200 OK\r\n\r\n".to_vec(), @@ -585,7 +585,7 @@ impl ProxyServer { .expect("Dispatcher unbound in ProxyServer") .dispatcher .try_send(TransmitDataMsg { - endpoint: Endpoint::Socket(msg.peer_addr), + endpoint: Endpoint::Socket(msg.client_addr), last_data: true, sequence_number: msg.sequence_number, data: b"HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\n\r\n".to_vec(), @@ -627,7 +627,7 @@ impl ProxyServer { ); let ibcd = InboundClientData { timestamp: SystemTime::now(), - peer_addr: msg.peer_addr, + client_addr: msg.peer_addr, reception_port: Some(nca.reception_port), last_data: true, is_clandestine: false, @@ -645,28 +645,28 @@ impl ProxyServer { fn find_or_generate_stream_key( &mut self, ibcd: &InboundClientData, - server_addr: SocketAddr, + client_addr: SocketAddr, ) -> StreamKey { - match self.keys_and_addrs.b_to_a(&ibcd.peer_addr) { + match self.keys_and_addrs.b_to_a(&ibcd.client_addr) { Some(stream_key) => { debug!( self.logger, "find_or_generate_stream_key() retrieved existing key {} for {}", &stream_key, - ibcd.peer_addr + ibcd.client_addr ); stream_key } None => { let stream_key = self .stream_key_factory - .make(self.main_cryptde.public_key(), server_addr); - self.keys_and_addrs.insert(stream_key, ibcd.peer_addr); + .make(self.main_cryptde.public_key(), client_addr); + self.keys_and_addrs.insert(stream_key, ibcd.client_addr); debug!( self.logger, "find_or_generate_stream_key() inserted new key {} for {}", &stream_key, - ibcd.peer_addr + ibcd.client_addr ); stream_key } @@ -1117,7 +1117,7 @@ impl IBCDHelper for IBCDHelperReal { msg: InboundClientData, retire_stream_key: bool, ) -> Result<(), String> { - let source_addr = msg.peer_addr; + let client_addr = msg.client_addr; if proxy.consuming_wallet_balance.is_none() && proxy.is_decentralized { let protocol_pack = match from_ibcd(&msg) { Err(e) => return Err(e), @@ -1127,7 +1127,7 @@ impl IBCDHelper for IBCDHelperReal { .server_impersonator() .consuming_wallet_absent(); let msg = TransmitDataMsg { - endpoint: Endpoint::Socket(source_addr), + endpoint: Endpoint::Socket(client_addr), last_data: true, sequence_number: Some(0), data, @@ -1139,7 +1139,7 @@ impl IBCDHelper for IBCDHelperReal { .expect("Dispatcher is dead"); return Err("Browser request rejected due to missing consuming wallet".to_string()); } - let stream_key = proxy.find_or_generate_stream_key(&msg, source_addr); + let stream_key = proxy.find_or_generate_stream_key(&msg, client_addr); let timestamp = msg.timestamp; let payload = match proxy.make_payload(msg, &stream_key) { Ok(payload) => { @@ -1165,7 +1165,7 @@ impl IBCDHelper for IBCDHelperReal { .insert(stream_key, dns_failure_retry); } let tth_args = - TryTransmitToHopperArgs::new(proxy, payload, source_addr, timestamp, retire_stream_key); + TryTransmitToHopperArgs::new(proxy, payload, client_addr, timestamp, retire_stream_key); let pld = &tth_args.payload; if let Some(route_query_response) = proxy.stream_key_routes.get(&pld.stream_key) { debug!( @@ -1275,14 +1275,14 @@ enum ExitServiceSearch { } trait StreamKeyFactory: Send { - fn make(&self, public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey; + fn make(&self, public_key: &PublicKey, client_addr: SocketAddr) -> StreamKey; } struct StreamKeyFactoryReal {} impl StreamKeyFactory for StreamKeyFactoryReal { - fn make(&self, public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey { - StreamKey::new(public_key, server_addr) + fn make(&self, public_key: &PublicKey, client_addr: SocketAddr) -> StreamKey { + StreamKey::new(public_key, client_addr) } } @@ -1512,11 +1512,11 @@ mod tests { } impl StreamKeyFactory for StreamKeyFactoryMock { - fn make(&self, public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey { + fn make(&self, public_key: &PublicKey, client_addr: SocketAddr) -> StreamKey { self.make_parameters .lock() .unwrap() - .push((public_key.clone(), server_addr)); + .push((public_key.clone(), client_addr)); self.make_results.borrow_mut().remove(0) } } @@ -1643,7 +1643,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -1748,7 +1748,7 @@ mod tests { let request_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(8443), sequence_number: Some(0), last_data: false, @@ -1757,7 +1757,7 @@ mod tests { }; let tunnelled_msg = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(8443), sequence_number: Some(0), last_data: false, @@ -1880,7 +1880,7 @@ mod tests { let request_data = http_request.to_vec(); let inbound_client_data = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr, + client_addr: socket_addr, reception_port: Some(443), last_data: false, is_clandestine: false, @@ -1941,7 +1941,7 @@ mod tests { let request_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(8443), sequence_number: Some(0), last_data: false, @@ -2013,7 +2013,7 @@ mod tests { let request_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(8443), sequence_number: Some(0), last_data: false, @@ -2081,7 +2081,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2140,7 +2140,7 @@ mod tests { let expected_data = tls_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: true, @@ -2203,7 +2203,7 @@ mod tests { let socket_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2283,7 +2283,7 @@ mod tests { let socket_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: true, @@ -2368,7 +2368,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2488,7 +2488,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2577,7 +2577,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2639,7 +2639,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2693,7 +2693,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -2744,7 +2744,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -3030,7 +3030,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -3152,7 +3152,7 @@ mod tests { let stream_key = StreamKey::make_meaningless_stream_key(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -3329,7 +3329,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -3425,7 +3425,7 @@ mod tests { let expected_data = tls_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: false, @@ -3511,7 +3511,7 @@ mod tests { let expected_data = tls_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: false, @@ -3596,7 +3596,7 @@ mod tests { let expected_data = tls_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: client_addr, + client_addr: client_addr, reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: true, @@ -3687,7 +3687,7 @@ mod tests { let stream_key = StreamKey::make_meaningless_stream_key(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(TLS_PORT), sequence_number: Some(0), last_data: true, @@ -5527,7 +5527,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(80), sequence_number: Some(0), last_data: false, @@ -6062,7 +6062,7 @@ mod tests { let handle_normal_client_data = help_to_handle_normal_client_data_params_arc.lock().unwrap(); let (inbound_client_data_msg, retire_stream_key) = &handle_normal_client_data[0]; - assert_eq!(inbound_client_data_msg.peer_addr, socket_addr); + assert_eq!(inbound_client_data_msg.client_addr, socket_addr); assert_eq!(inbound_client_data_msg.data, Vec::::new()); assert_eq!(inbound_client_data_msg.last_data, true); assert_eq!(inbound_client_data_msg.is_clandestine, false); @@ -6078,7 +6078,7 @@ mod tests { proxy_server.subs = Some(make_proxy_server_out_subs()); let inbound_client_data_msg = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), reception_port: None, last_data: true, is_clandestine: false, @@ -6177,7 +6177,7 @@ mod tests { Box::new(ClientRequestPayloadFactoryMock::default().make_result(None)); let inbound_client_data_msg = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), reception_port: Some(568), last_data: true, is_clandestine: false, @@ -6217,7 +6217,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -6286,7 +6286,7 @@ mod tests { let expected_data = http_request.to_vec(); let msg_from_dispatcher = InboundClientData { timestamp: SystemTime::now(), - peer_addr: socket_addr.clone(), + client_addr: socket_addr.clone(), reception_port: Some(HTTP_PORT), sequence_number: Some(0), last_data: true, @@ -6412,7 +6412,7 @@ mod tests { proxy_server.subs = Some(make_proxy_server_out_subs()); let inbound_client_data_msg = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.4:4578").unwrap(), reception_port: Some(80), last_data: true, is_clandestine: false, diff --git a/node/src/stream_handler_pool.rs b/node/src/stream_handler_pool.rs index db9bdd4e3..470f0c44f 100644 --- a/node/src/stream_handler_pool.rs +++ b/node/src/stream_handler_pool.rs @@ -916,7 +916,7 @@ mod tests { dispatcher_record, &dispatcher::InboundClientData { timestamp: dispatcher_record.timestamp, - peer_addr: peer_addr_a, + client_addr: peer_addr_a, reception_port, last_data: false, is_clandestine, @@ -930,7 +930,7 @@ mod tests { dispatcher_record, &dispatcher::InboundClientData { timestamp: dispatcher_record.timestamp, - peer_addr: peer_addr_a, + client_addr: peer_addr_a, reception_port, last_data: false, is_clandestine, @@ -944,7 +944,7 @@ mod tests { dispatcher_record, &dispatcher::InboundClientData { timestamp: dispatcher_record.timestamp, - peer_addr: peer_addr_a, + client_addr: peer_addr_a, reception_port, last_data: false, is_clandestine, @@ -1499,7 +1499,7 @@ mod tests { ibcd, &InboundClientData { timestamp: ibcd.timestamp, - peer_addr: SocketAddr::from_str("1.2.3.5:7000").unwrap(), + client_addr: SocketAddr::from_str("1.2.3.5:7000").unwrap(), reception_port: Some(54321), last_data: false, is_clandestine: true, diff --git a/node/src/stream_reader.rs b/node/src/stream_reader.rs index df080ede3..34a7b62bd 100644 --- a/node/src/stream_reader.rs +++ b/node/src/stream_reader.rs @@ -161,7 +161,7 @@ impl StreamReaderReal { }; let msg = dispatcher::InboundClientData { timestamp: SystemTime::now(), - peer_addr: self.peer_addr, + client_addr: self.peer_addr, reception_port: self.reception_port, last_data: false, is_clandestine: self.is_clandestine, @@ -169,7 +169,7 @@ impl StreamReaderReal { data: unmasked_chunk.chunk.clone(), }; debug!(self.logger, "Discriminator framed and unmasked {} bytes for {}; transmitting via Hopper", - unmasked_chunk.chunk.len(), msg.peer_addr); + unmasked_chunk.chunk.len(), msg.client_addr); self.ibcd_sub.try_send(msg).expect("Dispatcher is dead"); } None => { @@ -510,7 +510,7 @@ mod tests { d_record, &dispatcher::InboundClientData { timestamp: d_record.timestamp, - peer_addr, + client_addr: peer_addr, reception_port: Some(1234 as u16), last_data: false, is_clandestine: true, @@ -631,7 +631,7 @@ mod tests { d_record, &dispatcher::InboundClientData { timestamp: d_record.timestamp, - peer_addr: peer_addr, + client_addr: peer_addr, reception_port: Some(1234 as u16), last_data: false, is_clandestine: false, @@ -646,7 +646,7 @@ mod tests { d_record, &dispatcher::InboundClientData { timestamp: d_record.timestamp, - peer_addr: peer_addr, + client_addr: peer_addr, reception_port: Some(1234 as u16), last_data: false, is_clandestine: false, @@ -662,7 +662,7 @@ mod tests { let system = System::new("test"); let (_, stream_handler_pool_subs) = stream_handler_pool_stuff(); let (d_recording_arc, dispatcher_subs) = dispatcher_stuff(); - let peer_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); + let client_addr = SocketAddr::from_str("1.2.3.4:5678").unwrap(); let local_addr = SocketAddr::from_str("1.2.3.5:6789").unwrap(); let discriminator_factories: Vec> = vec![Box::new(JsonDiscriminatorFactory::new())]; @@ -687,7 +687,7 @@ mod tests { dispatcher_subs.stream_shutdown_sub, discriminator_factories, true, - peer_addr, + client_addr, local_addr, ); let before = SystemTime::now(); @@ -705,7 +705,7 @@ mod tests { d_record, &dispatcher::InboundClientData { timestamp: d_record.timestamp, - peer_addr, + client_addr, reception_port: Some(1234 as u16), last_data: false, is_clandestine: true, diff --git a/node/src/sub_lib/dispatcher.rs b/node/src/sub_lib/dispatcher.rs index 20eea08d7..66e349e11 100644 --- a/node/src/sub_lib/dispatcher.rs +++ b/node/src/sub_lib/dispatcher.rs @@ -115,7 +115,7 @@ pub enum DispatcherError { #[derive(PartialEq, Eq, Clone, Message)] pub struct InboundClientData { pub timestamp: SystemTime, - pub peer_addr: SocketAddr, + pub client_addr: SocketAddr, pub reception_port: Option, pub last_data: bool, pub is_clandestine: bool, @@ -130,7 +130,7 @@ impl Debug for InboundClientData { Err(_) => self.data.hex_dump().to_string(), }; write!(f, "InboundClientData {{ peer_addr: {:?}, reception_port: {:?}, last_data: {}, sequence_number: {:?}, {} bytes of data: {} }}", - self.peer_addr, self.reception_port, self.last_data, self.sequence_number, self.data.len(), data_string) + self.client_addr, self.reception_port, self.last_data, self.sequence_number, self.data.len(), data_string) } } @@ -138,7 +138,7 @@ impl InboundClientData { pub fn clone_but_data(&self) -> InboundClientData { InboundClientData { timestamp: SystemTime::now(), - peer_addr: self.peer_addr, + client_addr: self.client_addr, reception_port: self.reception_port, last_data: self.last_data, is_clandestine: self.is_clandestine, @@ -273,7 +273,7 @@ mod tests { fn inbound_client_data_is_identifiable_as_a_connect() { let subject = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), + client_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), reception_port: None, last_data: false, is_clandestine: false, @@ -288,7 +288,7 @@ mod tests { fn inbound_client_data_is_not_connect() { let subject = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), + client_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), reception_port: None, last_data: false, is_clandestine: false, @@ -303,7 +303,7 @@ mod tests { fn inbound_client_data_not_connect_if_no_space_after_method() { let subject = InboundClientData { timestamp: SystemTime::now(), - peer_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), + client_addr: SocketAddr::from_str("1.4.3.2:9999").unwrap(), reception_port: None, last_data: false, is_clandestine: false, diff --git a/node/src/sub_lib/stream_key.rs b/node/src/sub_lib/stream_key.rs index 1535ee77c..c17953434 100644 --- a/node/src/sub_lib/stream_key.rs +++ b/node/src/sub_lib/stream_key.rs @@ -84,10 +84,10 @@ impl<'a> Visitor<'a> for StreamKeyVisitor { } impl StreamKey { - pub fn new(public_key: &PublicKey, server_addr: SocketAddr) -> StreamKey { + pub fn new(public_key: &PublicKey, client_addr: SocketAddr) -> StreamKey { let mut hash = sha1::Sha1::new(); hash.update(public_key.as_ref()); - hash = add_socket_addr_to_hash(hash, server_addr); + hash = add_socket_addr_to_hash(hash, client_addr); hash.update(STREAM_KEY_SALT.as_slice()); StreamKey { hash: hash.digest().bytes(), @@ -138,10 +138,10 @@ mod tests { let public_key = main_cryptde().public_key(); let stream_key_count = 100; let ip_addr = IpAddr::from_str("1.2.3.4").unwrap(); - let server_addrs = (0..stream_key_count).map(|i| SocketAddr::new(ip_addr, 1024 + i as u16)); + let client_addrs = (0..stream_key_count).map(|i| SocketAddr::new(ip_addr, 1024 + i as u16)); - let stream_keys = server_addrs - .map(|server_addr| StreamKey::new(&public_key, server_addr)) + let stream_keys = client_addrs + .map(|client_addr| StreamKey::new(&public_key, client_addr)) .collect_vec(); (0..(stream_key_count - 1)).for_each(|a| { @@ -155,10 +155,10 @@ mod tests { fn stream_keys_with_same_host_name_are_same() { let public_key = main_cryptde().public_key(); let stream_key_count = 100; - let server_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); + let client_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); let stream_keys = (0..stream_key_count) - .map(|_| StreamKey::new(&public_key, server_addr)) + .map(|_| StreamKey::new(&public_key, client_addr)) .collect_vec(); (1..stream_key_count).for_each(|i| { @@ -168,11 +168,11 @@ mod tests { #[test] fn stream_keys_from_different_public_keys_are_different() { - let server_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); + let client_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); let stream_keys = vec![PublicKey::new(&[1, 2, 3]), PublicKey::new(&[1, 2, 2])] .iter() - .map(|public_key| StreamKey::new(public_key, server_addr)) + .map(|public_key| StreamKey::new(public_key, client_addr)) .collect_vec(); assert_ne!(stream_keys[0], stream_keys[1]); @@ -181,13 +181,13 @@ mod tests { #[test] fn stream_keys_are_salted() { let public_key = main_cryptde().public_key(); - let server_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); + let client_addr = SocketAddr::new(IpAddr::from_str("1.2.3.4").unwrap(), 1024); - let result = StreamKey::new(&public_key, server_addr); + let result = StreamKey::new(&public_key, client_addr); let mut hash = sha1::Sha1::new(); hash.update(public_key.as_ref()); - hash = add_socket_addr_to_hash(hash, server_addr); + hash = add_socket_addr_to_hash(hash, client_addr); let attack = StreamKey { hash: hash.digest().bytes(), }; From a4f6ec884bf7fb60a5bb049b884c1ee7bd89ef14 Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Thu, 27 Mar 2025 07:22:43 -0400 Subject: [PATCH 11/13] Interim commit --- node/src/proxy_server/http_protocol_pack.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/proxy_server/http_protocol_pack.rs b/node/src/proxy_server/http_protocol_pack.rs index 3904c736f..ce154d754 100644 --- a/node/src/proxy_server/http_protocol_pack.rs +++ b/node/src/proxy_server/http_protocol_pack.rs @@ -11,7 +11,7 @@ use regex::Regex; lazy_static! { static ref HOST_PATTERN: Regex = Regex::new(r"^(?:https?://)?([^\s/]+)").expect("bad regex"); } - + *** Replace this with the version from GH-554-dan *** pub struct HttpProtocolPack {} impl ProtocolPack for HttpProtocolPack { From 5240c1893f90451c93bbdf18bf23a38d22dd70a4 Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Thu, 27 Mar 2025 22:02:43 -0400 Subject: [PATCH 12/13] Fixed the protocol pack --- .../client_request_payload_factory.rs | 5 +- node/src/proxy_server/http_protocol_pack.rs | 91 ++++++++----------- node/src/proxy_server/mod.rs | 3 +- node/src/proxy_server/protocol_pack.rs | 8 +- node/src/proxy_server/tls_protocol_pack.rs | 7 +- 5 files changed, 53 insertions(+), 61 deletions(-) diff --git a/node/src/proxy_server/client_request_payload_factory.rs b/node/src/proxy_server/client_request_payload_factory.rs index 36fa03fdf..076444239 100644 --- a/node/src/proxy_server/client_request_payload_factory.rs +++ b/node/src/proxy_server/client_request_payload_factory.rs @@ -44,10 +44,7 @@ impl ClientRequestPayloadFactory for ClientRequestPayloadFactoryReal { let data = PlainData::new(&ibcd.data); let target_host = protocol_pack.find_host(&data); let (target_hostname, target_port) = match target_host { - Some(host) => match host.port { - Some(port) => (Some(host.name), port), - None => (Some(host.name), protocol_pack.standard_port()), - }, + Some(host) => (Some(host.name), host.port), None => (None, protocol_pack.standard_port()), }; Some(ClientRequestPayload_0v1 { diff --git a/node/src/proxy_server/http_protocol_pack.rs b/node/src/proxy_server/http_protocol_pack.rs index ce154d754..ac0058f28 100644 --- a/node/src/proxy_server/http_protocol_pack.rs +++ b/node/src/proxy_server/http_protocol_pack.rs @@ -11,7 +11,7 @@ use regex::Regex; lazy_static! { static ref HOST_PATTERN: Regex = Regex::new(r"^(?:https?://)?([^\s/]+)").expect("bad regex"); } - *** Replace this with the version from GH-554-dan *** + pub struct HttpProtocolPack {} impl ProtocolPack for HttpProtocolPack { @@ -24,9 +24,9 @@ impl ProtocolPack for HttpProtocolPack { } fn find_host(&self, data: &PlainData) -> Option { - match HttpProtocolPack::find_url_host(data.as_slice()) { + match HttpProtocolPack::find_header_host(data.as_slice()) { Some(host) => Some(host), - None => HttpProtocolPack::find_header_host(data.as_slice()), + None => HttpProtocolPack::find_url_host(data.as_slice()), } } @@ -67,12 +67,15 @@ impl HttpProtocolPack { match parts.len() { 1 => Some(Host { name: parts.remove(0).to_string(), - port: None, - }), - 2 => Some(Host { - name: parts.remove(0).to_string(), - port: Self::port_from_string(parts.remove(0).to_string()), + port: HTTP_PORT, }), + 2 => { + let name = parts.remove(0).to_string(); + match Self::port_from_string(parts.remove(0).to_string()) { + Ok(port) => Some(Host { name, port }), + Err(_) => None, + } + }, _ => None, } } @@ -91,10 +94,10 @@ impl HttpProtocolPack { ) } - fn port_from_string(port_str: String) -> Option { + fn port_from_string(port_str: String) -> Result { match port_str.parse::() { - Err(_) => None, - Ok(port) => Some(port), + Err(_) => Err(format!("Port '{}' is not a number", port_str)), + Ok(port) => Ok(port), } } } @@ -160,7 +163,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("header.host.com"), host.name); + assert_eq!(host, Host::new("header.host.com", HTTP_PORT)); } #[test] @@ -182,31 +185,31 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("192.168.1.230"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, Host::new("192.168.1.230", HTTP_PORT)); } #[test] - fn returns_host_name_and_port_from_url_if_both_exist() { + fn returns_host_name_and_port_from_header_if_both_exist() { let data = PlainData::new(b"OPTIONS http://top.host.com:1234/index.html HTTP/1.1\r\nHost: header.host.com:5432\r\n\r\nbodybody"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(Some(1234), host.port); + assert_eq!(host, Host::new("header.host.com", 5432)); } #[test] fn returns_host_name_from_http_url_if_header_doesnt_exist() { + // Note: that "Host: body.host.com" looks like a header, but it's not: it's content. let data = PlainData::new(b"DELETE http://top.host.com/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("top.host.com"), host.name); + assert_eq!(host.name, String::from("top.host.com")); } #[test] fn returns_host_name_from_https_url_if_header_doesnt_exist() { + // Note: that "Host: body.host.com" looks like a header, but it's not: it's content. let data = PlainData::new(b"PUT https://top.host.com/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); @@ -220,29 +223,29 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("top.host.com"), host.name); + assert_eq!(host, Host::new("top.host.com", HTTP_PORT)); } #[test] fn returns_host_name_from_url_when_no_scheme() { let data = PlainData::new( - b"CONNECT good.url.dude/path.html HTTP/1.1\r\nHost: wrong.url.dude\r\n\r\n", + b"GET wrong.url.dude/path.html HTTP/1.1\r\nHost: good.url.dude\r\n\r\n", ); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("good.url.dude"), host.name); + assert_eq!(host.name, String::from("good.url.dude")); } #[test] fn can_handle_domain_that_starts_with_http() { let data = PlainData::new( - b"CONNECT http.url.dude/path.html HTTP/1.1\r\nHost: wrong.url.dude\r\n\r\n", + b"GET http.url.dude/path.html HTTP/1.1\r\nHost: good.url.dude\r\n\r\n", ); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("http.url.dude"), host.name); + assert_eq!(String::from("good.url.dude"), host.name); } #[test] @@ -251,8 +254,7 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(Some(8080), host.port); + assert_eq!(host, Host::new("top.host.com", 8080)); } #[test] @@ -268,39 +270,27 @@ mod tests { fn specifying_a_non_numeric_port_in_the_url() { let data = PlainData::new(b"HEAD http://top.host.com:nanan/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] - fn specifying_a_missing_port_in_the_url() { + fn cant_extract_top_host_if_port_has_syntax_error() { let data = PlainData::new(b"HEAD http://top.host.com:/index.html HTTP/1.1\r\nContent-Length: 23\r\n\r\nHost: body.host.com\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("top.host.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] - fn from_integration_test() { + fn explicit_port_is_80_if_it_was_not_specified() { let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("www.example.com"), host.name); - } - - #[test] - fn explicit_port_is_none_if_it_was_not_specified() { - let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); - - let host = HttpProtocolPack {}.find_host(&data).unwrap(); - - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, Host::new("www.example.com", HTTP_PORT)); } #[test] @@ -309,28 +299,25 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(Some(8080), host.port); + assert_eq!(host, Host::new("www.example.com", 8080)); } #[test] fn specifying_a_non_numeric_port_in_host_header() { let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com:nannan\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] fn specifying_a_missing_port_in_host_header() { let data = PlainData::new(b"GET / HTTP/1.1\r\nHost: www.example.com:\r\n\r\n"); - let host = HttpProtocolPack {}.find_host(&data).unwrap(); + let host = HttpProtocolPack {}.find_host(&data); - assert_eq!(String::from("www.example.com"), host.name); - assert_eq!(None, host.port); + assert_eq!(host, None); } #[test] diff --git a/node/src/proxy_server/mod.rs b/node/src/proxy_server/mod.rs index 7cfc3a80d..aa69f2065 100644 --- a/node/src/proxy_server/mod.rs +++ b/node/src/proxy_server/mod.rs @@ -55,6 +55,7 @@ use std::rc::Rc; use std::str::FromStr; use std::time::{Duration, SystemTime}; use tokio::prelude::Future; +use masq_lib::constants::TLS_PORT; pub const CRASH_KEY: &str = "PROXYSERVER"; pub const RETURN_ROUTE_TTL: Duration = Duration::from_secs(120); @@ -564,7 +565,7 @@ impl ProxyServer { fn tls_connect(&mut self, msg: &InboundClientData) { let http_data = HttpProtocolPack {}.find_host(&msg.data.clone().into()); match http_data { - Some(ref host) if host.port == Some(443) => { + Some(ref host) if host.port == TLS_PORT => { let stream_key = self.find_or_generate_stream_key(msg, msg.client_addr); self.tunneled_hosts.insert(stream_key, host.name.clone()); self.subs diff --git a/node/src/proxy_server/protocol_pack.rs b/node/src/proxy_server/protocol_pack.rs index 38db8e6ff..76e9b2430 100644 --- a/node/src/proxy_server/protocol_pack.rs +++ b/node/src/proxy_server/protocol_pack.rs @@ -9,7 +9,13 @@ use masq_lib::constants::{HTTP_PORT, TLS_PORT}; #[derive(Clone, Debug, PartialEq, Eq)] pub struct Host { pub name: String, - pub port: Option, + pub port: u16, +} + +impl Host { + pub fn new(name: &str, port: u16) -> Self { + Host { name: name.to_string(), port } + } } pub trait ProtocolPack: Send + Sync { diff --git a/node/src/proxy_server/tls_protocol_pack.rs b/node/src/proxy_server/tls_protocol_pack.rs index f57177a8f..1a62eba95 100644 --- a/node/src/proxy_server/tls_protocol_pack.rs +++ b/node/src/proxy_server/tls_protocol_pack.rs @@ -1,3 +1,4 @@ +use masq_lib::constants::TLS_PORT; // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. use crate::proxy_server::protocol_pack::{Host, ProtocolPack, ServerImpersonator}; use crate::proxy_server::server_impersonator_tls::ServerImpersonatorTls; @@ -25,7 +26,7 @@ impl ProtocolPack for TlsProtocolPack { return None; } match Self::host_name_from_client_hello(&mut xvsr) { - Ok(name) => Some(Host { name, port: None }), + Ok(name) => Some(Host { name, port: TLS_PORT }), Err(()) => None, } } @@ -709,7 +710,7 @@ mod tests { assert_eq!( Some(Host { name: String::from("server.com"), - port: None, + port: TLS_PORT, }), result ); @@ -754,7 +755,7 @@ mod tests { assert_eq!( Some(Host { name: String::from("server.com"), - port: None + port: TLS_PORT }), result ); From 3b41718f1d22516a05ec40962d7c182483c6843d Mon Sep 17 00:00:00 2001 From: Dan Wiebe Date: Fri, 28 Mar 2025 07:56:02 -0400 Subject: [PATCH 13/13] Review issues --- dns_utility/Cargo.lock | 96 ++++-------------- masq_lib/Cargo.toml | 2 +- node/Cargo.lock | 102 +++++--------------- node/src/proxy_server/http_protocol_pack.rs | 8 +- 4 files changed, 45 insertions(+), 163 deletions(-) diff --git a/dns_utility/Cargo.lock b/dns_utility/Cargo.lock index 6782f8f6e..a497a59dc 100644 --- a/dns_utility/Cargo.lock +++ b/dns_utility/Cargo.lock @@ -596,14 +596,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -1189,6 +1189,12 @@ dependencies = [ "proc-macro2 1.0.94", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "radium" version = "0.3.0" @@ -1311,7 +1317,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.1", + "getrandom 0.3.2", ] [[package]] @@ -2211,9 +2217,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi" -version = "0.13.3+wasi-0.2.2" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] @@ -2290,70 +2296,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - [[package]] name = "winreg" version = "0.5.1" @@ -2383,9 +2325,9 @@ dependencies = [ [[package]] name = "wit-bindgen-rt" -version = "0.33.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ "bitflags 2.9.0", ] @@ -2402,18 +2344,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.23" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.23" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" dependencies = [ "proc-macro2 1.0.94", "quote 1.0.40", diff --git a/masq_lib/Cargo.toml b/masq_lib/Cargo.toml index 7fbcfb9f8..7375ea461 100644 --- a/masq_lib/Cargo.toml +++ b/masq_lib/Cargo.toml @@ -17,6 +17,7 @@ ethereum-types = "0.9.0" itertools = "0.10.1" lazy_static = "1.4.0" log = "0.4.8" +rand = { version = "0.9.0", features = ["thread_rng"] } regex = "1.5.4" serde = "1.0.133" serde_derive = "1.0.133" @@ -25,7 +26,6 @@ time = {version = "0.3.11", features = [ "formatting" ]} tiny-hderive = "0.3.0" toml = "0.5.8" websocket = {version = "0.26.2", default-features = false, features = ["sync"]} -rand = { version = "0.9.0", features = ["thread_rng"] } [features] no_test_share = [] diff --git a/node/Cargo.lock b/node/Cargo.lock index 30552a3da..976d2a676 100644 --- a/node/Cargo.lock +++ b/node/Cargo.lock @@ -1140,14 +1140,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -2682,6 +2682,12 @@ dependencies = [ "proc-macro2 1.0.94", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "radium" version = "0.3.0" @@ -2846,7 +2852,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.1", + "getrandom 0.3.2", ] [[package]] @@ -4460,9 +4466,9 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasi" -version = "0.13.3+wasi-0.2.2" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] @@ -4668,29 +4674,13 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm 0.42.0", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", - "windows_x86_64_gnullvm 0.42.0", - "windows_x86_64_msvc 0.42.0", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -4699,90 +4689,42 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - [[package]] name = "windows_aarch64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - [[package]] name = "windows_i686_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - [[package]] name = "windows_i686_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - [[package]] name = "windows_x86_64_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - [[package]] name = "windows_x86_64_gnullvm" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - [[package]] name = "windows_x86_64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - [[package]] name = "winreg" version = "0.5.1" @@ -4821,9 +4763,9 @@ dependencies = [ [[package]] name = "wit-bindgen-rt" -version = "0.33.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ "bitflags 2.9.0", ] diff --git a/node/src/proxy_server/http_protocol_pack.rs b/node/src/proxy_server/http_protocol_pack.rs index a2c63bde5..0bc41d405 100644 --- a/node/src/proxy_server/http_protocol_pack.rs +++ b/node/src/proxy_server/http_protocol_pack.rs @@ -164,7 +164,6 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(host, Host::new("header.host.com", HTTP_PORT)); - assert_eq!(HTTP_PORT, host.port); } #[test] @@ -225,13 +224,12 @@ mod tests { let host = HttpProtocolPack {}.find_host(&data).unwrap(); assert_eq!(host, Host::new("top.host.com", HTTP_PORT)); - assert_eq!(HTTP_PORT, host.port); } #[test] fn returns_host_name_from_url_when_no_scheme() { let data = PlainData::new( - b"GET wrong.url.dude/path.html HTTP/1.1\r\nHost: good.url.dude\r\n\r\n", + b"GET good.url.dude/path.html HTTP/1.0\r\n\r\n", ); let host = HttpProtocolPack {}.find_host(&data).unwrap(); @@ -242,12 +240,12 @@ mod tests { #[test] fn can_handle_domain_that_starts_with_http() { let data = PlainData::new( - b"GET http.url.dude/path.html HTTP/1.1\r\nHost: good.url.dude\r\n\r\n", + b"GET bad.url.dude/path.html HTTP/1.1\r\nHost: http.url.dude\r\n\r\n", ); let host = HttpProtocolPack {}.find_host(&data).unwrap(); - assert_eq!(String::from("good.url.dude"), host.name); + assert_eq!(String::from("http.url.dude"), host.name); } #[test]