diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0e3fd2446..8d03623e1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,9 +2,9 @@ name: Rust tests on: push: - branches: [master] + branches: [master,beta21,beta20] pull_request: - branches: [master] + branches: [master,beta21,beta20] env: CARGO_TERM_COLOR: always @@ -48,22 +48,6 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Run Cargo Audit run: cargo install cargo-audit && cargo audit - cross-mips: - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: Swatinem/rust-cache@v2 - - name: Cross test mips - run: cargo install cross && cross test --target mips-unknown-linux-musl --verbose -- --test-threads=1 - cross-mipsel: - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: Swatinem/rust-cache@v2 - - name: Cross test mipsel - run: cargo install cross && cross test --target mipsel-unknown-linux-musl --verbose -- --test-threads=1 cross-aarch64: needs: test runs-on: ubuntu-latest @@ -144,4 +128,4 @@ jobs: - name: Install Wireguard run: sudo apt-get update && sudo apt install -y wireguard linux-source linux-headers-$(uname -r) build-essential && sudo modprobe wireguard - name: Run integration test - run: bash scripts/integration_tests/all-up-test.sh MIGRATION_TEST \ No newline at end of file + run: bash scripts/integration_tests/all-up-test.sh MIGRATION_TEST diff --git a/Cargo.lock b/Cargo.lock index ae2376706..fa9d989f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "actix" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cba56612922b907719d4a01cf11c8d5b458e7d3dba946d0435f20f58d6795ed2" +checksum = "fb72882332b6d6282f428b77ba0358cb2687e61a6f6df6a6d3871e8a177c2d4f" dependencies = [ "actix-macros", "actix-rt", @@ -29,11 +29,11 @@ dependencies = [ [[package]] name = "actix-codec" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" +checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "bytes", "futures-core", "futures-sink", @@ -46,16 +46,16 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.5.1" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "129d4c88e98860e1758c5de288d1632b07970a16d59bdf7b8d66053d582bb71f" +checksum = "d223b13fd481fc0d1f83bb12659ae774d9e3601814c68a0bc539731698cca743" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-tls", "actix-utils", - "ahash 0.8.7", + "ahash 0.8.11", "base64 0.21.7", "bitflags 2.4.2", "brotli", @@ -66,7 +66,7 @@ dependencies = [ "flate2", "futures-core", "h2", - "http 0.2.11", + "http 0.2.12", "httparse", "httpdate", "itoa", @@ -91,7 +91,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -101,7 +101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d22475596539443685426b6bdadb926ad0ecaefdfc5fb05e5e3441f15463c511" dependencies = [ "bytestring", - "http 0.2.11", + "http 0.2.12", "regex", "serde", "tracing", @@ -130,7 +130,7 @@ dependencies = [ "futures-core", "futures-util", "mio", - "socket2 0.5.5", + "socket2 0.5.6", "tokio", "tracing", ] @@ -148,16 +148,16 @@ dependencies = [ [[package]] name = "actix-tls" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "929e47cc23865cdb856e59673cfba2d28f00b3bbd060dfc80e33a00a3cea8317" +checksum = "d4cce60a2f2b477bc72e5cde0af1812a6e82d8fd85b5570a5dcf2a5bf2c5be5f" dependencies = [ "actix-rt", "actix-service", "actix-utils", "futures-core", - "http 0.2.11", - "http 1.0.0", + "http 0.2.12", + "http 1.1.0", "impl-more", "openssl", "pin-project-lite", @@ -179,9 +179,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.4.1" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e43428f3bf11dee6d166b00ec2df4e3aa8cc1606aaa0b7433c146852e2f4e03b" +checksum = "43a6556ddebb638c2358714d853257ed226ece6023ef9364f23f0c70737ea984" dependencies = [ "actix-codec", "actix-http", @@ -191,7 +191,7 @@ dependencies = [ "actix-service", "actix-tls", "actix-utils", - "ahash 0.8.7", + "ahash 0.8.11", "bytes", "bytestring", "cfg-if", @@ -210,7 +210,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2 0.5.5", + "socket2 0.5.6", "time", "url", ] @@ -238,7 +238,7 @@ checksum = "7c7db3d5a9718568e4cf4a537cfd7070e6e6ff7481510d0237fb529ac850f6d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -258,9 +258,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom", "once_cell", @@ -269,9 +269,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -391,9 +391,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "arrayvec" @@ -423,7 +423,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -434,7 +434,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -461,9 +461,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "awc" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b625cad34428b3b82d0bd548b26a1cd0a3d70b6109e9b4e3355d8f1802a8b1c6" +checksum = "68c09cc97310b926f01621faee652f3d1b0962545a3cec6c9ac07def9ea36c2c" dependencies = [ "actix-codec", "actix-http", @@ -479,7 +479,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http 0.2.11", + "http 0.2.12", "itoa", "log", "mime", @@ -504,7 +504,7 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http 0.2.11", + "http 0.2.12", "http-body", "hyper", "itoa", @@ -530,7 +530,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.11", + "http 0.2.12", "http-body", "mime", "rustversion", @@ -672,7 +672,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", "syn_derive", ] @@ -699,15 +699,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "bytecheck" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" dependencies = [ "bytecheck_derive", "ptr_meta", @@ -716,9 +716,9 @@ dependencies = [ [[package]] name = "bytecheck_derive" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ "proc-macro2", "quote", @@ -754,9 +754,9 @@ checksum = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ "jobserver", "libc", @@ -880,18 +880,18 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-channel" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" dependencies = [ "crossbeam-utils", ] @@ -914,11 +914,11 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.2" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b" +checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" dependencies = [ - "nix 0.27.1", + "nix 0.28.0", "windows-sys 0.52.0", ] @@ -1051,9 +1051,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "email-encoding" @@ -1238,7 +1238,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -1329,17 +1329,17 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" dependencies = [ "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http 0.2.11", - "indexmap 2.1.0", + "http 0.2.12", + "indexmap 2.2.5", "slab", "tokio", "tokio-util", @@ -1348,9 +1348,9 @@ dependencies = [ [[package]] name = "half" -version = "1.8.2" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" [[package]] name = "handlebars" @@ -1372,7 +1372,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.8", ] [[package]] @@ -1389,9 +1389,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex-literal" @@ -1421,9 +1421,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -1432,9 +1432,9 @@ dependencies = [ [[package]] name = "http" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -1448,7 +1448,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http 0.2.11", + "http 0.2.12", "pin-project-lite", ] @@ -1481,13 +1481,13 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http 0.2.11", + "http 0.2.12", "http-body", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.5", + "socket2 0.5.6", "tokio", "tower-service", "tracing", @@ -1557,9 +1557,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1602,6 +1602,7 @@ dependencies = [ "num-traits", "num256", "petgraph", + "phonenumber", "rita_client", "rita_client_registration", "rita_common", @@ -1638,12 +1639,12 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", - "rustix", + "libc", "windows-sys 0.52.0", ] @@ -1684,18 +1685,18 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -1748,9 +1749,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libsodium-sys" @@ -1805,9 +1806,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lru-cache" @@ -1909,18 +1910,18 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", @@ -1974,12 +1975,13 @@ dependencies = [ [[package]] name = "nix" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ "bitflags 2.4.2", "cfg-if", + "cfg_aliases", "libc", ] @@ -2020,28 +2022,33 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" dependencies = [ "autocfg", "num-integer", @@ -2062,9 +2069,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -2080,16 +2087,6 @@ dependencies = [ "serde", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" version = "0.32.2" @@ -2126,9 +2123,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.62" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ "bitflags 2.4.2", "cfg-if", @@ -2147,7 +2144,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -2158,18 +2155,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.2.1+3.2.0" +version = "300.2.3+3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fe476c29791a5ca0d1273c697e96085bbabbbea2ef7afd5617e78a4b40332d3" +checksum = "5cff92b6f71555b61bb9315f7c64da3ca43d87531622120fea0195fc761b4843" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.98" +version = "0.9.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" +checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" dependencies = [ "cc", "libc", @@ -2236,9 +2233,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.6" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" +checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" dependencies = [ "memchr", "thiserror", @@ -2247,9 +2244,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.6" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcd6ab1236bbdb3a49027e920e693192ebfe8913f6d60e294de57463a493cfde" +checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" dependencies = [ "pest", "pest_generator", @@ -2257,22 +2254,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.6" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a31940305ffc96863a735bef7c7994a00b325a7138fdbc5bda0f1a0476d3275" +checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "pest_meta" -version = "2.7.6" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ff62f5259e53b78d1af898941cdcdccfae7385cf7d793a6e55de5d05bb4b7d" +checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" dependencies = [ "once_cell", "pest", @@ -2286,7 +2283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap 2.2.5", ] [[package]] @@ -2312,22 +2309,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -2344,9 +2341,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "powerfmt" @@ -2403,9 +2400,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -2430,7 +2427,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -2544,9 +2541,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -2556,9 +2553,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -2591,18 +2588,18 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rend" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" dependencies = [ "bytecheck", ] [[package]] name = "reqwest" -version = "0.11.23" +version = "0.11.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" dependencies = [ "base64 0.21.7", "bytes", @@ -2610,7 +2607,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http 0.2.11", + "http 0.2.12", "http-body", "hyper", "hyper-tls", @@ -2622,9 +2619,11 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", @@ -2638,16 +2637,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom", "libc", "spin", "untrusted", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2661,7 +2661,7 @@ dependencies = [ [[package]] name = "rita_bin" -version = "0.21.4" +version = "0.21.5" dependencies = [ "actix", "actix-rt", @@ -2699,7 +2699,7 @@ dependencies = [ [[package]] name = "rita_client" -version = "0.21.4" +version = "0.21.5" dependencies = [ "actix", "actix-web", @@ -2754,7 +2754,7 @@ dependencies = [ [[package]] name = "rita_common" -version = "0.21.4" +version = "0.21.5" dependencies = [ "actix", "actix-service", @@ -2809,7 +2809,7 @@ dependencies = [ [[package]] name = "rita_exit" -version = "0.21.4" +version = "0.21.5" dependencies = [ "actix", "actix-web", @@ -2839,7 +2839,7 @@ dependencies = [ [[package]] name = "rita_extender" -version = "0.21.4" +version = "0.21.5" dependencies = [ "actix", "actix-web", @@ -2859,9 +2859,9 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.43" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527a97cdfef66f65998b5f3b637c26f5a5ec09cc52a3f9932313ac645f4190f5" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" dependencies = [ "bitvec", "bytecheck", @@ -2877,9 +2877,9 @@ dependencies = [ [[package]] name = "rkyv_derive" -version = "0.7.43" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5c462a1328c8e67e4d6dbad1eb0355dd43e8ab432c6e227a43657f16ade5033" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ "proc-macro2", "quote", @@ -2888,9 +2888,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.33.1" +version = "1.34.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4" +checksum = "b39449a79f45e8da28c57c341891b69a183044b29518bb8f86dbac9df60bb7df" dependencies = [ "arrayvec", "borsh", @@ -2919,9 +2919,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.2", "errno", @@ -2981,9 +2981,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "same-file" @@ -3036,9 +3036,9 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "secp256k1" -version = "0.28.1" +version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f622567e3b4b38154fb8190bcf6b160d7a4301d70595a49195b48c116007a27" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ "secp256k1-sys", ] @@ -3077,15 +3077,15 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -3102,20 +3102,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -3219,9 +3219,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -3235,12 +3235,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -3308,9 +3308,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -3326,7 +3326,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -3364,13 +3364,12 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall", "rustix", "windows-sys 0.52.0", ] @@ -3407,32 +3406,33 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "time" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -3447,10 +3447,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] @@ -3471,19 +3472,18 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2 0.5.6", "tokio-macros", "windows-sys 0.48.0", ] @@ -3506,7 +3506,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -3543,9 +3543,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -3583,11 +3583,11 @@ checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.5", "toml_datetime", "winnow", ] @@ -3605,7 +3605,7 @@ dependencies = [ "bytes", "flate2", "h2", - "http 0.2.11", + "http 0.2.12", "http-body", "hyper", "hyper-timeout", @@ -3676,7 +3676,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -3720,9 +3720,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] @@ -3746,9 +3746,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" dependencies = [ "getrandom", ] @@ -3767,9 +3767,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -3792,9 +3792,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3802,24 +3802,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -3829,9 +3829,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3839,28 +3839,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -3937,7 +3937,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -3957,17 +3957,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -3978,9 +3978,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -3990,9 +3990,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -4002,9 +4002,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -4014,9 +4014,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -4026,9 +4026,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -4038,9 +4038,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -4050,15 +4050,15 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -4099,7 +4099,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8bf21573d..115c80407 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ inherits = "dev" opt-level = 2 [workspace.dependencies] -deep_space = {version = "2", features = ["althea"], default-features=false} +deep_space = {version = "=2.23.1", features = ["althea"], default-features=false} web30 = "1.2" clarity = "1.3" awc = {version = "3.2", default-features = false, features=["openssl", "compress-gzip", "compress-zstd"]} diff --git a/althea_kernel_interface/src/hardware_info.rs b/althea_kernel_interface/src/hardware_info.rs index 658d39293..abecc0bef 100644 --- a/althea_kernel_interface/src/hardware_info.rs +++ b/althea_kernel_interface/src/hardware_info.rs @@ -82,7 +82,7 @@ pub fn get_kernel_version() -> Result { let sys_kernel_ver_error = Err(Error::FailedToGetSystemKernelVersion); let lines = get_lines("/proc/version")?; - let line = match lines.get(0) { + let line = match lines.first() { Some(line) => line, None => return sys_kernel_ver_error, }; @@ -154,7 +154,7 @@ fn get_sys_uptime() -> Result { let sys_time_error = Err(Error::FailedToGetSystemTime); let lines = get_lines("/proc/uptime")?; - let line = match lines.get(0) { + let line = match lines.first() { Some(line) => line, None => return sys_time_error, }; @@ -179,7 +179,7 @@ fn get_load_avg() -> Result<(f32, f32, f32), Error> { // cpu load average let load_average_error = Err(Error::FailedToGetLoadAverage); let lines = get_lines("/proc/loadavg")?; - let load_avg = match lines.get(0) { + let load_avg = match lines.first() { Some(line) => line, None => return load_average_error, }; @@ -243,7 +243,7 @@ fn get_numcpus() -> Result { fn maybe_get_single_line_u64(path: &str) -> Option { match get_lines(path) { Ok(line) => { - let var_name = line.get(0); + let var_name = line.first(); match var_name { Some(val) => match val.parse() { Ok(res) => Some(res), @@ -258,7 +258,7 @@ fn maybe_get_single_line_u64(path: &str) -> Option { pub fn maybe_get_single_line_string(path: &str) -> Option { match get_lines(path) { - Ok(line) => line.get(0).map(|val| val.to_string()), + Ok(line) => line.first().map(|val| val.to_string()), Err(_e) => None, } } @@ -337,28 +337,23 @@ fn get_ethernet_stats() -> Option> { } fn get_wifi_devices() -> Vec { - let mut ret: Vec = Vec::new(); - //get devices - let devices = parse_wifi_device_names(); - if devices.is_err() { - warn!("Unable to get wifi devices: {:?}", devices); - return Vec::new(); - } - - for dev in devices.unwrap() { - let device = WifiDevice { - name: dev.clone(), - survey_data: get_wifi_survey_info(&dev), - station_data: get_wifi_station_info(&dev), - ssid: get_radio_ssid(&dev), - channel: get_radio_channel(&dev), - enabled: get_radio_enabled(&dev), - }; - info!("Created the following wifi struct: {:?}", device.clone()); - ret.push(device); + match parse_wifi_device_names() { + Ok(devices) => devices + .into_iter() + .map(|dev| WifiDevice { + name: dev.clone(), + survey_data: get_wifi_survey_info(&dev), + station_data: get_wifi_station_info(&dev), + ssid: get_radio_ssid(&dev), + channel: get_radio_channel(&dev), + enabled: get_radio_enabled(&dev), + }) + .collect(), + Err(err) => { + warn!("Unable to get wifi devices: {:?}", err); + Vec::new() + } } - - ret } /// This function parses files in /proc that contain conntrack info to send to ops @@ -449,13 +444,19 @@ fn get_wifi_survey_info(dev: &str) -> Vec { .args([dev, "survey", "dump"]) .stdout(Stdio::piped()) .output(); - - if res.is_err() { - error!("Unable to run survey dump {:?}", res); - return Vec::new(); + match res { + Ok(a) => match String::from_utf8(a.stdout) { + Ok(a) => extract_wifi_survey_data(&a, dev), + Err(e) => { + error!("Unable to parse iw survey dump {:?}", e); + Vec::new() + } + }, + Err(e) => { + error!("Unable to run survey dump {:?}", e); + Vec::new() + } } - let res = String::from_utf8(res.unwrap().stdout).unwrap(); - extract_wifi_survey_data(&res, dev) } fn get_wifi_station_info(dev: &str) -> Vec { @@ -463,14 +464,19 @@ fn get_wifi_station_info(dev: &str) -> Vec { .args([dev, "station", "dump"]) .stdout(Stdio::piped()) .output(); - - if res.is_err() { - error!("Unable to run station dump {:?}", res); - return Vec::new(); + match res { + Ok(a) => match String::from_utf8(a.stdout) { + Ok(a) => extract_wifi_station_data(&a), + Err(e) => { + error!("Unable to parse iw station dump {:?}", e); + Vec::new() + } + }, + Err(e) => { + error!("Unable to run station dump {:?}", e); + Vec::new() + } } - - let res = String::from_utf8(res.unwrap().stdout).unwrap(); - extract_wifi_station_data(&res) } /// Expected input wlan0, wlan1, etc diff --git a/althea_kernel_interface/src/interface_tools.rs b/althea_kernel_interface/src/interface_tools.rs index 1f521964e..c2e120c09 100644 --- a/althea_kernel_interface/src/interface_tools.rs +++ b/althea_kernel_interface/src/interface_tools.rs @@ -1,6 +1,7 @@ use crate::file_io::get_lines; use crate::KernelInterface; use crate::KernelInterfaceError as Error; +use althea_types::InterfaceUsageStats; use regex::Regex; use std::fs::read_dir; use std::net::IpAddr; @@ -8,7 +9,51 @@ use std::net::Ipv4Addr; use std::net::Ipv6Addr; use std::str::from_utf8; +/// Utility function for get_per_interface_usage that makes options ? compatible +fn get_helper(input: Option<&&str>) -> Result { + match input { + Some(v) => Ok(v.to_string()), + None => Err(Error::ParseError( + "Missing field in /proc/net/dev!".to_string(), + )), + } +} + impl dyn KernelInterface { + /// Gets usage data from all interfaces from /proc/net/dev, note that for wireguard interfaces + /// updating the interface on the fly (like we do with wg_exit) will reset the usage + /// counter on the wireguard side, but not on in proc which this code pulls from + pub fn get_per_interface_usage(&self) -> Result, Error> { + let lines = get_lines("/proc/net/dev")?; + // all lines represent an interface, except the first line which is a header + let mut lines = lines.iter(); + // skip the first and second lines + lines.next(); + lines.next(); + let mut ret = Vec::new(); + for line in lines { + println!("line ins {}", line); + let parts: Vec<&str> = line.split_ascii_whitespace().collect(); + ret.push(InterfaceUsageStats { + interface_name: get_helper(parts.first())?.trim_end_matches(':').to_string(), + recieve_bytes: get_helper(parts.get(1))?.parse()?, + recieve_packets: get_helper(parts.get(2))?.parse()?, + recieve_errors: get_helper(parts.get(3))?.parse()?, + recieve_dropped: get_helper(parts.get(4))?.parse()?, + recieve_fifo_errors: get_helper(parts.get(5))?.parse()?, + recieve_frame_errors: get_helper(parts.get(6))?.parse()?, + recieve_multicast_erorrs: get_helper(parts.get(8))?.parse()?, + transmit_bytes: get_helper(parts.get(9))?.parse()?, + transmit_packets: get_helper(parts.get(10))?.parse()?, + transmit_errors: get_helper(parts.get(11))?.parse()?, + transmit_fifo_errors: get_helper(parts.get(12))?.parse()?, + transmit_collission_erorrs: get_helper(parts.get(13))?.parse()?, + tranmist_carrier_errors: get_helper(parts.get(14))?.parse()?, + }) + } + Ok(ret) + } + /// Returns all existing interfaces pub fn get_interfaces(&self) -> Result, Error> { let links = read_dir("/sys/class/net/")?; @@ -176,7 +221,7 @@ impl dyn KernelInterface { /// Gets the mtu from an interface pub fn get_mtu(&self, if_name: &str) -> Result { let lines = get_lines(&format!("/sys/class/net/{if_name}/mtu"))?; - if let Some(mtu) = lines.get(0) { + if let Some(mtu) = lines.first() { Ok(mtu.parse()?) } else { Err(Error::NoInterfaceError(if_name.to_string())) @@ -206,7 +251,7 @@ impl dyn KernelInterface { Ok(index.parse().unwrap()) } else { let lines = get_lines(&format!("/sys/class/net/{if_name}/ifindex"))?; - if let Some(ifindex) = lines.get(0) { + if let Some(ifindex) = lines.first() { Ok(ifindex.parse()?) } else { Err(Error::NoInterfaceError(if_name.to_string())) @@ -218,7 +263,7 @@ impl dyn KernelInterface { /// identical but if you have a virtual (say DSA) interface then this will be the physical interface name pub fn get_iflink(&self, if_name: &str) -> Result { let lines = get_lines(&format!("/sys/class/net/{if_name}/iflink"))?; - if let Some(iflink) = lines.get(0) { + if let Some(iflink) = lines.first() { Ok(iflink.parse()?) } else { Err(Error::NoInterfaceError(if_name.to_string())) @@ -345,3 +390,9 @@ fn test_get_ip_addresses_linux() { let val = ("192.168.1.203".parse().unwrap(), 32); assert!(interfaces.contains(&val)) } + +#[test] +fn test_get_interface_usage() { + use crate::KI; + let _ = KI.get_per_interface_usage().unwrap(); +} diff --git a/althea_kernel_interface/src/ping_check.rs b/althea_kernel_interface/src/ping_check.rs index 348ad2b16..3b717dee5 100644 --- a/althea_kernel_interface/src/ping_check.rs +++ b/althea_kernel_interface/src/ping_check.rs @@ -5,7 +5,7 @@ use std::net::IpAddr; use std::time::Duration; impl dyn KernelInterface { - //Pings a ipv6 address to determine if it's online + //Pings an address to determine if it's online pub fn ping_check( &self, ip: &IpAddr, diff --git a/althea_kernel_interface/src/traffic_control.rs b/althea_kernel_interface/src/traffic_control.rs index 931656a73..83b8fa33e 100644 --- a/althea_kernel_interface/src/traffic_control.rs +++ b/althea_kernel_interface/src/traffic_control.rs @@ -342,16 +342,8 @@ impl dyn KernelInterface { /// Generates a unique traffic class id for a exit user, essentially a really dumb hashing function pub fn get_class_id(&self, ip: Ipv4Addr) -> u32 { - format!( - "{}{}{}{}", - ip.octets()[3], - ip.octets()[2], - ip.octets()[1], - ip.octets()[0] - ) - .parse::() - .unwrap() - % 9999 //9999 is the maximum flow id value allowed + let num: u32 = ip.into(); + num % 9999 //9999 is the maximum flow id value allowed } /// Filters traffic from a given ipv6 address into the class that we are using diff --git a/althea_types/src/monitoring.rs b/althea_types/src/monitoring.rs index 2a93637f2..4714000ac 100644 --- a/althea_types/src/monitoring.rs +++ b/althea_types/src/monitoring.rs @@ -287,6 +287,26 @@ pub fn has_packet_loss(sample: u16) -> bool { lost_packets > 0 } +/// Represents various usage data and statistics for a given interface +/// parsed from /proc/net/dev +#[derive(Debug, Eq, PartialEq, Clone)] +pub struct InterfaceUsageStats { + pub interface_name: String, + pub recieve_bytes: u64, + pub transmit_bytes: u64, + pub recieve_packets: u64, + pub transmit_packets: u64, + pub recieve_errors: u64, + pub transmit_errors: u64, + pub recieve_dropped: u64, + pub recieve_fifo_errors: u64, + pub transmit_fifo_errors: u64, + pub recieve_frame_errors: u64, + pub recieve_multicast_erorrs: u64, + pub transmit_collission_erorrs: u64, + pub tranmist_carrier_errors: u64, +} + #[cfg(test)] mod tests { use super::*; diff --git a/antenna_forwarding_client/src/lib.rs b/antenna_forwarding_client/src/lib.rs index f13ac54a3..7154426f8 100644 --- a/antenna_forwarding_client/src/lib.rs +++ b/antenna_forwarding_client/src/lib.rs @@ -110,7 +110,7 @@ pub fn start_antenna_forwarding_proxy { // read messages will return a vec of at least one, - match messages.get(0) { + match messages.first() { Some(ForwardingProtocolMessage::ForwardMessage { ip, server_port: _server_port, diff --git a/babel_monitor/src/lib.rs b/babel_monitor/src/lib.rs index d8a2e3c13..09ad72c61 100644 --- a/babel_monitor/src/lib.rs +++ b/babel_monitor/src/lib.rs @@ -96,7 +96,7 @@ pub fn open_babel_stream( } /// Read function, you should always pass an empty string to the previous contents field -/// it's used when the function does not find a babel terminator and needs to recuse to get +/// it's used when the function does not find a babel terminator and needs to recurse to get /// the full message fn read_babel( stream: &mut TcpStream, @@ -174,6 +174,9 @@ fn read_babel( Ok(babel_data) } +/// Runs a command on the babeld management interface, returns the full return string of the command +/// this function will return an error if the command fails to write to the socket, but the command itself +/// may still fail, you should check the output using read_babel_sync in addition to other parse functions pub fn run_command(stream: &mut TcpStream, cmd: &str) -> Result { info!("Running babel command {}", cmd); let cmd = format!("{cmd}\n"); @@ -433,7 +436,7 @@ ok\n"; #[test] fn neigh_parse() { let neighs = parse_neighs_sync(TABLE.to_string()).unwrap(); - let neigh = neighs.get(0); + let neigh = neighs.first(); assert!(neigh.is_some()); let neigh = neigh.unwrap(); assert_eq!(neighs.len(), 4); @@ -445,7 +448,7 @@ ok\n"; let routes = parse_routes_sync(TABLE.to_string()).unwrap(); assert_eq!(routes.len(), 5); - let route = routes.get(0).unwrap(); + let route = routes.first().unwrap(); assert_eq!(route.price, 3072); } @@ -454,7 +457,7 @@ ok\n"; let interfaces = parse_interfaces_sync(TABLE.to_string()).unwrap(); assert_eq!(interfaces.len(), 5); - let iface = interfaces.get(0).unwrap(); + let iface = interfaces.first().unwrap(); assert!(!iface.up); let iface = interfaces.get(2).unwrap(); assert_eq!(iface.ipv4, Some("10.0.236.201".parse().unwrap())); @@ -478,7 +481,7 @@ ok\n"; let routes = parse_routes_sync(input).unwrap(); assert_eq!(routes.len(), 5); - let route = routes.get(0).unwrap(); + let route = routes.first().unwrap(); assert_eq!(route.price, 3072); // assert that these are equal within the minimum comparison difference // of float values diff --git a/babel_monitor/src/parsing.rs b/babel_monitor/src/parsing.rs index 1e34b20d0..d24a67a7f 100644 --- a/babel_monitor/src/parsing.rs +++ b/babel_monitor/src/parsing.rs @@ -11,6 +11,9 @@ use std::iter::Iterator; use std::net::IpAddr; use std::str::{self}; +/// Iterates over the output of a Babel dump and consumes the final line of output +/// determing if the babel command was successful or not, returning the rest of the output +/// for parsing by another function pub fn read_babel_sync(output: &str) -> Result { let mut ret = String::new(); for line in output.lines() { diff --git a/clu/src/lib.rs b/clu/src/lib.rs index 597259302..11c3c428a 100644 --- a/clu/src/lib.rs +++ b/clu/src/lib.rs @@ -15,7 +15,7 @@ use std::fs::File; use std::io::Read; use std::net::IpAddr; use std::path::Path; -use std::{str, thread}; +use std::thread; mod error; pub use error::NewCluError; @@ -300,18 +300,12 @@ fn linux_exit_init( Ok(settings) } -pub fn init(platform: &str, settings: RitaClientSettings) -> RitaClientSettings { - match platform { - "linux" => linux_init(settings).unwrap(), - _ => unimplemented!(), - } +pub fn init(settings: RitaClientSettings) -> RitaClientSettings { + linux_init(settings).unwrap() } -pub fn exit_init(platform: &str, settings: RitaExitSettingsStruct) -> RitaExitSettingsStruct { - match platform { - "linux" => linux_exit_init(settings).unwrap(), - _ => unimplemented!(), - } +pub fn exit_init(settings: RitaExitSettingsStruct) -> RitaExitSettingsStruct { + linux_exit_init(settings).unwrap() } #[cfg(test)] diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 0280be4c1..7d2d17c0b 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -39,3 +39,4 @@ lazy_static = "1.4" actix-web = { version = "4.3", default_features = false, features = [ "openssl", ] } +phonenumber = "0.3" diff --git a/integration_tests/src/registration_server.rs b/integration_tests/src/registration_server.rs index 989ab466e..b81a5d74e 100644 --- a/integration_tests/src/registration_server.rs +++ b/integration_tests/src/registration_server.rs @@ -89,6 +89,7 @@ async fn register_router(client: Json) -> HttpResponse { handle_sms_registration( client, "dummy key".to_string(), + "dummy-id".to_string(), Some(get_test_runner_magic_phone()), ) .await, diff --git a/integration_tests/src/setup_utils/rita.rs b/integration_tests/src/setup_utils/rita.rs index e194ed0a0..0872ba53b 100644 --- a/integration_tests/src/setup_utils/rita.rs +++ b/integration_tests/src/setup_utils/rita.rs @@ -155,7 +155,7 @@ pub fn spawn_rita( rcsettings.network.babeld_settings.local_fee = local_fee; // mirrored from rita_bin/src/client.rs - let s = clu::init("linux", rcsettings); + let s = clu::init(rcsettings); set_flag_config(config_path.into()); settings::set_rita_client(s.clone()); @@ -248,7 +248,7 @@ pub fn spawn_rita_exit( resettings.db_uri = "postgresql://postgres@10.0.0.1/test".to_string(); // mirrored from rita_bin/src/exit.rs - let resettings = clu::exit_init("linux", resettings); + let resettings = clu::exit_init(resettings); set_flag_config(config_path.into()); settings::set_rita_exit(resettings.clone()); diff --git a/integration_tests/src/utils.rs b/integration_tests/src/utils.rs index 1e5ba5289..a73a2d8a7 100644 --- a/integration_tests/src/utils.rs +++ b/integration_tests/src/utils.rs @@ -31,6 +31,7 @@ use nix::{ sched::{setns, CloneFlags}, sys::stat::Mode, }; +use phonenumber::PhoneNumber; use rita_common::{ debt_keeper::GetDebtsResult, payment_validator::{ALTHEA_CHAIN_PREFIX, ALTHEA_CONTACT_TIMEOUT}, @@ -138,8 +139,8 @@ pub fn get_eth_node() -> String { format!("http://{}:8545", NODE_IP) } -pub fn get_test_runner_magic_phone() -> String { - "+17040000000".to_string() +pub fn get_test_runner_magic_phone() -> PhoneNumber { + "+17040000000".parse().unwrap() } pub async fn deploy_contracts() -> Address { @@ -405,7 +406,7 @@ pub fn get_default_settings( exit.exit_network.cluster_exits = cluster_exits; client.exit_client.contact_info = Some( ContactType::Both { - number: get_test_runner_magic_phone().parse().unwrap(), + number: get_test_runner_magic_phone(), email: "fake@fake.com".parse().unwrap(), sequence_number: Some(0), } diff --git a/rita_bin/src/client.rs b/rita_bin/src/client.rs index 5181fafc5..160021d68 100644 --- a/rita_bin/src/client.rs +++ b/rita_bin/src/client.rs @@ -74,15 +74,11 @@ fn main() { // load the settings file, setup a thread to save it out every so often // and populate the memory cache of settings used throughout the program let settings: RitaClientSettings = { - let platform = &args.flag_platform; - RitaClientSettings::new_watched(settings_file.clone()).unwrap(); let mut s = settings::get_rita_client(); settings::set_flag_config(settings_file.clone()); - s.set_future(args.flag_future); - // start migrations // // handle babel migration for old settings files @@ -98,7 +94,7 @@ fn main() { // end migrations // - let s = clu::init(platform, s); + let s = clu::init(s); s.write(settings_file).unwrap(); settings::set_rita_client(s.clone()); diff --git a/rita_bin/src/exit.rs b/rita_bin/src/exit.rs index 67aa8381b..85bf2b924 100644 --- a/rita_bin/src/exit.rs +++ b/rita_bin/src/exit.rs @@ -76,7 +76,7 @@ fn main() { let settings_file = args.flag_config; let settings = RitaExitSettingsStruct::new_watched(&settings_file).unwrap(); - let settings = clu::exit_init("linux", settings); + let settings = clu::exit_init(settings); settings::set_rita_exit(settings.clone()); sanity_check_config(); println!("Look the exit settings! {settings:?}"); diff --git a/rita_client/src/exit_manager/exit_loop.rs b/rita_client/src/exit_manager/exit_loop.rs index a729295e1..52ed762a3 100644 --- a/rita_client/src/exit_manager/exit_loop.rs +++ b/rita_client/src/exit_manager/exit_loop.rs @@ -4,8 +4,7 @@ use crate::exit_manager::time_sync::maybe_set_local_to_exit_time; use crate::exit_manager::{ correct_default_route, exit_general_details_request, exit_status_request, get_client_pub_ipv6, get_cluster_ip_list, get_full_selected_exit, get_routes_hashmap, has_exit_changed, - initialize_selected_exit_list, linux_setup_exit_tunnel, remove_nat, restore_nat, run_ping_test, - set_exit_list, + initialize_selected_exit_list, linux_setup_exit_tunnel, remove_nat, restore_nat, set_exit_list, }; use crate::traffic_watcher::{query_exit_debts, QueryExitDebts}; use actix_async::System as AsyncSystem; @@ -21,8 +20,6 @@ use std::thread; use std::time::{Duration, Instant}; const EXIT_LOOP_SPEED: Duration = Duration::from_secs(5); -const PING_TEST_SPEED: Duration = Duration::from_secs(100); -const REBOOT_TIMEOUT: Duration = Duration::from_secs(600); /// How often we make a exit status request for registered exits. Prevents us from bogging up exit processing /// power const STATUS_REQUEST_QUERY: Duration = Duration::from_secs(600); @@ -78,23 +75,6 @@ pub fn start_exit_manager_loop() { } }; - // Run ping test only when we are registered to prevent constant reboots - if let ExitState::Registered { .. } = exit.info { - // Run this ping test every PING_TEST_SPEED seconds - if Instant::now() - em_state.last_connection_time > PING_TEST_SPEED { - if run_ping_test() { - em_state.last_connection_time = Instant::now(); - } else { - // If this router has been in a bad state for >10 mins, reboot - if (Instant::now() - em_state.last_connection_time) > REBOOT_TIMEOUT { - let _res = KI.run_command("reboot", &[]); - } - } - } - } else { - // reset our reboot timer every tick if not registered - em_state.last_connection_time = Instant::now(); - } // Get cluster exit list. This is saved locally and updated every tick depending on what exit we connect to. // When it is empty, it means an exit we connected to went down, and we use the list from memory to connect to a new instance @@ -336,9 +316,8 @@ pub fn start_exit_manager_loop() { e ); if Instant::now() - last_restart < Duration::from_secs(60) { - error!("Restarting too quickly, leaving it to auto rescue!"); - let sys = AsyncSystem::current(); - sys.stop_with_code(121); + error!("Restarting too quickly, rebooting instead!"); + let _res = KI.run_command("reboot", &[]); } last_restart = Instant::now(); } diff --git a/rita_client/src/exit_manager/mod.rs b/rita_client/src/exit_manager/mod.rs index 7b42bfc83..821015592 100644 --- a/rita_client/src/exit_manager/mod.rs +++ b/rita_client/src/exit_manager/mod.rs @@ -39,11 +39,9 @@ use sodiumoxide::crypto::box_; use sodiumoxide::crypto::box_::curve25519xsalsa20poly1305::Nonce; use sodiumoxide::crypto::box_::curve25519xsalsa20poly1305::PublicKey; use std::collections::{HashMap, HashSet}; -use std::net::Ipv4Addr; use std::net::{IpAddr, SocketAddr}; use std::sync::Arc; use std::sync::RwLock; -use std::time::Duration; use std::time::Instant; /// The number of times ExitSwitcher will try to connect to an unresponsive exit before blacklisting its ip @@ -88,31 +86,16 @@ pub struct LastExitStates { } /// An actor which pays the exit -#[derive(Clone)] +#[derive(Clone, Default)] pub struct ExitManager { pub nat_setup: bool, /// Every tick we query an exit endpoint to get a list of exits in that cluster. We use this list for exit switching pub exit_list: ExitList, /// Store last exit here, when we see an exit change, we reset wg tunnels pub last_exit_state: LastExitStates, - /// Store exit connection status. If no update in > 10, perform a power cycle - pub last_connection_time: Instant, - /// Store the last exit status request for all registered exits pub last_status_request: Option, } -impl Default for ExitManager { - fn default() -> Self { - ExitManager { - nat_setup: false, - exit_list: ExitList::default(), - last_exit_state: LastExitStates::default(), - last_connection_time: Instant::now(), - last_status_request: None, - } - } -} - /// This functions sets the exit list ONLY IF the list arguments provived is not empty. This is need for the following edge case: /// When an exit goes down, the endpoint wont repsond, so we have no exits to switch to. By setting only when we have a length > 1 /// we assure that we switch when an exit goes down @@ -788,19 +771,6 @@ pub fn get_client_pub_ipv6() -> Option { None } -/// Verifies ipv4 connectivity by pinging 1.1.1.1 -pub fn run_ping_test() -> bool { - let cloudflare: IpAddr = Ipv4Addr::new(1, 1, 1, 1).into(); - let timeout = Duration::from_secs(5); - match KI.ping_check(&cloudflare, timeout, None) { - Ok(out) => out, - Err(e) => { - error!("ipv4 ping error: {:?}", e); - false - } - } -} - /// Verfies if exit has changed to reestablish wg tunnels /// 1.) When exit instance ip has changed /// 2.) Exit reg details have chaged diff --git a/rita_client/src/heartbeat/mod.rs b/rita_client/src/heartbeat/mod.rs index dd0f3d0f7..2d34a6364 100644 --- a/rita_client/src/heartbeat/mod.rs +++ b/rita_client/src/heartbeat/mod.rs @@ -13,6 +13,7 @@ //! This packet is encrypted using the usual LibSodium box construction and sent to the heartbeat server in the following format //! WgKey, Nonce, Ciphertext for the HeartBeatMessage. This consumes 32 bytes, 24 bytes, and to the end of the message +use althea_kernel_interface::KI; use althea_types::ExitDetails; use babel_monitor::parsing::get_installed_route; @@ -113,9 +114,8 @@ pub fn send_heartbeat_loop() { } { error!("Heartbeat loop thread panicked! Respawning {:?}", e); if Instant::now() - last_restart < Duration::from_secs(60) { - error!("Restarting too quickly, leaving it to auto rescue!"); - let sys = actix_async::System::current(); - sys.stop_with_code(121); + error!("Restarting too quickly, rebooting instead!"); + let _res = KI.run_command("reboot", &[]); } last_restart = Instant::now(); } diff --git a/rita_client/src/lib.rs b/rita_client/src/lib.rs index 55e76a6e2..ce5cf42e8 100644 --- a/rita_client/src/lib.rs +++ b/rita_client/src/lib.rs @@ -25,7 +25,6 @@ pub use crate::dashboard::auth::*; pub use crate::dashboard::backup_created::*; pub use crate::dashboard::bandwidth_limit::*; pub use crate::dashboard::contact_info::*; -pub use crate::dashboard::contact_info::*; pub use crate::dashboard::eth_private_key::*; pub use crate::dashboard::exits::*; pub use crate::dashboard::extender_checkin::*; @@ -49,16 +48,12 @@ use settings::client::{default_config_path, APP_NAME}; pub struct Args { #[serde(default = "default_config_path")] pub flag_config: PathBuf, - pub flag_platform: String, - pub flag_future: bool, } impl Default for Args { fn default() -> Self { Args { flag_config: default_config_path(), - flag_platform: "linux".to_string(), - flag_future: false, } } } @@ -71,8 +66,6 @@ pub fn get_client_usage(version: &str, git_hash: &str) -> String { "Usage: {APP_NAME} [--config=] [--platform=] [--future] Options: -c, --config= Name of config file - -p, --platform= Platform (linux or OpenWrt) - --future Enable B side of A/B releases About: Version {READABLE_VERSION} - {version} git hash {git_hash}" diff --git a/rita_client/src/operator_update/update_loop.rs b/rita_client/src/operator_update/update_loop.rs index eab96cca4..2953d996f 100644 --- a/rita_client/src/operator_update/update_loop.rs +++ b/rita_client/src/operator_update/update_loop.rs @@ -3,6 +3,7 @@ use crate::operator_update::{operator_update, TARGET_UPDATE_FREQUENCY, UPDATE_FREQUENCY_CAP}; use actix_async::System as AsyncSystem; +use althea_kernel_interface::KI; use rand::Rng; use std::cmp::{max, min}; use std::thread; @@ -72,9 +73,8 @@ pub fn start_operator_update_loop() { e ); if Instant::now() - last_restart < Duration::from_secs(60) { - error!("Restarting too quickly, leaving it to auto rescue!"); - let sys = AsyncSystem::current(); - sys.stop_with_code(121); + error!("Restarting too quickly, rebooting instead!"); + let _res = KI.run_command("reboot", &[]); } last_restart = Instant::now(); } diff --git a/rita_client/src/rita_loop/mod.rs b/rita_client/src/rita_loop/mod.rs index 72f83daa4..45cde1dfe 100644 --- a/rita_client/src/rita_loop/mod.rs +++ b/rita_client/src/rita_loop/mod.rs @@ -11,15 +11,18 @@ use crate::heartbeat::HEARTBEAT_SERVER_KEY; use crate::operator_fee_manager::tick_operator_payments; use crate::InterfaceMode; use actix_async::System as AsyncSystem; +use althea_kernel_interface::hardware_info::get_hardware_info; use althea_kernel_interface::KernelInterfaceError; use althea_kernel_interface::KI; use althea_types::ExitState; use antenna_forwarding_client::start_antenna_forwarding_proxy; +use rand::Rng; use rita_common::rita_loop::set_gateway; use rita_common::tunnel_manager::tm_get_neighbors; use rita_common::usage_tracker::get_current_hour; use rita_common::usage_tracker::get_last_saved_usage_hour; use settings::client::RitaClientSettings; +use settings::get_rita_common; use std::collections::HashMap; use std::fs; use std::fs::File; @@ -29,6 +32,7 @@ use std::io::BufReader; use std::io::Read; use std::io::Seek; use std::net::IpAddr; +use std::net::Ipv4Addr; use std::path::Path; use std::sync::Arc; use std::sync::RwLock; @@ -36,7 +40,7 @@ use std::thread; use std::time::{Duration, Instant}; // the speed in seconds for the client loop -pub const CLIENT_LOOP_SPEED: Duration = Duration::from_secs(5); +pub const CLIENT_LOOP_SPEED: Duration = Duration::from_secs(30); pub const CLIENT_LOOP_TIMEOUT: Duration = Duration::from_secs(4); lazy_static! { @@ -84,24 +88,22 @@ pub fn metrics_permitted() -> bool { .is_some() } -/// Rita loop thread spawning function, there are currently two rita loops, one that -/// runs as a thread with async/await support and one that runs as a actor using old futures -/// slowly things will be migrated into this new sync loop as we move to async/await -pub fn start_rita_loop() { +/// Rita loop thread spawning function, this function contains all the rita client functions +/// with the exception of exit operations which have their own loop +pub fn start_rita_client_loop() { let mut last_restart = Instant::now(); // outer thread is a watchdog inner thread is the runner thread::spawn(move || { // this will always be an error, so it's really just a loop statement // with some fancy destructuring - while let Err(e) = { - thread::spawn(move || loop { - let start = Instant::now(); - trace!("Client tick!"); + thread::spawn(move || { + let mut last_successful_ping = Instant::now(); + loop { + let start = Instant::now(); + trace!("Client tick!"); - let runner = AsyncSystem::new(); - runner.block_on(async move { manage_gateway(); info!( "Rita Client loop manage gateway in {}s {}ms", @@ -123,30 +125,41 @@ pub fn start_rita_loop() { start.elapsed().subsec_millis() ); - // sends an operator payment if enough time has elapsed - tick_operator_payments().await; + last_successful_ping = check_for_rescue_reboot(last_successful_ping); info!( - "Rita Client loop operator payments completed in {}s {}ms", + "Rita Client loop check for rescue reboot completed in {}s {}ms", start.elapsed().as_secs(), start.elapsed().subsec_millis() ); - }); - info!( - "Rita Client loop completed in {}s {}ms", - start.elapsed().as_secs(), - start.elapsed().subsec_millis() - ); + // if you have additional async functions to run please add them here + // in order to reuse the runner + let runner = AsyncSystem::new(); + runner.block_on(async move { + // sends an operator payment if enough time has elapsed + tick_operator_payments().await; + info!( + "Rita Client loop operator payments completed in {}s {}ms", + start.elapsed().as_secs(), + start.elapsed().subsec_millis() + ); + }); + + info!( + "Rita Client loop completed in {}s {}ms", + start.elapsed().as_secs(), + start.elapsed().subsec_millis() + ); - thread::sleep(CLIENT_LOOP_SPEED); + thread::sleep(CLIENT_LOOP_SPEED); + } }) .join() } { error!("Rita client loop thread paniced! Respawning {:?}", e); if Instant::now() - last_restart < Duration::from_secs(60) { - error!("Restarting too quickly, leaving it to auto rescue!"); - let sys = AsyncSystem::current(); - sys.stop_with_code(121); + error!("Restarting too quickly, rebooting instead!"); + let _res = KI.run_command("reboot", &[]); } last_restart = Instant::now(); } @@ -158,7 +171,7 @@ pub fn start_rita_client_loops() { send_heartbeat_loop(); } crate::exit_manager::exit_loop::start_exit_manager_loop(); - crate::rita_loop::start_rita_loop(); + crate::rita_loop::start_rita_client_loop(); crate::operator_update::update_loop::start_operator_update_loop(); } @@ -377,7 +390,7 @@ pub fn update_dns_conf() { (Ok(dns_server_list), Ok(router_internal_ip)) => { // an empty list uses the system resolver, this is acceptable since we just set the system resolver to // point at the exit internal ip above - if let Some(first_server_list_entry) = dns_server_list.get(0) { + if let Some(first_server_list_entry) = dns_server_list.first() { if *first_server_list_entry != router_internal_ip { let mut dns_server_list = dns_server_list; dns_server_list.insert(0, router_internal_ip); @@ -482,3 +495,75 @@ fn maybe_parse_ip( Err(e) => Err(e), } } + +/// This list should contain as many unique public ips from as many different providers as possible +/// the larger this list the less we ping any specific provider and the less likely we are to be +/// confused by a single router being down +const PING_TEST_IPS: [Ipv4Addr; 6] = [ + // Cloudflare + Ipv4Addr::new(1, 1, 1, 1), + // Google + Ipv4Addr::new(8, 8, 8, 8), + // Quad9 + Ipv4Addr::new(9, 9, 9, 9), + // Hurricane Electric + Ipv4Addr::new(74, 82, 42, 42), + // OpenDNS + Ipv4Addr::new(208, 67, 222, 222), + // Verisin + Ipv4Addr::new(64, 6, 65, 6), +]; +/// Verifies ipv4 connectivity by pinging a set list of external ip addresses. This check +/// comes with some risk, if the ip addresses provided are all down, the router will reboot +/// even if connectivity to the rest of the internet is fine. To avoid this we ping several +/// different common addresses +pub fn run_ping_test() -> bool { + let mut rng = rand::thread_rng(); + let index = rng.gen_range(0..PING_TEST_IPS.len()); + let target_ip = PING_TEST_IPS[index]; + + let timeout = Duration::from_secs(5); + match KI.ping_check(&target_ip.into(), timeout, None) { + Ok(out) => out, + Err(e) => { + error!("ipv4 ping error: {:?}", e); + false + } + } +} + +const PING_TEST_SPEED: Duration = Duration::from_secs(100); +const REBOOT_TIMEOUT: Duration = Duration::from_secs(600); +/// This function checks if the router needs a rescue reboot. Meaning it has entered a bad state somehow and needs to be restarted +/// to recover. +fn check_for_rescue_reboot(mut last_successful_ping: Instant) -> Instant { + // first we check if we can reach the internet, if we can't for too long we reboot + + // Run this ping test every PING_TEST_SPEED seconds + if Instant::now() - last_successful_ping > PING_TEST_SPEED { + if run_ping_test() { + last_successful_ping = Instant::now(); + } else { + // If this router has been in a bad state for >10 mins, reboot + if (Instant::now() - last_successful_ping) > REBOOT_TIMEOUT { + let _res = KI.run_command("reboot", &[]); + } + } + } + + // next we check if the load average is too high for hAP specifically since they are more prone to this + let model = get_rita_common().network.device; + let hw_info = get_hardware_info(model.clone()); + match (model, hw_info) { + (None, _) => error!("Model name not found?"), + (Some(mdl), Ok(info)) => { + if mdl.contains("mikrotik_hap-ac2") && info.load_avg_fifteen_minute > 4.0 { + info!("15 minute load average > 4, rebooting!"); + let _res = KI.run_command("reboot", &[]); + } + } + (Some(_), Err(_)) => error!("Could not get hardware info!"), + } + + last_successful_ping +} diff --git a/rita_client_registration/src/lib.rs b/rita_client_registration/src/lib.rs index ce9d0b77a..c32624ec1 100644 --- a/rita_client_registration/src/lib.rs +++ b/rita_client_registration/src/lib.rs @@ -1,11 +1,14 @@ #![deny(unused_crate_dependencies)] use std::{ collections::{HashMap, HashSet}, + error::Error, + fmt::Display, sync::{Arc, RwLock}, time::Duration, }; use althea_types::{ExitClientIdentity, Identity, WgKey}; +use awc::error::SendRequestError; use clarity::Address; use phonenumber::PhoneNumber; use serde::{Deserialize, Serialize}; @@ -38,9 +41,29 @@ pub const TX_TIMEOUT: Duration = Duration::from_secs(60); /// Return struct from check_text and Send Text. Verified indicates status from api http req, /// bad phone number is an error parsing clients phone number /// Internal server error is an error while querying api endpoint -enum TextApiError { +#[derive(Debug)] +pub enum TextApiError { BadPhoneNumber, InternalServerError { error: String }, + SendRequestError { error: SendRequestError }, +} + +impl Display for TextApiError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TextApiError::BadPhoneNumber => write!(f, "InvalidPhoneNumber"), + TextApiError::InternalServerError { error } => write!(f, "Internal error {}", error), + TextApiError::SendRequestError { error } => write!(f, "{}", error), + } + } +} + +impl Error for TextApiError {} + +impl From for TextApiError { + fn from(value: SendRequestError) -> Self { + TextApiError::SendRequestError { error: value } + } } /// Return struct from Registration server to exit @@ -157,7 +180,8 @@ async fn client_exists( pub async fn handle_sms_registration( client: ExitClientIdentity, api_key: String, - magic_number: Option, + verify_profile_id: String, + magic_number: Option, ) -> ExitSignupReturn { info!( "Handling phone registration for {}", @@ -170,70 +194,92 @@ pub async fn handle_sms_registration( let text_num = get_texts_sent(client.global.wg_public_key); let sent_more_than_allowed_texts = text_num > 10; - match ( - client.reg_details.phone.clone(), - client.reg_details.phone_code.clone(), - sent_more_than_allowed_texts, - ) { - // all texts exhausted, but they can still submit the correct code - (Some(number), Some(code), true) => { - let is_magic = - magic_phone_number.is_some() && magic_phone_number.unwrap() == number.clone(); - let result = is_magic || { - match check_text(number.clone(), code, api_key).await { - Ok(a) => a, - Err(e) => return return_api_error(e), + match client.reg_details.phone { + Some(number) => match number.parse() { + Ok(number) => { + let number: PhoneNumber = number; + match ( + client.reg_details.phone_code.clone(), + sent_more_than_allowed_texts, + ) { + // all texts exhausted, but they can still submit the correct code + (Some(code), true) => { + let is_magic = magic_phone_number.is_some() + && magic_phone_number.unwrap() == number.clone(); + let result = is_magic || { + match check_sms_auth_result( + number.clone(), + code, + api_key, + verify_profile_id, + ) + .await + { + Ok(a) => a, + Err(e) => return return_api_error(e), + } + }; + if result { + info!( + "Phone registration complete for {}", + client.global.wg_public_key + ); + + add_client_to_reg_batch(client.global); + reset_texts_sent(client.global.wg_public_key); + ExitSignupReturn::RegistrationOk + } else { + ExitSignupReturn::PendingRegistration + } + } + // user has exhausted attempts but is still not submitting code + (None, true) => ExitSignupReturn::PendingRegistration, + // user has attempts remaining and is requesting the code be resent + (None, false) => { + if let Err(e) = + start_sms_auth_flow(number, api_key, verify_profile_id).await + { + return return_api_error(e); + } + increment_texts_sent(client.global.wg_public_key); + ExitSignupReturn::PendingRegistration + } + // user has attempts remaining and is submitting a code + (Some(code), false) => { + let is_magic = magic_phone_number.is_some() + && magic_phone_number.unwrap() == number.clone(); + + let result = is_magic || { + match check_sms_auth_result( + number.clone(), + code, + api_key, + verify_profile_id, + ) + .await + { + Ok(a) => a, + Err(e) => return return_api_error(e), + } + }; + trace!("Check text returned {}", result); + if result { + info!( + "Phone registration complete for {}", + client.global.wg_public_key + ); + add_client_to_reg_batch(client.global); + reset_texts_sent(client.global.wg_public_key); + ExitSignupReturn::RegistrationOk + } else { + ExitSignupReturn::PendingRegistration + } + } } - }; - if result { - info!( - "Phone registration complete for {}", - client.global.wg_public_key - ); - - add_client_to_reg_batch(client.global); - reset_texts_sent(client.global.wg_public_key); - ExitSignupReturn::RegistrationOk - } else { - ExitSignupReturn::PendingRegistration - } - } - // user has exhausted attempts but is still not submitting code - (Some(_number), None, true) => ExitSignupReturn::PendingRegistration, - // user has attempts remaining and is requesting the code be resent - (Some(number), None, false) => { - if let Err(e) = send_text(number, api_key).await { - return return_api_error(e); } - increment_texts_sent(client.global.wg_public_key); - ExitSignupReturn::PendingRegistration - } - // user has attempts remaining and is submitting a code - (Some(number), Some(code), false) => { - let is_magic = - magic_phone_number.is_some() && magic_phone_number.unwrap() == number.clone(); - - let result = is_magic || { - match check_text(number.clone(), code, api_key).await { - Ok(a) => a, - Err(e) => return return_api_error(e), - } - }; - trace!("Check text returned {}", result); - if result { - info!( - "Phone registration complete for {}", - client.global.wg_public_key - ); - add_client_to_reg_batch(client.global); - reset_texts_sent(client.global.wg_public_key); - ExitSignupReturn::RegistrationOk - } else { - ExitSignupReturn::PendingRegistration - } - } - // user did not submit a phonenumber - (None, _, _) => ExitSignupReturn::BadPhoneNumber, + Err(_) => ExitSignupReturn::BadPhoneNumber, + }, + None => ExitSignupReturn::BadPhoneNumber, } } @@ -243,74 +289,80 @@ fn return_api_error(e: TextApiError) -> ExitSignupReturn { TextApiError::InternalServerError { error } => { ExitSignupReturn::InternalServerError { e: error } } + TextApiError::SendRequestError { error } => ExitSignupReturn::InternalServerError { + e: error.to_string(), + }, } } +#[derive(Serialize)] +pub struct TelnyxSmsAuthCheck { + verify_profile_id: String, + code: String, +} + /// Posts to the validation endpoint with the code, will return success if the code /// is the same as the one sent to the user -async fn check_text(number: String, code: String, api_key: String) -> Result { - trace!("About to check text message status for {}", number); - let number: PhoneNumber = match number.parse() { - Ok(number) => number, - Err(e) => { - error!("Phone parse error: {}", e); - return Err(TextApiError::BadPhoneNumber); - } - }; - let url = "https://api.authy.com/protected/json/phones/verification/check"; +pub async fn check_sms_auth_result( + number: PhoneNumber, + code: String, + bearer_key: String, + verify_profile_id: String, +) -> Result { + info!("About to check text message status for {}", number); + + let check_url = format!( + "https://api.telnyx.com/v2/verifications/by_phone_number/{}/actions/verify", + number + ); let client = awc::Client::default(); - let response = match client - .get(url) - .send_form(&SmsCheck { - api_key, - verification_code: code, - phone_number: number.national().to_string(), - country_code: number.code().value().to_string(), + match client + .post(check_url) + .bearer_auth(bearer_key) + .send_json(&TelnyxSmsAuthCheck { + verify_profile_id, + code, }) .await { - Ok(a) => a, + Ok(a) => Ok(a.status().is_success()), Err(e) => { - return Err(TextApiError::InternalServerError { - error: e.to_string(), - }) + error!("Failed to verify code with {:?}", e); + Err(e.into()) } - }; - - trace!("Got {} back from check text", response.status()); - Ok(response.status().is_success()) + } } -/// Sends the authy verification text by hitting the api endpoint -async fn send_text(number: String, api_key: String) -> Result<(), TextApiError> { - info!("Sending message for {}", number); - let url = "https://api.authy.com/protected/json/phones/verification/start"; - let number: PhoneNumber = match number.parse() { - Ok(number) => number, - Err(e) => { - error!("Parse phone number error {}", e); - return Err(TextApiError::BadPhoneNumber); - } - }; +#[derive(Serialize)] +pub struct TelnyxAuthMessage { + /// user target number + pub phone_number: String, + pub verify_profile_id: String, +} +/// Url for sending auth code +const URL_START: &str = "https://api.telnyx.com/v2/verifications/sms"; +pub async fn start_sms_auth_flow( + phone_number: PhoneNumber, + bearer_key: String, + verify_profile_id: String, +) -> Result<(), TextApiError> { let client = awc::Client::default(); match client - .post(url) - .send_form(&SmsRequest { - api_key, - via: "sms".to_string(), - phone_number: number.national().to_string(), - country_code: number.code().value().to_string(), + .post(URL_START) + .bearer_auth(bearer_key) + .timeout(Duration::from_secs(1)) + .send_json(&TelnyxAuthMessage { + phone_number: phone_number.to_string(), + verify_profile_id, }) .await { - Ok(_a) => Ok(()), + Ok(_) => Ok(()), Err(e) => { - error!("Send text error! {}", e); - Err(TextApiError::InternalServerError { - error: e.to_string(), - }) + error!("auth text error {:?}", e); + Err(e.into()) } } } diff --git a/rita_common/src/rita_loop/fast_loop.rs b/rita_common/src/rita_loop/fast_loop.rs index ddded8a05..870406a77 100644 --- a/rita_common/src/rita_loop/fast_loop.rs +++ b/rita_common/src/rita_loop/fast_loop.rs @@ -9,6 +9,7 @@ use crate::peer_listener::structs::PeerListener; use crate::traffic_watcher::watch; use crate::tunnel_manager::contact_peers::tm_contact_peers; use crate::tunnel_manager::tm_get_neighbors; +use crate::KI; use actix_async::System as AsyncSystem; use babel_monitor::open_babel_stream; use babel_monitor::parse_neighs; @@ -107,11 +108,13 @@ pub fn start_rita_fast_loop() { }) .join() } { - error!("Rita common fast loop thread paniced! Respawning {:?}", e); + error!("Rita common fast loop thread panicked! Respawning {:?}", e); if Instant::now() - last_restart < Duration::from_secs(60) { - error!("Restarting too quickly, leaving it to auto rescue!"); - let sys = AsyncSystem::current(); - sys.stop_with_code(121); + error!("Restarting too quickly, rebooting instead!"); + // only reboot if we are on openwrt, otherwise we are probably on a datacenter server rebooting that is a bad idea + if KI.is_openwrt() { + let _res = KI.run_command("reboot", &[]); + } } last_restart = Instant::now(); } @@ -171,9 +174,11 @@ pub fn peer_discovery_loop() { e ); if Instant::now() - last_restart < Duration::from_secs(60) { - error!("Restarting too quickly, leaving it to auto rescue!"); - let sys = AsyncSystem::current(); - sys.stop_with_code(121); + error!("Restarting too quickly, rebooting instead!"); + // only reboot if we are on openwrt, otherwise we are probably on a datacenter server rebooting that is a bad idea + if KI.is_openwrt() { + let _res = KI.run_command("reboot", &[]); + } } last_restart = Instant::now(); } diff --git a/rita_common/src/rita_loop/slow_loop.rs b/rita_common/src/rita_loop/slow_loop.rs index 66a9f3a17..eef6d1c4a 100644 --- a/rita_common/src/rita_loop/slow_loop.rs +++ b/rita_common/src/rita_loop/slow_loop.rs @@ -4,13 +4,11 @@ use crate::token_bridge::tick_token_bridge; use crate::tunnel_manager::tm_common_slow_loop_helper; use crate::KI; use actix_async::System as AsyncSystem; -use althea_kernel_interface::hardware_info::get_hardware_info; use babel_monitor::open_babel_stream; use babel_monitor::parse_interfaces; use babel_monitor::set_local_fee; use babel_monitor::set_metric_factor; use babel_monitor::structs::BabelMonitorError; -use settings::get_rita_common; use std::net::TcpStream; use std::thread; use std::time::Duration; @@ -35,8 +33,6 @@ pub fn start_rita_slow_loop() { info!("Common Slow tick!"); let start = Instant::now(); - check_for_hap_reboot(); - // checks for and updates tunnel manager traffic shaper values handle_shaping(); @@ -56,7 +52,7 @@ pub fn start_rita_slow_loop() { Ok(mut stream) => { // we really only need to run this on startup, but doing so periodically // could catch the edge case where babel is restarted under us - if let Err(e) = update_babel_price_and_metric_factor(&mut stream) { + if let Err(e) = set_babel_price(&mut stream) { warn!("Failed to set babel price with {:?}", e); num_babel_failures += 1; } @@ -106,35 +102,18 @@ pub fn start_rita_slow_loop() { } { error!("Rita common slow loop thread panicked! Respawning {:?}", e); if Instant::now() - last_restart < Duration::from_secs(120) { - error!("Restarting too quickly, leaving it to auto rescue!"); - let sys = AsyncSystem::current(); - sys.stop_with_code(121); + error!("Restarting too quickly, rebooting instead!"); + // only reboot if we are on openwrt, otherwise we are probably on a datacenter server rebooting that is a bad idea + if KI.is_openwrt() { + let _res = KI.run_command("reboot", &[]); + } } last_restart = Instant::now(); } }); } -/// This is a special handler for hAP routers which have a habit of getting locked up in -/// runway cpu use cases, restarting them usually resolves it -fn check_for_hap_reboot() { - let model = get_rita_common().network.device; - let hw_info = get_hardware_info(model.clone()); - match (model, hw_info) { - (None, _) => error!("Model name not found?"), - (Some(mdl), Ok(info)) => { - if mdl.contains("mikrotik_hap-ac2") && info.load_avg_fifteen_minute > 4.0 { - info!("15 minute load average > 4, rebooting!"); - let _res = KI.run_command("reboot", &[]); - } - } - (Some(_), Err(_)) => error!("Could not get hardware info!"), - } -} - -/// This function updates the babeld price and metric factor by connecting to the babel instance and -/// setting those values. -fn update_babel_price_and_metric_factor(stream: &mut TcpStream) -> Result<(), BabelMonitorError> { +fn set_babel_price(stream: &mut TcpStream) -> Result<(), BabelMonitorError> { let start = Instant::now(); let common = settings::get_rita_common(); let local_fee = common.network.babeld_settings.local_fee; diff --git a/rita_exit/src/operator_update/update_loop.rs b/rita_exit/src/operator_update/update_loop.rs index 223922cef..3887e4712 100644 --- a/rita_exit/src/operator_update/update_loop.rs +++ b/rita_exit/src/operator_update/update_loop.rs @@ -3,11 +3,10 @@ use crate::operator_update::{operator_update, UPDATE_FREQUENCY}; use actix_async::System as AsyncSystem; use std::thread; -use std::time::{Duration, Instant}; +use std::time::Instant; /// This function spawns a thread soley responsible for performing the operator update pub fn start_operator_update_loop() { - let mut last_restart = Instant::now(); let rita_started = Instant::now(); // outer thread is a watchdog inner thread is the runner thread::spawn(move || { @@ -39,12 +38,6 @@ pub fn start_operator_update_loop() { "Rita exit Operator Update loop thread paniced! Respawning {:?}", e ); - if Instant::now() - last_restart < Duration::from_secs(60) { - error!("Restarting too quickly, leaving it to auto rescue!"); - let sys = AsyncSystem::current(); - sys.stop_with_code(121); - } - last_restart = Instant::now(); } }); } diff --git a/rita_exit/src/rita_loop/mod.rs b/rita_exit/src/rita_loop/mod.rs index 1c8914b85..5df0816b4 100644 --- a/rita_exit/src/rita_loop/mod.rs +++ b/rita_exit/src/rita_loop/mod.rs @@ -76,7 +76,6 @@ pub type ExitLock = Arc>>; /// thread which simply restarts the billing. pub fn start_rita_exit_loop() { setup_exit_wg_tunnel(); - let mut last_restart = Instant::now(); // the last usage of the wg tunnels, if an innner thread restarts this must be preserved to prevent // overbilling users @@ -103,12 +102,6 @@ pub fn start_rita_exit_loop() { .join() } { error!("Exit loop thread panicked! Respawning {:?}", e); - if Instant::now() - last_restart < Duration::from_secs(60) { - error!("Restarting too quickly, leaving it to systemd!"); - let sys = AsyncSystem::current(); - sys.stop_with_code(121); - } - last_restart = Instant::now(); } }); } diff --git a/settings/src/client.rs b/settings/src/client.rs index 09a2cb698..ad4c1f594 100644 --- a/settings/src/client.rs +++ b/settings/src/client.rs @@ -164,7 +164,11 @@ impl ExitClientSettings { impl RitaClientSettings { pub fn new(file_name: &str) -> Result { if !Path::new(file_name).exists() { - return Err(SettingsError::FileNotFoundError(file_name.to_string())); + error!( + "Failed to find settings file at location {}, generating", + file_name + ); + return Ok(RitaClientSettings::default()); } let config_toml = std::fs::read_to_string(file_name)?; @@ -227,8 +231,6 @@ pub struct RitaClientSettings { pub localization: LocalizationSettings, pub network: NetworkSettings, pub exit_client: ExitClientSettings, - #[serde(skip)] - pub future: bool, #[serde(default = "default_app_name")] pub app_name: String, /// The save interval defaults to 48 hours for exit settings represented in seconds @@ -267,12 +269,4 @@ impl RitaClientSettings { self.network.nickname, )) } - - pub fn get_future(&self) -> bool { - self.future - } - - pub fn set_future(&mut self, future: bool) { - self.future = future - } }