From 7a49ac320c56ab38b7a931564b691408172747b7 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Thu, 2 Nov 2023 11:29:49 +0100 Subject: [PATCH] misc updates for ipblc (#6) Reviewed-on: https://git.paulbsd.com/paulbsd/ipblc/pulls/6 --- .drone.yml | 4 + Cargo.lock | 550 ++++++++++++++++++------------------------- Cargo.toml | 16 +- Dockerfile | 2 +- src/config.rs | 89 +++++-- src/fw.rs | 142 +++++++---- src/ip.rs | 85 +++---- src/ipblc.rs | 73 +++--- src/monitoring.rs | 1 - src/regexps/ipv6.txt | 2 +- src/webservice.rs | 2 + src/websocket.rs | 12 +- 12 files changed, 493 insertions(+), 485 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9e9ad53..47b6c9d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,6 +10,7 @@ platform: steps: - name: test and build image: rust:1 + pull: always commands: - apt-get update -y - apt-get install -y libnftnl-dev libmnl-dev @@ -26,6 +27,7 @@ steps: - tag - name: release image: rust:1 + pull: always commands: - apt-get update -y - apt-get install -y libnftnl-dev libmnl-dev @@ -75,6 +77,7 @@ platform: steps: - name: test and build image: rust:1 + pull: always commands: - apt-get update -y - apt-get install -y libnftnl-dev libmnl-dev @@ -91,6 +94,7 @@ steps: - tag - name: release image: rust:1 + pull: always commands: - apt-get update -y - apt-get install -y libnftnl-dev libmnl-dev diff --git a/Cargo.lock b/Cargo.lock index 085bcba..a8e9070 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -43,30 +43,29 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -82,9 +81,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys", @@ -98,9 +97,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -113,9 +112,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.2" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bitflags" @@ -125,9 +124,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "block-buffer" @@ -140,27 +139,30 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -170,34 +172,33 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "serde", - "time", "wasm-bindgen", - "winapi", + "windows-targets", ] [[package]] name = "clap" -version = "4.3.19" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" +checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.19" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" dependencies = [ "anstream", "anstyle", @@ -207,9 +208,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "colorchoice" @@ -235,9 +236,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -270,9 +271,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] @@ -291,27 +292,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "fnv" version = "1.0.7" @@ -329,54 +309,41 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-macro" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.27", -] +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-core", - "futures-macro", "futures-task", "pin-project-lite", "pin-utils", - "slab", ] [[package]] @@ -397,14 +364,14 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "git-version" @@ -430,9 +397,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -455,9 +422,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "http" @@ -489,9 +456,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" @@ -510,7 +477,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -519,9 +486,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -533,16 +500,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -576,7 +543,7 @@ dependencies = [ [[package]] name = "ipblc" -version = "1.2.2" +version = "1.3.0" dependencies = [ "chrono", "clap", @@ -596,20 +563,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" - -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", -] +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itoa" @@ -619,9 +575,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] @@ -634,21 +590,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - -[[package]] -name = "linux-raw-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -656,24 +606,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "mime" @@ -692,12 +633,12 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys", ] @@ -747,23 +688,20 @@ dependencies = [ [[package]] name = "nix" -version = "0.26.2" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "cfg-if", "libc", - "memoffset", - "pin-utils", - "static_assertions", ] [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -780,9 +718,9 @@ dependencies = [ [[package]] name = "object" -version = "0.31.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -811,9 +749,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", @@ -830,9 +768,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -884,18 +822,18 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -932,18 +870,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.9.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", @@ -953,9 +891,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.3" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -964,15 +902,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ "base64", "bytes", @@ -996,6 +934,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-rustls", "tower-service", @@ -1009,17 +948,16 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.20" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", + "getrandom", "libc", - "once_cell", "spin", "untrusted", - "web-sys", - "winapi", + "windows-sys", ] [[package]] @@ -1028,24 +966,11 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustix" -version = "0.38.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" -dependencies = [ - "bitflags 2.3.3", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "rustls" -version = "0.21.5" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79ea77c539259495ce8ca47f53e66ae0330a8819f67e23ac96ca02f50e7b7d36" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", "ring", @@ -1076,9 +1001,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.101.1" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f36a6828982f422756984e47912a7a51dcbc2a197aa791158f8ca61cd8204e" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ "ring", "untrusted", @@ -1113,9 +1038,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", @@ -1146,29 +1071,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.174" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b88756493a5bd5e5395d53baa70b194b05764ab85b59e43e4b8f4e1192fa9b1" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.174" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5c3a298c7f978e53536f95a63bdc4c4a64550582f31a0359a9afda6aede62e" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.38", ] [[package]] name = "serde_json" -version = "1.0.103" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -1189,9 +1114,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -1209,40 +1134,44 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", ] [[package]] -name = "spin" -version = "0.5.2" +name = "socket2" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys", +] [[package]] -name = "static_assertions" -version = "1.1.0" +name = "spin" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strsim" @@ -1263,9 +1192,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.27" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -1285,34 +1214,44 @@ dependencies = [ ] [[package]] -name = "thiserror" -version = "1.0.44" +name = "system-configuration" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.27", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", + "syn 2.0.38", ] [[package]] @@ -1332,11 +1271,10 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", @@ -1345,7 +1283,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2", + "socket2 0.5.5", "tokio-macros", "windows-sys", ] @@ -1358,7 +1296,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.38", ] [[package]] @@ -1373,9 +1311,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -1393,20 +1331,19 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] @@ -1419,9 +1356,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "tungstenite" -version = "0.19.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15fba1a6d6bb030745759a9a2a588bfe8490fc8b4751a277db3a0be1c9ebbf67" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ "byteorder", "bytes", @@ -1436,14 +1373,13 @@ dependencies = [ "thiserror", "url", "utf-8", - "webpki", ] [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" @@ -1453,9 +1389,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -1474,15 +1410,15 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -1516,12 +1452,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1530,9 +1460,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1540,24 +1470,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.38", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if", "js-sys", @@ -1567,9 +1497,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1577,51 +1507,38 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki-roots" -version = "0.22.6" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki", -] +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "winapi" @@ -1646,10 +1563,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets", ] @@ -1665,9 +1582,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1680,51 +1597,52 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 591f006..4903e20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ipblc" -version = "1.2.2" +version = "1.3.0" edition = "2021" authors = ["PaulBSD "] description = "ipblc is a tool that search and send attacking ip addresses to ipbl" @@ -10,19 +10,19 @@ repository = "https://git.paulbsd.com/paulbsd/ipblc" [dependencies] chrono = { version = "0.4", features = ["serde"] } -clap = { version = "4.2", features = ["string"] } +clap = { version = "4.4", features = ["string"] } git-version = "0.3" -ipnet = "2.7" +ipnet = "2.9" lazy_static = "1.4" mnl = "0.2" nftnl = "0.6" -nix = "0.26" -regex = "1.8" -reqwest = { version = "0.11", default-features = false, features = ["json","rustls-tls"] } +nix = { version = "0.27", features = ["hostname", "inotify"] } +regex = "1.10" +reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -tokio = { version = "1.28", features = ["full", "sync"] } -tungstenite = { version = "0.19", features = ["handshake","rustls-tls-native-roots"] } +tokio = { version = "1.33", features = ["full", "sync"] } +tungstenite = { version = "0.20", features = ["handshake", "rustls-tls-native-roots"] } ## to optimize binary size (slow compile time) #[profile.release] diff --git a/Dockerfile b/Dockerfile index a9a1404..fa0146c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,5 +2,5 @@ FROM rustembedded/cross:aarch64-unknown-linux-musl RUN dpkg --add-architecture arm64 RUN apt-get update -RUN apt-get install -y libasound2-dev:arm64 libzmq3-dev libnftnl-dev libmnl-dev libmnl0:arm64 libnftnl7:arm64 libmnl0:amd64 libnftnl0:arm64 +RUN apt-get install -y libnftnl-dev libmnl-dev libmnl0:arm64 libnftnl7:arm64 libmnl0:amd64 libnftnl0:arm64 RUN apt-get clean diff --git a/src/config.rs b/src/config.rs index cf6fccd..3610071 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,7 +6,7 @@ use chrono::Duration; use clap::{Arg, ArgAction, ArgMatches, Command}; use git_version::git_version; use ipnet::IpNet; -use nix::sys::inotify::{AddWatchFlags, InitFlags, Inotify, WatchDescriptor}; +use nix::sys::inotify::{AddWatchFlags, Inotify, WatchDescriptor}; use regex::Regex; use reqwest::{Client, Error as ReqError, Response}; use serde::{Deserialize, Serialize}; @@ -17,16 +17,15 @@ use std::path::Path; pub const GIT_VERSION: &str = git_version!(args = ["--always", "--dirty="]); const MASTERSERVER: &str = "ipbl.paulbsd.com"; const WSSUBSCRIPTION: &str = "ipbl"; -const CONFIG_RETRY: u64 = 1; +const CONFIG_RETRY: u64 = 2; const WEB_CLIENT_TIMEOUT: i64 = 5; -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct Context { pub blocklist: HashMap, pub cfg: Config, pub discovery: Discovery, pub flags: Flags, - pub instance: Box, pub sas: HashMap, pub hashwd: HashMap, } @@ -48,7 +47,7 @@ pub struct Flags { } impl Context { - pub async fn new() -> Self { + pub async fn new(inotify: &Inotify) -> Self { // Get flags let argp: ArgMatches = Context::argparse(); let debug: bool = argp.get_one::("debug").unwrap().to_owned(); @@ -63,13 +62,12 @@ impl Context { urls: HashMap::new(), }, sas: HashMap::new(), - instance: Box::new(Inotify::init(InitFlags::empty()).unwrap()), blocklist: HashMap::new(), hashwd: HashMap::new(), }; print!("Loading config ... "); - ctx.load().await.unwrap(); + ctx.load(&inotify).await.unwrap(); ctx } @@ -113,7 +111,7 @@ impl Context { Ok(data) } - pub async fn load(&mut self) -> Result<(), Box> { + pub async fn load(&mut self, inotify: &Inotify) -> Result<(), Box> { if cfg!(test) { return Ok(()); } @@ -128,7 +126,7 @@ impl Context { break; } Err(err) => { - println!("error loading config: {err}, retrying in {CONFIG_RETRY} secs"); + println!("error loading config: {err}, retrying in {CONFIG_RETRY}s"); last_in_err = true; sleep_s(CONFIG_RETRY).await; } @@ -137,7 +135,7 @@ impl Context { if last_in_err { println!("creating sas"); } - self.create_sas().await?; + self.create_sas(&inotify).await?; if last_in_err { println!("created sas"); } @@ -153,9 +151,9 @@ impl Context { res } - pub async fn get_blocklist_toblock(&mut self) -> Vec { + pub async fn get_blocklist_toblock(&self) -> Vec { let mut res: Vec = vec![]; - for (_, block) in self.blocklist.iter_mut() { + for (_, block) in self.blocklist.iter() { match self.cfg.sets.get(&block.ipdata.src) { Some(set) => { if block.tryfail >= set.tryfail { @@ -228,15 +226,17 @@ impl Context { removed } - pub async fn create_sas(&mut self) -> Result<(), Box> { + pub async fn create_sas( + &mut self, + inotify: &Inotify, + ) -> Result<(), Box> { for (src, set) in self.cfg.sets.iter() { let p = Path::new(set.path.as_str()); if p.is_dir() { let wd = match self.hashwd.get(&set.path.to_string()) { Some(wd) => *wd, None => { - let res = self - .instance + let res = inotify .add_watch(set.path.as_str(), AddWatchFlags::IN_MODIFY) .unwrap(); self.hashwd.insert(set.path.to_string(), res); @@ -443,6 +443,26 @@ impl Config { Ok(()) } + pub async fn _get_last(server: &String) -> Result, ReqError> { + let resp = httpclient() + .get(format!("{server}/ips/last")) + .query(&[("interval", "3 hours")]) + .send() + .await; + + let req = match resp { + Ok(re) => re, + Err(err) => return Err(err), + }; + + let data: Vec = match req.json::>().await { + Ok(res) => res, + Err(err) => return Err(err), + }; + + Ok(data) + } + pub fn build_trustnets(&self) -> Vec { let mut trustnets: Vec = vec![]; for trustnet in &self.trustnets { @@ -462,6 +482,7 @@ impl Config { mode: String::from("ws"), hostname: gethostname(true), ipdata: IpData { + t: 4, ip: "".to_string(), src: "".to_string(), date: "".to_string(), @@ -538,10 +559,12 @@ impl Hash for Set { mod test { use super::*; use crate::ip::*; + use nix::sys::inotify::InitFlags; use Context; pub async fn prepare_test_data() -> Context { - let mut ctx = Context::new().await; + let inotify = Inotify::init(InitFlags::empty()).unwrap(); + let mut ctx = Context::new(&inotify).await; let now: DateTime = Local::now().trunc_subsecs(0); ctx.blocklist = HashMap::new(); @@ -551,6 +574,7 @@ mod test { mode: String::from("ws"), hostname: String::from("localhost"), ipdata: IpData { + t: 4, ip: "1.1.1.1".to_string(), hostname: "test1".to_string(), date: now.to_rfc3339().to_string(), @@ -566,6 +590,7 @@ mod test { mode: String::from("ws"), hostname: String::from("localhost"), ipdata: IpData { + t: 4, ip: "1.1.1.2".to_string(), hostname: "test2".to_string(), date: now.to_rfc3339().to_string(), @@ -580,6 +605,7 @@ mod test { mode: String::from("ws"), hostname: String::from("localhost"), ipdata: IpData { + t: 4, ip: "1.1.1.3".to_string(), hostname: "testgood".to_string(), date: now.to_rfc3339().to_string(), @@ -593,6 +619,7 @@ mod test { mode: String::from("ws"), hostname: String::from("localhost"), ipdata: IpData { + t: 4, ip: "1.1.1.4".to_string(), hostname: "testgood".to_string(), date: now.to_rfc3339().to_string(), @@ -606,6 +633,7 @@ mod test { mode: String::from("ws"), hostname: String::from("localhost"), ipdata: IpData { + t: 4, ip: "1.1.1.4".to_string(), hostname: "testgood".to_string(), date: now.to_rfc3339().to_string(), @@ -613,11 +641,24 @@ mod test { }, }) .await; + ctx.update_blocklist(&mut IpEvent { + msgtype: String::from("add"), + mode: String::from("ws"), + hostname: String::from("localhost"), + ipdata: IpData { + t: 6, + ip: "2a00:1450:4007:805::2003".to_string(), + hostname: "testgood".to_string(), + date: now.to_rfc3339().to_string(), + src: "http".to_string(), + }, + }) + .await; - let mut ip1 = ctx.blocklist.get_mut(&"1.1.1.1".to_string()).unwrap(); + let ip1 = ctx.blocklist.get_mut(&"1.1.1.1".to_string()).unwrap(); ip1.starttime = DateTime::from(now) - Duration::minutes(61); - let mut ip2 = ctx.blocklist.get_mut(&"1.1.1.2".to_string()).unwrap(); + let ip2 = ctx.blocklist.get_mut(&"1.1.1.2".to_string()).unwrap(); ip2.starttime = DateTime::from(now) - Duration::minutes(62); ctx } @@ -627,8 +668,14 @@ mod test { let ctx = prepare_test_data().await; let pending = ctx.get_blocklist_pending().await; - assert_eq!(pending.len(), 4); - let ips = ["1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4"]; + assert_eq!(pending.len(), 5); + let ips = [ + "1.1.1.1", + "1.1.1.2", + "1.1.1.3", + "1.1.1.4", + "2a00:1450:4007:805::2003", + ]; for i in ips { let ip = ctx .blocklist @@ -646,7 +693,7 @@ mod test { let mut ctx = prepare_test_data().await; ctx.gc_blocklist().await; let toblock = ctx.get_blocklist_toblock().await; - assert_eq!(toblock.len(), 2); + assert_eq!(toblock.len(), 3); } #[tokio::test] diff --git a/src/fw.rs b/src/fw.rs index b08f219..8eba965 100644 --- a/src/fw.rs +++ b/src/fw.rs @@ -2,13 +2,44 @@ use crate::ip::IpData; use crate::ipblc::PKG_NAME; use nftnl::{nft_expr, Batch, Chain, FinalizedBatch, ProtoFamily, Rule, Table}; -use std::{ffi::CString, io::Error, net::Ipv4Addr}; +use std::{ + ffi::CString, + io::Error, + net::{Ipv4Addr, Ipv6Addr}, +}; -pub fn fwinit() -> (Batch, Table) { +pub enum FwTableType { + IPv4, + IPv6, +} + +pub fn fwglobalinit<'a>() -> ((Batch, Table), (Batch, Table)) { + let (batch4, table4) = fwinit(FwTableType::IPv4); + let (batch6, table6) = fwinit(FwTableType::IPv6); + ((batch4, table4), (batch6, table6)) +} + +fn fwinit(t: FwTableType) -> (Batch, Table) { + let table_name: String; + let table: Table; + match t { + FwTableType::IPv4 => { + table_name = format!("{PKG_NAME}4"); + table = Table::new( + &CString::new(format!("{table_name}")).unwrap(), + ProtoFamily::Ipv4, + ); + } + FwTableType::IPv6 => { + table_name = format!("{PKG_NAME}6"); + table = Table::new( + &CString::new(format!("{table_name}")).unwrap(), + ProtoFamily::Ipv6, + ); + } + } let mut batch = Batch::new(); - let table = Table::new(&CString::new(PKG_NAME).unwrap(), ProtoFamily::Ipv4); - batch.add(&table, nftnl::MsgType::Add); batch.add(&table, nftnl::MsgType::Del); @@ -21,45 +52,82 @@ pub fn fwblock( ret: &mut Vec, fwlen: &mut usize, ) -> std::result::Result<(), Error> { - // convert chain - let ips_add = convert(ips_add); - let (mut batch, table) = fwinit(); + let ((mut batch4, table4), (mut batch6, table6)) = fwglobalinit(); - // build chain - let mut chain = Chain::new(&CString::new(PKG_NAME).unwrap(), &table); - chain.set_hook(nftnl::Hook::In, 1); - chain.set_policy(nftnl::Policy::Accept); + // build chain for ipv4 + let mut chain4 = Chain::new(&CString::new(PKG_NAME).unwrap(), &table4); + chain4.set_hook(nftnl::Hook::In, 1); + chain4.set_policy(nftnl::Policy::Accept); // add chain - batch.add(&chain, nftnl::MsgType::Add); + batch4.add(&chain4, nftnl::MsgType::Add); - let rule = Rule::new(&chain); - batch.add(&rule, nftnl::MsgType::Del); + batch4.add(&Rule::new(&chain4), nftnl::MsgType::Del); - let mut rule = Rule::new(&chain); - rule.add_expr(&nft_expr!(ct state)); - rule.add_expr(&nft_expr!(bitwise mask 4u32, xor 0u32)); - rule.add_expr(&nft_expr!(cmp != 0u32)); - rule.add_expr(&nft_expr!(counter)); - rule.add_expr(&nft_expr!(verdict accept)); - batch.add(&rule, nftnl::MsgType::Add); + let mut rule4 = Rule::new(&chain4); + rule4.add_expr(&nft_expr!(ct state)); + rule4.add_expr(&nft_expr!(bitwise mask 4u32, xor 0u32)); + rule4.add_expr(&nft_expr!(cmp != 0u32)); + rule4.add_expr(&nft_expr!(counter)); + rule4.add_expr(&nft_expr!(verdict accept)); + batch4.add(&rule4, nftnl::MsgType::Add); + + // build chain for ipv6 + let mut chain6 = Chain::new(&CString::new(PKG_NAME).unwrap(), &table6); + chain6.set_hook(nftnl::Hook::In, 1); + chain6.set_policy(nftnl::Policy::Accept); + + // add chain + batch6.add(&chain6, nftnl::MsgType::Add); + + batch6.add(&Rule::new(&chain6), nftnl::MsgType::Del); + + let mut rule6 = Rule::new(&chain6); + rule6.add_expr(&nft_expr!(ct state)); + rule6.add_expr(&nft_expr!(bitwise mask 4u32, xor 0u32)); + rule6.add_expr(&nft_expr!(cmp != 0u32)); + rule6.add_expr(&nft_expr!(counter)); + rule6.add_expr(&nft_expr!(verdict accept)); + batch6.add(&rule6, nftnl::MsgType::Add); // build and add rules - for ip in ips_add.clone() { - let mut rule = Rule::new(&chain); - rule.add_expr(&nft_expr!(payload ipv4 saddr)); - rule.add_expr(&nft_expr!(cmp == ip)); - rule.add_expr(&nft_expr!(ct state)); - rule.add_expr(&nft_expr!(bitwise mask 10u32, xor 0u32)); - rule.add_expr(&nft_expr!(cmp != 0u32)); - rule.add_expr(&nft_expr!(counter)); - rule.add_expr(&nft_expr!(verdict drop)); - batch.add(&rule, nftnl::MsgType::Add); + for ipdata in ips_add.clone() { + match ipdata.t { + 4 => { + let ip = ipdata.ip.parse::().unwrap(); + let mut rule = Rule::new(&chain4); + rule.add_expr(&nft_expr!(payload ipv4 saddr)); + rule.add_expr(&nft_expr!(cmp == ip)); + rule.add_expr(&nft_expr!(ct state)); + rule.add_expr(&nft_expr!(bitwise mask 10u32, xor 0u32)); + rule.add_expr(&nft_expr!(cmp != 0u32)); + rule.add_expr(&nft_expr!(counter)); + rule.add_expr(&nft_expr!(verdict drop)); + batch4.add(&rule, nftnl::MsgType::Add); + } + 6 => { + let ip = ipdata.ip.parse::().unwrap(); + let mut rule = Rule::new(&chain6); + rule.add_expr(&nft_expr!(payload ipv6 saddr)); + rule.add_expr(&nft_expr!(cmp == ip)); + rule.add_expr(&nft_expr!(ct state)); + rule.add_expr(&nft_expr!(bitwise mask 10u32, xor 0u32)); + rule.add_expr(&nft_expr!(cmp != 0u32)); + rule.add_expr(&nft_expr!(counter)); + rule.add_expr(&nft_expr!(verdict drop)); + batch6.add(&rule, nftnl::MsgType::Add); + } + _ => { + todo!() + } + } } // validate and send batch - let finalized_batch = batch.finalize(); - send_and_process(&finalized_batch)?; + for b in [batch4, batch6] { + let bf = b.finalize(); + send_and_process(&bf).unwrap(); + } if fwlen != &mut ips_add.len() { ret.push(format!("{length} ip in firewall", length = ips_add.len())); } @@ -94,11 +162,3 @@ fn socket_recv<'a>( Ok(None) } } - -fn convert(input: &Vec) -> Vec { - let mut output: Vec = vec![]; - for val in input { - output.push(val.ip.parse::().unwrap()); - } - output -} diff --git a/src/ip.rs b/src/ip.rs index 0a4ea2d..93a48aa 100644 --- a/src/ip.rs +++ b/src/ip.rs @@ -1,4 +1,3 @@ -use crate::config::httpclient; use crate::utils::gethostname; use chrono::offset::LocalResult; @@ -6,7 +5,6 @@ use chrono::prelude::*; use ipnet::IpNet; use lazy_static::lazy_static; use regex::Regex; -use reqwest::Error as ReqError; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::fmt::{Display, Formatter}; @@ -27,12 +25,16 @@ pub struct IpEvent { pub ipdata: IpData, } -#[derive(Clone, Debug, Serialize, Deserialize, Eq)] -pub struct IpData { - pub ip: String, - pub src: String, - pub date: String, - pub hostname: String, +#[macro_export] +macro_rules! ipevent { + ($msgtype:expr,$mode:expr,$hostname:expr,$ipdata:expr) => { + IpEvent { + msgtype: String::from($msgtype), + mode: String::from($mode), + hostname: $hostname, + ipdata: $ipdata, + } + }; } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -43,6 +45,15 @@ pub struct BlockIpData { pub starttime: DateTime, } +#[derive(Clone, Debug, Serialize, Deserialize, Eq)] +pub struct IpData { + pub t: isize, + pub ip: String, + pub src: String, + pub date: String, + pub hostname: String, +} + impl PartialEq for IpData { fn eq(&self, other: &IpData) -> bool { self.ip.as_bytes() == other.ip.as_bytes() && self.src == other.src @@ -91,15 +102,18 @@ pub fn filter( if let Ok(l) = line { if regex.is_match(l.as_str()) { let s_ipaddr: String; + let t: isize; match R_IPV4.captures(l.as_str()) { Some(sv4) => { s_ipaddr = sv4.get(0).unwrap().as_str().to_string(); + t = 4; } None => { match R_IPV6.captures(l.as_str()) { Some(sv6) => { s_ipaddr = sv6.get(0).unwrap().as_str().to_string(); + t = 6; } None => { continue; @@ -132,6 +146,7 @@ pub fn filter( if !is_trusted(&ipaddr, &trustnets) { iplist.push(IpData { ip: s_ipaddr, + t: t, src: src.to_owned(), date: s_date.to_rfc3339().to_owned(), hostname: hostname.to_owned(), @@ -145,30 +160,24 @@ pub fn filter( } fn parse_date(input: regex::Captures) -> DateTime { - let mut ymd: Vec = vec![]; - let mut hms: Vec = vec![]; + let mut ymd: Vec = vec![]; + let mut hms: Vec = vec![]; + let ymd_range = 2..5; + let hms_range = 5..8; - let (daterange, hourrange) = (2..5, 5..8); - - for i in daterange { - ymd.push(input.get(i).unwrap().as_str().parse::().unwrap()); + for cap in ymd_range { + ymd.push(input.get(cap).unwrap().as_str().parse::().unwrap()); } - for i in hourrange { - hms.push(input.get(i).unwrap().as_str().parse::().unwrap()); + for cap in hms_range { + hms.push(input.get(cap).unwrap().as_str().parse::().unwrap()); } - let date: DateTime = match Local.with_ymd_and_hms( - ymd[0] as i32, - ymd[1] as u32, - ymd[2] as u32, - hms[0] as u32, - hms[1] as u32, - hms[2] as u32, - ) { - LocalResult::Single(s) => s, - LocalResult::Ambiguous(a, _b) => a, - LocalResult::None => Local::now(), - }; + let date: DateTime = + match Local.with_ymd_and_hms(ymd[0] as i32, ymd[1], ymd[2], hms[0], hms[1], hms[2]) { + LocalResult::Single(s) => s, + LocalResult::Ambiguous(a, _b) => a, + LocalResult::None => Local::now().trunc_subsecs(0), + }; date } @@ -180,23 +189,3 @@ fn is_trusted(ip: &IpAddr, trustnets: &Vec) -> bool { } false } - -pub async fn _get_last(server: &String) -> Result, ReqError> { - let resp = httpclient() - .get(format!("{server}/ips/last")) - .query(&[("interval", "3 hours")]) - .send() - .await; - - let req = match resp { - Ok(re) => re, - Err(err) => return Err(err), - }; - - let data: Vec = match req.json::>().await { - Ok(res) => res, - Err(err) => return Err(err), - }; - - Ok(data) -} diff --git a/src/ipblc.rs b/src/ipblc.rs index b31d6d8..d2cf688 100644 --- a/src/ipblc.rs +++ b/src/ipblc.rs @@ -1,6 +1,7 @@ use crate::config::{Context, GIT_VERSION}; -use crate::fw::{fwblock, fwinit}; +use crate::fw::{fwblock, fwglobalinit}; use crate::ip::{filter, IpData, IpEvent}; +use crate::ipevent; use crate::monitoring::apiserver; use crate::utils::{gethostname, read_lines, sleep_s}; use crate::webservice::send_to_ipbl_api; @@ -9,7 +10,7 @@ use crate::websocket::{send_to_ipbl_websocket, websocketpubsub, websocketreqrep} use chrono::prelude::*; use chrono::prelude::{DateTime, Local}; use chrono::Duration; -use nix::sys::inotify::InotifyEvent; +use nix::sys::inotify::{InitFlags, Inotify, InotifyEvent}; use std::collections::HashMap; use std::sync::Arc; use tokio::sync::mpsc::{channel, Receiver, Sender}; @@ -21,15 +22,17 @@ const WS_CHAN_SIZE: usize = 64; const LOOP_MAX_WAIT: u64 = 5; pub async fn run() { - let globalctx = Context::new().await; + let inotify = Inotify::init(InitFlags::empty()).unwrap(); + let globalctx = Context::new(&inotify).await; let ctxarc = Arc::new(RwLock::new(globalctx)); + let mut fwlen: usize = 0; let pkgversion = format!("{}@{}", env!("CARGO_PKG_VERSION"), GIT_VERSION); let mut last_cfg_reload: DateTime = Local::now().trunc_subsecs(0); println!("Launching {}, version {}", PKG_NAME, pkgversion); - fwinit(); + fwglobalinit(); let ctxapi = Arc::clone(&ctxarc); apiserver(&ctxapi).await.unwrap(); @@ -47,7 +50,9 @@ pub async fn run() { let mut wssocketrr = websocketreqrep(&ctxwsrr).await; // init file watcher - let mut blrx = watchfiles(&ctxarc).await; + let inoarc = Arc::new(RwLock::new(inotify)); + let inoclone = Arc::clone(&inoarc); + let mut blrx = watchfiles(inoclone).await; let ctxclone = Arc::clone(&ctxarc); let ipeventclone = Arc::clone(&ipeventtxarc); @@ -66,19 +71,14 @@ pub async fn run() { let (toblock,server); { - let mut ctx = ctxclone.write().await; + let ctx = ctxclone.read().await; toblock = ctx.get_blocklist_toblock().await; server = ctx.flags.server.clone(); } if received_ip.msgtype == "bootstrap".to_string() { for ip_to_send in toblock { - let ipe = IpEvent{ - msgtype: String::from("init"), - mode: String::from("ws"), - hostname: gethostname(true), - ipdata: ip_to_send, - }; + let ipe = ipevent!("init","ws",gethostname(true),ip_to_send); if !send_to_ipbl_websocket(&mut wssocketrr, &ipe).await { wssocketrr = websocketreqrep(&ctxwsrr).await; break; @@ -98,12 +98,7 @@ pub async fn run() { if let Some(ipevent) = filtered_ipevent { if received_ip.msgtype != "init" { println!("sending {} to api and ws", ipevent.ipdata.ip); - let ipe = IpEvent{ - msgtype: String::from("add"), - mode: String::from("ws"), - hostname: gethostname(true), - ipdata: ipevent.ipdata, - }; + let ipe = ipevent!("add","ws",gethostname(true),ipevent.ipdata); send_to_ipbl_api(&server.clone(), &ipe).await; let status = send_to_ipbl_websocket(&mut wssocketrr, &ipe).await; if !status { @@ -125,15 +120,21 @@ pub async fn run() { } let ctxclone = Arc::clone(&ctxarc); - handle_cfg_reload(&ctxclone, &mut last_cfg_reload).await; + let inoclone = Arc::clone(&inoarc); + handle_cfg_reload(&ctxclone, &mut last_cfg_reload, inoclone).await; } } -async fn handle_cfg_reload(ctxclone: &Arc>, last_cfg_reload: &mut DateTime) { +async fn handle_cfg_reload( + ctxclone: &Arc>, + last_cfg_reload: &mut DateTime, + inoarc: Arc>, +) { let now_cfg_reload = Local::now().trunc_subsecs(0); if (now_cfg_reload - *last_cfg_reload) > Duration::seconds(LOOP_MAX_WAIT as i64) { let mut ctx = ctxclone.write().await; - match ctx.load().await { + let inotify = inoarc.read().await; + match ctx.load(&inotify).await { Ok(_) => { *last_cfg_reload = Local::now().trunc_subsecs(0); } @@ -145,9 +146,12 @@ async fn handle_cfg_reload(ctxclone: &Arc>, last_cfg_reload: &mu } async fn handle_fwblock(ctxclone: Arc>, ret: &mut Vec, fwlen: &mut usize) { - let toblock = { + { let mut ctx = ctxclone.write().await; ctx.gc_blocklist().await; + } + let toblock = { + let ctx = ctxclone.read().await; ctx.get_blocklist_toblock().await }; @@ -160,19 +164,11 @@ async fn handle_fwblock(ctxclone: Arc>, ret: &mut Vec, f }; } -async fn watchfiles(ctxarc: &Arc>) -> Receiver { +async fn watchfiles(inoarc: Arc>) -> Receiver { let (bltx, blrx): (Sender, Receiver) = channel(BL_CHAN_SIZE); - let ctxclone = Arc::clone(ctxarc); tokio::spawn(async move { loop { - let events; - let instance; - { - let ctx = ctxclone.read().await; - instance = ctx.instance.clone(); - } - - events = instance.read_events().unwrap(); + let events = inoarc.read().await.read_events().unwrap(); for inevent in events { let date: DateTime = Local::now().trunc_subsecs(0); @@ -209,7 +205,7 @@ async fn compare_files_changes( let sas; { let ctx = ctxarc.read().await; - sas = ctx.clone().sas; + sas = ctx.sas.clone(); sask = sas.keys(); tnets = ctx.cfg.build_trustnets(); } @@ -258,14 +254,9 @@ async fn compare_files_changes( } } for ip in iplist { - let ipevent = IpEvent { - msgtype: String::from("add"), - hostname: gethostname(true), - mode: String::from("file"), - ipdata: ip, - }; - let ipetx = ipeventtx.write().await; - ipetx.send(ipevent).await.unwrap(); + let ipe = ipevent!("add", "file", gethostname(true), ip); + let ipetx = ipeventtx.read().await; + ipetx.send(ipe).await.unwrap(); } } None => {} diff --git a/src/monitoring.rs b/src/monitoring.rs index 90b5b10..456691a 100644 --- a/src/monitoring.rs +++ b/src/monitoring.rs @@ -22,7 +22,6 @@ pub async fn apiserver(ctxarc: &Arc>) -> io::Result<()> { tokio::spawn(async move { loop { - //apitx.send(String::from("")).await.unwrap(); match listener.accept().await { Ok((stream, _addr)) => { //let mut buf = [0; 1024]; diff --git a/src/regexps/ipv6.txt b/src/regexps/ipv6.txt index d69593c..a5c5291 100644 --- a/src/regexps/ipv6.txt +++ b/src/regexps/ipv6.txt @@ -1 +1 @@ -((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$)) \ No newline at end of file +(((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*)|(((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?) \ No newline at end of file diff --git a/src/webservice.rs b/src/webservice.rs index 48891f8..a4d74f6 100644 --- a/src/webservice.rs +++ b/src/webservice.rs @@ -31,6 +31,7 @@ async fn push_ip(client: &Client, server: &str, ip: &IpData) -> Result<(), ReqEr let mut data: Vec = vec![]; data.push(IpData { + t: ip.t, ip: ip.ip.to_string(), src: ip.src.to_string(), date: ip.date.to_string(), @@ -56,6 +57,7 @@ async fn _push_ip_bulk( for ip in ips { data.push(IpData { + t: ip.t, ip: ip.ip.to_string(), src: ip.src.to_string(), date: ip.date.to_string(), diff --git a/src/websocket.rs b/src/websocket.rs index 596b3f3..95ed015 100644 --- a/src/websocket.rs +++ b/src/websocket.rs @@ -41,7 +41,7 @@ pub async fn websocketpubsub( tokio::spawn(async move { loop { let mut ws = websocket.write().await; - match ws.read_message() { + match ws.read() { Ok(msg) => { let tosend: IpEvent = match serde_json::from_str(msg.to_string().as_str()) { Ok(o) => o, @@ -52,7 +52,7 @@ pub async fn websocketpubsub( if tosend.ipdata.hostname != gethostname(true) || tosend.msgtype == "init".to_string() { - let txps = txpubsub.write().await; + let txps = txpubsub.read().await; txps.send(tosend).await.unwrap(); } } @@ -90,9 +90,7 @@ pub async fn websocketconnect<'a>( } println!("connected to {endpoint}"); let msg = json!({ "hostname": hostname }); - socket - .write_message(Message::Text(msg.to_string())) - .unwrap(); + socket.send(Message::Text(msg.to_string())).unwrap(); Ok(socket) } @@ -103,7 +101,7 @@ pub async fn send_to_ipbl_websocket( let msg = format!("{val}", val = serde_json::to_string(&ip).unwrap()); if ws.can_write() { - match ws.write_message(Message::Text(msg)) { + match ws.send(Message::Text(msg)) { Ok(_) => {} Err(e) => { println!("err send read: {e:?}"); @@ -115,7 +113,7 @@ pub async fn send_to_ipbl_websocket( }; if ws.can_read() { - match ws.read_message() { + match ws.read() { Ok(_) => {} Err(e) => { println!("err send read: {e:?}");