diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 9d5225c..a3d34cb 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -11,9 +11,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy, rustfmt - name: Cache Cargo registry uses: actions/cache@v3 continue-on-error: false diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 4b3984f..5e619ba 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -5,15 +5,16 @@ on: branches: [mainline] paths-ignore: - "**.md" + pull_request: + branches: [mainline] + paths-ignore: + - "**.md" jobs: - release: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy, rustfmt - name: Cache Cargo registry uses: actions/cache@v3 continue-on-error: false diff --git a/Cargo.lock b/Cargo.lock index ddbe029..c6cbb40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,21 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +version = 4 [[package]] name = "aho-corasick" @@ -28,9 +13,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -43,76 +28,49 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", -] - -[[package]] -name = "backtrace" -version = "0.3.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", + "windows-sys 0.59.0", ] [[package]] name = "bytes" -version = "1.6.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" - -[[package]] -name = "cc" -version = "1.0.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "clap" -version = "4.5.7" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", @@ -120,9 +78,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.7" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -132,9 +90,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.5" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -144,21 +102,21 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "env_filter" -version = "0.1.0" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", "regex", @@ -166,9 +124,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" dependencies = [ "anstream", "anstyle", @@ -177,24 +135,12 @@ dependencies = [ "log", ] -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" - [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "humantime" version = "2.1.0" @@ -203,15 +149,15 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" [[package]] name = "listenfd" @@ -226,9 +172,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" @@ -236,74 +182,46 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] - [[package]] name = "mio" -version = "0.8.11" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "wasi", - "windows-sys 0.48.0", -] - -[[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.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" -dependencies = [ - "memchr", + "windows-sys 0.52.0", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] [[package]] name = "regex" -version = "1.10.5" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -313,9 +231,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -324,24 +242,18 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "socket2" -version = "0.5.7" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -352,9 +264,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.67" +version = "2.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" +checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" dependencies = [ "proc-macro2", "quote", @@ -363,7 +275,7 @@ dependencies = [ [[package]] name = "systemd-udp-proxy" -version = "0.1.1" +version = "0.1.3" dependencies = [ "clap", "env_logger", @@ -374,26 +286,24 @@ dependencies = [ [[package]] name = "tokio" -version = "1.38.0" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ - "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.61.2", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", @@ -402,9 +312,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "utf8parse" @@ -414,9 +324,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.8.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "wasi" @@ -446,141 +356,173 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", ] [[package]] name = "windows-targets" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" diff --git a/Cargo.toml b/Cargo.toml index 679bad3..c3d9fbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "systemd-udp-proxy" -version = "0.1.1" -edition = "2021" +version = "0.1.3" +edition = "2024" [dependencies] clap = { version = "4.5", features = ["derive"] } env_logger = "0.11" listenfd = "1.0" log = "0.4" -tokio = { version = "1.38", features = ["io-util", "macros", "net", "rt-multi-thread", "sync", "time"] } +tokio = { version = "1.48", features = ["io-util", "macros", "net", "rt-multi-thread", "sync", "time"] } diff --git a/src/log_config.rs b/src/log_config.rs index 7a9e871..c1724f2 100644 --- a/src/log_config.rs +++ b/src/log_config.rs @@ -1,10 +1,10 @@ use std::io::Write; -use env_logger::{Builder, Env, DEFAULT_FILTER_ENV}; +use env_logger::{Builder, DEFAULT_FILTER_ENV, Env}; use log::LevelFilter; /// Initialize logger in the systemd format, default to WARN log level if not specified -pub fn init() { +pub fn init_systemd() { let env = Env::default().filter_or(DEFAULT_FILTER_ENV, LevelFilter::Warn.as_str()); Builder::from_env(env) .format(|buf, record| { @@ -15,12 +15,11 @@ pub fn init() { log::Level::Error => 3, log::Level::Warn => 4, log::Level::Info => 6, - log::Level::Debug => 7, - log::Level::Trace => 7, + log::Level::Debug | log::Level::Trace => 7, }, record.target(), record.args() ) }) - .init() + .init(); } diff --git a/src/main.rs b/src/main.rs index 326f869..6f325df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use clap::Parser; use listenfd::ListenFd; #[cfg(not(debug_assertions))] use log::warn; -use primary_tasks::{rx_loop, tx_loop}; +use primary_tasks::{rx_task, tx_task}; use session::SessionReply; use tokio::{net::UdpSocket, sync::mpsc}; @@ -21,7 +21,7 @@ mod primary_tasks; mod session; #[derive(Parser, Debug)] -struct Args { +struct ProxyConfig { /// The destination port to proxy traffic to #[arg(short = 'p', long)] destination_port: u16, @@ -40,11 +40,11 @@ const MAX_UDP_PACKET_SIZE: u16 = u16::MAX; #[tokio::main] async fn main() -> io::Result<()> { - log_config::init(); - let args = Args::parse(); + log_config::init_systemd(); + let config = ProxyConfig::parse(); #[cfg(debug_assertions)] - let std_source_socket = std::net::UdpSocket::bind((Ipv4Addr::new(127, 0, 0, 1), 8123))?; + let std_source_socket = std::net::UdpSocket::bind((Ipv4Addr::LOCALHOST, 8123))?; #[cfg(not(debug_assertions))] let std_source_socket = { let mut listen_fd = ListenFd::from_env(); @@ -69,8 +69,8 @@ async fn main() -> io::Result<()> { let source_socket = Arc::new(UdpSocket::from_std(std_source_socket)?); let (reply_channel_tx, reply_channel_rx) = mpsc::unbounded_channel::(); - let rx_task = tokio::spawn(rx_loop(args, reply_channel_tx, source_socket.clone())); - let tx_task = tokio::spawn(tx_loop(reply_channel_rx, source_socket.clone())); + let rx_task = tokio::spawn(rx_task(config, reply_channel_tx, source_socket.clone())); + let tx_task = tokio::spawn(tx_task(reply_channel_rx, source_socket.clone())); rx_task.await??; tx_task.await??; diff --git a/src/primary_tasks/mod.rs b/src/primary_tasks/mod.rs index 0ad8e6e..8714810 100644 --- a/src/primary_tasks/mod.rs +++ b/src/primary_tasks/mod.rs @@ -1,5 +1,5 @@ mod rx_task; mod tx_task; -pub use rx_task::rx_loop; -pub use tx_task::tx_loop; +pub use rx_task::rx_task; +pub use tx_task::tx_task; diff --git a/src/primary_tasks/rx_task.rs b/src/primary_tasks/rx_task.rs index 64e59fc..2371485 100644 --- a/src/primary_tasks/rx_task.rs +++ b/src/primary_tasks/rx_task.rs @@ -1,5 +1,5 @@ use std::{ - collections::{hash_map::Entry, HashMap}, + collections::{HashMap, hash_map::Entry}, io, sync::Arc, }; @@ -8,15 +8,15 @@ use log::{error, info}; use tokio::{ net::UdpSocket, sync::{ - mpsc::{self, UnboundedSender}, RwLock, + mpsc::{self, UnboundedSender}, }, }; use crate::{ - error_util::{handle_io_error, ErrorAction}, + MAX_UDP_PACKET_SIZE, ProxyConfig, + error_util::{ErrorAction, handle_io_error}, session::{Session, SessionReply, SessionSource}, - Args, MAX_UDP_PACKET_SIZE, }; type SessionChannel = UnboundedSender>; @@ -24,12 +24,12 @@ type SessionCache = HashMap)>; /// Loops infinitely over the `rx_socket` to recieve traffic from the original source of the proxy. /// -/// For each unique [std::net::SocketAddr] that sends traffic to this socket, a [Session] is created and -/// tx/rx loop tasks are spawned to proxy traffic for that session to and from the destination. If a [Session] -/// does not recieve traffic for [Args::session_timeout] seconds, it will close its tasks and a new one will -/// need to be created if any traffic resumes from it. -pub async fn rx_loop( - args: Args, +/// For each unique [`std::net::SocketAddr`] that sends traffic to `rx_socket`, a [`Session`] is created and +/// tx/rx loop tasks are spawned to proxy traffic for that session to and from the destination. If a [`Session`] +/// does not recieve traffic for [`ProxyConfig::session_timeout`] seconds, it will close its tasks and a new one will +/// be created if any traffic resumes from it. +pub async fn rx_task( + config: ProxyConfig, reply_channel_tx: UnboundedSender, rx_socket: Arc, ) -> io::Result<()> { @@ -41,14 +41,14 @@ pub async fn rx_loop( match rx_socket.recv_buf_from(&mut buf).await { Err(err) => match handle_io_error(err) { ErrorAction::Terminate(err) => return Err(err), - ErrorAction::Continue => continue, + ErrorAction::Continue => {} }, Ok((_len, source)) => { let mut session_cache = sessions.write().await; let session_channel_tx = match session_cache.entry(source.into()) { Entry::Vacant(entry) => { info!("Creating a new session for {source}"); - let session = match Session::new(&args, source.into()).await { + let session = match Session::new(&config, source.into()).await { Ok(created_session) => Arc::new(created_session), Err(err) => { error!("Failed to create a session for {}: {:?}", source, err); @@ -61,7 +61,7 @@ pub async fn rx_loop( let tx_session = session.clone(); let tx_session_cache = sessions.clone(); tokio::spawn(async move { - if let Err(err) = tx_session.tx_loop(rx, args.session_timeout).await { + if let Err(err) = tx_session.tx_loop(rx, config.session_timeout).await { error!("TX error for {}: {:?}", source, err); } tx_session_cache.write().await.remove(&source.into()); @@ -69,10 +69,10 @@ pub async fn rx_loop( let rx_session = session.clone(); let rx_session_cache = sessions.clone(); - let my_reply_channel = shared_reply_channel.clone(); + let rx_reply_channel = shared_reply_channel.clone(); tokio::spawn(async move { if let Err(err) = rx_session - .rx_loop(my_reply_channel, args.session_timeout) + .rx_loop(rx_reply_channel, config.session_timeout) .await { error!("RX error for {}: {:?}", source, err); @@ -97,6 +97,6 @@ pub async fn rx_loop( sessions.write().await.remove(&source.into()); } } - }; + } } } diff --git a/src/primary_tasks/tx_task.rs b/src/primary_tasks/tx_task.rs index 5b35564..b60f9c0 100644 --- a/src/primary_tasks/tx_task.rs +++ b/src/primary_tasks/tx_task.rs @@ -3,16 +3,16 @@ use std::{io, sync::Arc}; use tokio::{net::UdpSocket, sync::mpsc::UnboundedReceiver}; use crate::{ - error_util::{handle_io_error, ErrorAction}, + error_util::{ErrorAction, handle_io_error}, session::SessionReply, }; -/// Loops infinitely over the `tx_socket` to forward traffic from the destination of the proxy. +/// Loops infinitely over the `reply_channel_rx` to forward traffic from the destination of the proxy. /// /// This task recives channel messages representing responses from the proxy destination over -/// `reply_channel_tx` from [crate::session::Session]s and sends them back to the original +/// `reply_channel_tx` from [`crate::session::Session`]s and sends them back to the original /// source via `tx_socket`. -pub async fn tx_loop( +pub async fn tx_task( mut reply_channel_rx: UnboundedReceiver, tx_socket: Arc, ) -> io::Result<()> { @@ -21,10 +21,10 @@ pub async fn tx_loop( .send_to(&reply.data, (reply.source.address, reply.source.port)) .await { - Ok(_) => continue, + Ok(_) => {} Err(err) => match handle_io_error(err) { ErrorAction::Terminate(err) => return Err::<(), io::Error>(err), - ErrorAction::Continue => continue, + ErrorAction::Continue => {} }, } } diff --git a/src/session.rs b/src/session.rs index cbfcfdb..0e4105d 100644 --- a/src/session.rs +++ b/src/session.rs @@ -14,8 +14,8 @@ use tokio::{ }; use crate::{ - error_util::{handle_io_error, ErrorAction}, - Args, MAX_UDP_PACKET_SIZE, + MAX_UDP_PACKET_SIZE, ProxyConfig, + error_util::{ErrorAction, handle_io_error}, }; #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] @@ -24,15 +24,15 @@ pub struct SessionSource { pub port: u16, } -/// Wrapper around a [UdpSocket] that handles the boiler plate of establishing a connection to the appropriate -/// backend destination. It retains the original [SessionSource] of the traffic it will be proxying +/// Wrapper around a [`UdpSocket`] that handles the boiler plate of establishing a connection to the appropriate +/// backend destination. It retains the original [`SessionSource`] of the traffic it will be proxying /// so that replies from the backend can be properly routed back. #[derive(Debug)] pub struct Session { /// The source that this session is receiving traffic from source: SessionSource, /// The socket that this session is using to communicate with the destination - destination: Arc, + destination_socket: Arc, } #[derive(Debug)] @@ -48,24 +48,24 @@ impl SessionReply { } impl Session { - /// Establish a new session that binds to an [Args::source_address] and establishes - /// a connection to [Args::destination_address] on [Args::destination_port]. Returns an [io::Error] - /// if the connection fails to establish. - pub async fn new(args: &Args, source: SessionSource) -> io::Result { + /// Establish a new session that binds to an [`ProxyConfig::source_address`] and establishes + /// a connection to [`ProxyConfig::destination_address`] on [`ProxyConfig::destination_port`]. + /// Returns an [`io::Error`] if the connection fails to establish. + pub async fn new(config: &ProxyConfig, source: SessionSource) -> io::Result { // Let the OS assign us an available port - let destination = Arc::new(UdpSocket::bind((args.source_address, 0)).await?); + let destination_socket = Arc::new(UdpSocket::bind((config.source_address, 0)).await?); // Connect to the destination - destination - .connect((args.destination_address, args.destination_port)) + destination_socket + .connect((config.destination_address, config.destination_port)) .await?; Ok(Session { source, - destination, + destination_socket, }) } - /// Loops indefinitely waiting for messages on `source_channel` and send them to the [Self::destination]. + /// Loops indefinitely waiting for messages on `source_channel` and send them to the [`Self::destination_socket`]. /// Ends the loop if no message is recieved for `session_timeout` seconds or any unrecoverable /// error occurs in transmission. pub async fn tx_loop( @@ -75,7 +75,7 @@ impl Session { ) -> io::Result<()> { let duration = Duration::from_secs(session_timeout); while let Ok(Some(data)) = timeout(duration, source_channel.recv()).await { - match self.destination.send(&data).await { + match self.destination_socket.send(&data).await { Ok(_) => {} Err(err) => match err.kind() { // Destination service hasn't started yet @@ -91,8 +91,8 @@ impl Session { Ok(()) } - /// Loops indefinitely waiting for replies from the [Self::destination] and forwards them to the `reply_channel`. - /// Ends the loop if no reply is recieved for `session_timeout` seconds. + /// Loops indefinitely waiting for replies from the [`Self::destination_socket`] and forwards them to + /// the `reply_channel`. Ends the loop if no reply is recieved for `session_timeout` seconds. pub async fn rx_loop( &self, reply_channel: Arc>, @@ -101,7 +101,7 @@ impl Session { let duration = Duration::from_secs(session_timeout); loop { let mut buf = Vec::with_capacity(MAX_UDP_PACKET_SIZE.into()); - match timeout(duration, self.destination.recv_buf(&mut buf)).await { + match timeout(duration, self.destination_socket.recv_buf(&mut buf)).await { Ok(result) => { if let Err(err) = result { match handle_io_error(err) { @@ -110,11 +110,11 @@ impl Session { } } } - Err(_) => { + Err(_timeout_exceeded) => { info!("Closing rx session for {}", self.source); return Ok(()); } - }; + } if reply_channel .send(SessionReply::new(self.source, buf)) @@ -122,9 +122,9 @@ impl Session { { return Err(io::Error::new( ErrorKind::ConnectionAborted, - "Primary tx task has stopped listening, dropping reply as the proxy will soon terminate" + "Primary tx task has stopped listening, dropping reply as the proxy will soon terminate", )); - }; + } } } }