From 621bc5d88cda9de631e9552530fe204d1ecf1c88 Mon Sep 17 00:00:00 2001 From: "Isaac M. Good" Date: Fri, 3 Jan 2025 01:40:18 -0800 Subject: [PATCH 1/8] Various naming and doc improvements plus dependency upgrades --- Cargo.lock | 296 +++++++++++++---------------------- Cargo.toml | 4 +- src/log_config.rs | 2 +- src/main.rs | 12 +- src/primary_tasks/mod.rs | 4 +- src/primary_tasks/rx_task.rs | 18 +-- src/primary_tasks/tx_task.rs | 4 +- src/session.rs | 20 +-- 8 files changed, 140 insertions(+), 220 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ddbe029..7fa2866 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,21 +1,21 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" @@ -28,9 +28,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,64 +43,58 @@ 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", + "windows-sys 0.59.0", ] [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[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" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cfg-if" @@ -110,9 +104,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[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 +114,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 +126,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 +138,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 +160,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", @@ -179,9 +173,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "heck" @@ -189,12 +183,6 @@ 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 +191,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.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "listenfd" @@ -226,9 +214,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" @@ -238,72 +226,62 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ - "adler", + "adler2", ] [[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", + "windows-sys 0.52.0", ] [[package]] name = "object" -version = "0.36.0" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[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 +291,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,9 +302,9 @@ 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" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustc-demangle" @@ -336,9 +314,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -352,9 +330,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", @@ -374,26 +352,25 @@ dependencies = [ [[package]] name = "tokio" -version = "1.38.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -402,9 +379,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 +391,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 +423,84 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[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.5", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 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-targets", ] [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "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_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[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" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[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" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[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 = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[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 = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[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 = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml index 679bad3..173293d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "systemd-udp-proxy" -version = "0.1.1" +version = "0.1.2" edition = "2021" [dependencies] @@ -8,4 +8,4 @@ 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.42", features = ["io-util", "macros", "net", "rt-multi-thread", "sync", "time"] } diff --git a/src/log_config.rs b/src/log_config.rs index 7a9e871..40e2390 100644 --- a/src/log_config.rs +++ b/src/log_config.rs @@ -4,7 +4,7 @@ use env_logger::{Builder, Env, DEFAULT_FILTER_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| { diff --git a/src/main.rs b/src/main.rs index 326f869..ba5e1b3 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,8 +40,8 @@ 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))?; @@ -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..352093e 100644 --- a/src/primary_tasks/rx_task.rs +++ b/src/primary_tasks/rx_task.rs @@ -16,7 +16,7 @@ use tokio::{ use crate::{ error_util::{handle_io_error, ErrorAction}, session::{Session, SessionReply, SessionSource}, - Args, MAX_UDP_PACKET_SIZE, + ProxyConfig, 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 +/// 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 [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, +/// be created if any traffic resumes from it. +pub async fn rx_task( + config: ProxyConfig, reply_channel_tx: UnboundedSender, rx_socket: Arc, ) -> io::Result<()> { @@ -48,7 +48,7 @@ pub async fn rx_loop( 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); diff --git a/src/primary_tasks/tx_task.rs b/src/primary_tasks/tx_task.rs index 5b35564..bbefad0 100644 --- a/src/primary_tasks/tx_task.rs +++ b/src/primary_tasks/tx_task.rs @@ -7,12 +7,12 @@ use crate::{ 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 /// source via `tx_socket`. -pub async fn tx_loop( +pub async fn tx_task( mut reply_channel_rx: UnboundedReceiver, tx_socket: Arc, ) -> io::Result<()> { diff --git a/src/session.rs b/src/session.rs index cbfcfdb..c2f35a0 100644 --- a/src/session.rs +++ b/src/session.rs @@ -15,7 +15,7 @@ use tokio::{ use crate::{ error_util::{handle_io_error, ErrorAction}, - Args, MAX_UDP_PACKET_SIZE, + ProxyConfig, MAX_UDP_PACKET_SIZE, }; #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] @@ -32,7 +32,7 @@ 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)] @@ -51,17 +51,17 @@ 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 { + 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, }) } @@ -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 @@ -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,7 +110,7 @@ impl Session { } } } - Err(_) => { + Err(_timeout_exceeded) => { info!("Closing rx session for {}", self.source); return Ok(()); } From 975aaa2c0c92cc960ef34fdf3125ec56d9d5f0e2 Mon Sep 17 00:00:00 2001 From: "Isaac M. Good" Date: Fri, 3 Jan 2025 01:42:52 -0800 Subject: [PATCH 2/8] Update verify.yml task name --- .github/workflows/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 4b3984f..6516fef 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -7,7 +7,7 @@ on: - "**.md" jobs: - release: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From d0d9f6e6628eb3eb65b254917d394c2f569f942c Mon Sep 17 00:00:00 2001 From: "Isaac M. Good" Date: Sat, 22 Feb 2025 01:39:01 -0800 Subject: [PATCH 3/8] Drop redundant Rust toolchain install --- .github/workflows/build-release.yml | 3 --- .github/workflows/verify.yml | 3 --- 2 files changed, 6 deletions(-) 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 6516fef..1281b71 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.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 From cf31df96c732796a9c60f0f651b33574dc24ae50 Mon Sep 17 00:00:00 2001 From: "Isaac M. Good" Date: Wed, 9 Apr 2025 07:53:48 -0700 Subject: [PATCH 4/8] Add pull_requests to verify.yml --- .github/workflows/verify.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 1281b71..f29c9c2 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -5,6 +5,8 @@ on: branches: [mainline] paths-ignore: - "**.md" + pull_request: + branches: [mainline] jobs: build: From c6c8bdc94ec19b85ccf863c323853a7b706e091a Mon Sep 17 00:00:00 2001 From: "Isaac M. Good" Date: Wed, 9 Apr 2025 07:54:55 -0700 Subject: [PATCH 5/8] Ignore markdown in pull requests for verify.yml --- .github/workflows/verify.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index f29c9c2..5e619ba 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -7,6 +7,8 @@ on: - "**.md" pull_request: branches: [mainline] + paths-ignore: + - "**.md" jobs: build: From 33f69cb2c403429b78ad059a9a33828f02f46c58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 07:58:19 -0700 Subject: [PATCH 6/8] Bump tokio from 1.42.0 to 1.43.1 in the cargo group across 1 directory (#3) Bumps the cargo group with 1 update in the / directory: [tokio](https://github.com/tokio-rs/tokio). Updates `tokio` from 1.42.0 to 1.43.1
Release notes

Sourced from tokio's releases.

Tokio v1.43.0

1.43.0 (Jan 8th, 2025)

Added

  • net: add UdpSocket::peek methods (#7068)
  • net: add support for Haiku OS (#7042)
  • process: add Command::into_std() (#7014)
  • signal: add SignalKind::info on illumos (#6995)
  • signal: add support for realtime signals on illumos (#7029)

Fixed

  • io: don't call set_len before initializing vector in Blocking (#7054)
  • macros: suppress clippy::needless_return in #[tokio::main] (#6874)
  • runtime: fix thread parking on WebAssembly (#7041)

Changes

  • chore: use unsync loads for unsync_load (#7073)
  • io: use Buf::put_bytes in Repeat read impl (#7055)
  • task: drop the join waker of a task eagerly (#6986)

Changes to unstable APIs

  • metrics: improve flexibility of H2Histogram Configuration (#6963)
  • taskdump: add accessor methods for backtrace (#6975)

Documented

  • io: clarify ReadBuf::uninit allows initialized buffers as well (#7053)
  • net: fix ambiguity in TcpStream::try_write_vectored docs (#7067)
  • runtime: fix LocalRuntime doc links (#7074)
  • sync: extend documentation for watch::Receiver::wait_for (#7038)
  • sync: fix typos in OnceCell docs (#7047)

#6874: tokio-rs/tokio#6874 #6963: tokio-rs/tokio#6963 #6975: tokio-rs/tokio#6975 #6986: tokio-rs/tokio#6986 #6995: tokio-rs/tokio#6995 #7014: tokio-rs/tokio#7014 #7029: tokio-rs/tokio#7029 #7038: tokio-rs/tokio#7038 #7041: tokio-rs/tokio#7041 #7042: tokio-rs/tokio#7042 #7047: tokio-rs/tokio#7047 #7053: tokio-rs/tokio#7053 #7054: tokio-rs/tokio#7054 #7055: tokio-rs/tokio#7055

... (truncated)

Commits
  • a7b658c chore: prepare Tokio v1.43.1 release
  • c1c8d10 Merge remote-tracking branch 'origin/tokio-1.38.x' into forward-port-1.38.x
  • aa303bc chore: prepare Tokio v1.38.2 release
  • 7b6ccb5 chore: backport CI fixes
  • 4b174ce sync: fix cloning value when receiving from broadcast channel
  • 5f3296d chore: prepare Tokio v1.43.0 (#7079)
  • cc974a6 chore: prepare tokio-macros v2.5.0 (#7078)
  • 15495fd metrics: improve flexibility of H2Histogram Configuration (#6963)
  • ad41834 io: don't call set_len before initializing vector in Blocking (#7054)
  • bd3e857 runtime: move is_join_waker_set assertion in unset_waker (#7072)
  • Additional commits viewable in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tokio&package-manager=cargo&previous-version=1.42.0&new-version=1.43.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/SharkBaitDLS/systemd-udp-proxy/network/alerts).
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7fa2866..2423bbc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -341,7 +341,7 @@ dependencies = [ [[package]] name = "systemd-udp-proxy" -version = "0.1.1" +version = "0.1.2" dependencies = [ "clap", "env_logger", @@ -352,9 +352,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "492a604e2fd7f814268a378409e6c92b5525d747d10db9a229723f55a417958c" dependencies = [ "backtrace", "bytes", @@ -368,9 +368,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 173293d..0986828 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,4 @@ clap = { version = "4.5", features = ["derive"] } env_logger = "0.11" listenfd = "1.0" log = "0.4" -tokio = { version = "1.42", features = ["io-util", "macros", "net", "rt-multi-thread", "sync", "time"] } +tokio = { version = "1.43", features = ["io-util", "macros", "net", "rt-multi-thread", "sync", "time"] } From e79d2dcd63f3251f6418bdc5e6f18773bd57cac5 Mon Sep 17 00:00:00 2001 From: "Isaac M. Good" Date: Fri, 16 May 2025 23:29:32 -0700 Subject: [PATCH 7/8] Clippy lint fixups --- src/log_config.rs | 5 ++--- src/primary_tasks/rx_task.rs | 8 ++++---- src/primary_tasks/tx_task.rs | 6 +++--- src/session.rs | 20 ++++++++++---------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/log_config.rs b/src/log_config.rs index 40e2390..08efc69 100644 --- a/src/log_config.rs +++ b/src/log_config.rs @@ -15,12 +15,11 @@ pub fn init_systemd() { 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/primary_tasks/rx_task.rs b/src/primary_tasks/rx_task.rs index 352093e..56c3d66 100644 --- a/src/primary_tasks/rx_task.rs +++ b/src/primary_tasks/rx_task.rs @@ -24,9 +24,9 @@ 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 `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 [Args::session_timeout] seconds, it will close its tasks and a new one will +/// 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, @@ -41,7 +41,7 @@ pub async fn rx_task( 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; diff --git a/src/primary_tasks/tx_task.rs b/src/primary_tasks/tx_task.rs index bbefad0..47b6858 100644 --- a/src/primary_tasks/tx_task.rs +++ b/src/primary_tasks/tx_task.rs @@ -10,7 +10,7 @@ use crate::{ /// 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_task( mut reply_channel_rx: UnboundedReceiver, @@ -21,10 +21,10 @@ pub async fn tx_task( .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 c2f35a0..683075c 100644 --- a/src/session.rs +++ b/src/session.rs @@ -24,8 +24,8 @@ 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 { @@ -48,9 +48,9 @@ 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. + /// 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_socket = Arc::new(UdpSocket::bind((config.source_address, 0)).await?); @@ -65,7 +65,7 @@ impl Session { }) } - /// 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( @@ -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>, @@ -114,7 +114,7 @@ impl Session { info!("Closing rx session for {}", self.source); return Ok(()); } - }; + } if reply_channel .send(SessionReply::new(self.source, buf)) @@ -124,7 +124,7 @@ impl Session { ErrorKind::ConnectionAborted, "Primary tx task has stopped listening, dropping reply as the proxy will soon terminate" )); - }; + } } } } From 30d09e0a41f23e24de384252e840f9d0784ed581 Mon Sep 17 00:00:00 2001 From: "Isaac M. Good" Date: Sun, 14 Dec 2025 03:37:12 -0800 Subject: [PATCH 8/8] Upgrade to Rust 2024 --- Cargo.lock | 198 +++++++++++++++++++---------------- Cargo.toml | 6 +- src/log_config.rs | 2 +- src/main.rs | 2 +- src/primary_tasks/rx_task.rs | 10 +- src/primary_tasks/tx_task.rs | 2 +- src/session.rs | 6 +- 7 files changed, 124 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2423bbc..c6cbb40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,21 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "addr2line" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" - [[package]] name = "aho-corasick" version = "1.1.3" @@ -75,33 +60,12 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "backtrace" -version = "0.3.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets", -] - [[package]] name = "bytes" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - [[package]] name = "clap" version = "4.5.23" @@ -171,12 +135,6 @@ dependencies = [ "log", ] -[[package]] -name = "gimli" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" - [[package]] name = "heck" version = "0.5.0" @@ -197,9 +155,9 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" [[package]] name = "listenfd" @@ -224,15 +182,6 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "miniz_oxide" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" -dependencies = [ - "adler2", -] - [[package]] name = "mio" version = "1.0.3" @@ -244,15 +193,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "object" -version = "0.36.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" -dependencies = [ - "memchr", -] - [[package]] name = "pin-project-lite" version = "0.2.15" @@ -306,20 +246,14 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - [[package]] name = "socket2" -version = "0.5.8" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -341,7 +275,7 @@ dependencies = [ [[package]] name = "systemd-udp-proxy" -version = "0.1.2" +version = "0.1.3" dependencies = [ "clap", "env_logger", @@ -352,25 +286,24 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.1" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "492a604e2fd7f814268a378409e6c92b5525d747d10db9a229723f55a417958c" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ - "backtrace", "bytes", "libc", "mio", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "tokio-macros" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", @@ -423,13 +356,19 @@ 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", + "windows-targets 0.52.6", ] [[package]] @@ -438,7 +377,25 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "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]] @@ -447,14 +404,31 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "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.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "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]] @@ -463,44 +437,92 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +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 = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" diff --git a/Cargo.toml b/Cargo.toml index 0986828..c3d9fbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "systemd-udp-proxy" -version = "0.1.2" -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.43", 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 08efc69..c1724f2 100644 --- a/src/log_config.rs +++ b/src/log_config.rs @@ -1,6 +1,6 @@ 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 diff --git a/src/main.rs b/src/main.rs index ba5e1b3..6f325df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,7 @@ async fn main() -> io::Result<()> { 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(); diff --git a/src/primary_tasks/rx_task.rs b/src/primary_tasks/rx_task.rs index 56c3d66..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}, - ProxyConfig, MAX_UDP_PACKET_SIZE, }; type SessionChannel = UnboundedSender>; @@ -97,6 +97,6 @@ pub async fn rx_task( sessions.write().await.remove(&source.into()); } } - }; + } } } diff --git a/src/primary_tasks/tx_task.rs b/src/primary_tasks/tx_task.rs index 47b6858..b60f9c0 100644 --- a/src/primary_tasks/tx_task.rs +++ b/src/primary_tasks/tx_task.rs @@ -3,7 +3,7 @@ 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, }; diff --git a/src/session.rs b/src/session.rs index 683075c..0e4105d 100644 --- a/src/session.rs +++ b/src/session.rs @@ -14,8 +14,8 @@ use tokio::{ }; use crate::{ - error_util::{handle_io_error, ErrorAction}, - ProxyConfig, MAX_UDP_PACKET_SIZE, + MAX_UDP_PACKET_SIZE, ProxyConfig, + error_util::{ErrorAction, handle_io_error}, }; #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] @@ -122,7 +122,7 @@ 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", )); } }