diff --git a/CHANGELOG.md b/CHANGELOG.md index 571bc4ffc43..e6469dbfae5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ## [Unreleased] +### Changed + +- mirrord-layer: Added `SocketId` to `UserSocket` as a better way of identifying sockets, + part of [#1054](https://github.com/metalbear-co/mirrord/issues/1054). + ## 3.31.0 ### Added diff --git a/Cargo.lock b/Cargo.lock index 39b90ac37d3..a2e3ff426f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", - "tokio-util 0.7.4", + "tokio-util 0.7.7", ] [[package]] @@ -94,7 +94,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.20", ] [[package]] @@ -122,19 +122,20 @@ dependencies = [ [[package]] name = "async-stream" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" dependencies = [ "async-stream-impl", "futures-core", + "pin-project-lite", ] [[package]] name = "async-stream-impl" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", @@ -171,20 +172,20 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.4" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5694b64066a2459918d8074c2ce0d5a88f409431994c2356617c8ae0c4721fc" +checksum = "6137c6234afb339e75e764c866e3594900f0211e1315d33779f269bbe2ec6967" dependencies = [ "async-trait", "axum-core", - "base64 0.20.0", + "base64 0.21.0", "bitflags", "bytes", "futures-util", "http", "http-body 0.4.5", "hyper 0.14.24", - "itoa 1.0.5", + "itoa", "matchit", "memchr", "mime", @@ -200,7 +201,7 @@ dependencies = [ "tokio", "tokio-tungstenite", "tower", - "tower-http", + "tower-http 0.4.0", "tower-layer", "tower-service", ] @@ -254,12 +255,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "base64" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" - [[package]] name = "base64" version = "0.21.0" @@ -366,7 +361,7 @@ dependencies = [ "serde_urlencoded", "thiserror", "tokio", - "tokio-util 0.7.4", + "tokio-util 0.7.7", "url", "winapi", ] @@ -390,18 +385,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata", - "serde", -] - [[package]] name = "bumpalo" version = "3.12.0" @@ -421,9 +404,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c041d3eab048880cb0b86b256447da3f18859a163c3b8d8893f4e6368abe6393" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" [[package]] name = "byteorder" @@ -514,9 +497,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" dependencies = [ "glob", "libc", @@ -525,9 +508,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.4" +version = "4.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" +checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" dependencies = [ "bitflags", "clap_derive", @@ -540,9 +523,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.1.0" +version = "4.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" +checksum = "44bec8e5c9d09e439c4335b1af0abaab56dcf3b94999a936e1bb47b9134288f0" dependencies = [ "heck 0.4.1", "proc-macro-error", @@ -553,9 +536,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" +checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" dependencies = [ "os_str_bytes", ] @@ -651,9 +634,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" dependencies = [ "cfg-if", "crossbeam-utils", @@ -661,9 +644,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", ] @@ -686,13 +669,12 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.6" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +checksum = "af91f40b7355f82b0a891f50e70399475945bb0b0da4f1700ce60761c9d3e359" dependencies = [ - "bstr", "csv-core", - "itoa 0.4.8", + "itoa", "ryu", "serde", ] @@ -718,9 +700,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc831ee6a32dd495436e317595e639a587aa9907bef96fe6e6abc290ab6204e9" +checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" dependencies = [ "cc", "cxxbridge-flags", @@ -730,9 +712,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94331d54f1b1a8895cd81049f7eaaaef9d05a7dcb4d1fd08bf3ff0806246789d" +checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" dependencies = [ "cc", "codespan-reporting", @@ -745,15 +727,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48dcd35ba14ca9b40d6e4b4b39961f23d835dbb8eed74565ded361d93e1feb8a" +checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" [[package]] name = "cxxbridge-macro" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bbeb29798b407ccd82a3324ade1a7286e0d29851475990b612670f6f5124d2" +checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" dependencies = [ "proc-macro2", "quote", @@ -961,9 +943,9 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dyn-clone" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9b0705efd4599c15a38151f4721f7bc388306f61084d3bfd50bd07fbca5cb60" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "either" @@ -1064,9 +1046,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -1306,9 +1288,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" [[package]] name = "glob" @@ -1318,9 +1300,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "h2" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" dependencies = [ "bytes", "fnv", @@ -1331,7 +1313,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util 0.7.4", + "tokio-util 0.7.7", "tracing", ] @@ -1402,13 +1384,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", - "itoa 1.0.5", + "itoa", ] [[package]] @@ -1494,7 +1476,7 @@ dependencies = [ "http-body 0.4.5", "httparse", "httpdate", - "itoa 1.0.5", + "itoa", "pin-project-lite", "socket2", "tokio", @@ -1505,9 +1487,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.0.0-rc.2" +version = "1.0.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "289cfdbf735dea222b0ec6a10224b4d9552c7662bb451d4589cbfda3d407d1a3" +checksum = "7b75264b2003a3913f118d35c586e535293b3e22e41f074930762929d071e092" dependencies = [ "bytes", "futures-channel", @@ -1518,7 +1500,7 @@ dependencies = [ "http-body 1.0.0-rc.2", "httparse", "httpdate", - "itoa 1.0.5", + "itoa", "pin-project-lite", "tokio", "tracing", @@ -1694,9 +1676,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" +checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", @@ -1719,12 +1701,6 @@ dependencies = [ "either", ] -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - [[package]] name = "itoa" version = "1.0.5" @@ -1845,9 +1821,9 @@ dependencies = [ "thiserror", "tokio", "tokio-tungstenite", - "tokio-util 0.7.4", + "tokio-util 0.7.7", "tower", - "tower-http", + "tower-http 0.3.5", "tracing", ] @@ -1902,7 +1878,7 @@ dependencies = [ "smallvec", "thiserror", "tokio", - "tokio-util 0.7.4", + "tokio-util 0.7.7", "tracing", ] @@ -2091,14 +2067,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -2155,7 +2131,7 @@ dependencies = [ "futures", "http-body-util", "httparse", - "hyper 1.0.0-rc.2", + "hyper 1.0.0-rc.3", "iptables", "libc", "mirrord-protocol", @@ -2176,7 +2152,7 @@ dependencies = [ "thiserror", "tokio", "tokio-stream", - "tokio-util 0.7.4", + "tokio-util 0.7.7", "tracing", "tracing-subscriber", "trust-dns-resolver", @@ -2255,7 +2231,7 @@ dependencies = [ "mirrord-progress", "mirrord-protocol", "rand 0.8.5", - "rstest 0.15.0", + "rstest 0.16.0", "serde_json", "thiserror", "tokio", @@ -2283,7 +2259,7 @@ dependencies = [ "http-body 0.4.5", "http-body-util", "hyper 0.14.24", - "hyper 1.0.0-rc.2", + "hyper 1.0.0-rc.3", "itertools", "k8s-openapi", "libc", @@ -2298,7 +2274,7 @@ dependencies = [ "os_info", "rand 0.8.5", "regex", - "rstest 0.15.0", + "rstest 0.16.0", "serde_json", "socket2", "streammap-ext", @@ -2306,7 +2282,7 @@ dependencies = [ "thiserror", "tokio", "tokio-stream", - "tokio-util 0.7.4", + "tokio-util 0.7.7", "tower", "tracing", "tracing-appender", @@ -2373,7 +2349,7 @@ dependencies = [ "fancy-regex", "http-body-util", "http-serde", - "hyper 1.0.0-rc.2", + "hyper 1.0.0-rc.3", "libc", "serde", "thiserror", @@ -2537,15 +2513,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nom8" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" -dependencies = [ - "memchr", -] - [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -2683,18 +2650,18 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d829733185c1ca374f17e52b762f24f535ec625d2cc1f070e34c8a9068f341b" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2be1598bf1c313dcdd12092e3f1920f463462525a21b7b4e11b4168353d0123e" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2745,9 +2712,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "openssl-probe" @@ -3032,9 +2999,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", "toml_edit", @@ -3239,7 +3206,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.17", + "time 0.3.20", "x509-parser", "yasna", ] @@ -3546,9 +3513,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" +checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" dependencies = [ "chrono", "dyn-clone", @@ -3559,9 +3526,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" +checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" dependencies = [ "proc-macro2", "quote", @@ -3694,7 +3661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ "indexmap", - "itoa 1.0.5", + "itoa", "ryu", "serde", ] @@ -3715,7 +3682,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.5", + "itoa", "ryu", "serde", ] @@ -3761,7 +3728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fb06d4b6cdaef0e0c51fa881acb721bed3c924cfaa71d9c94a3b771dfdf6567" dependencies = [ "indexmap", - "itoa 1.0.5", + "itoa", "ryu", "serde", "unsafe-libyaml", @@ -3795,18 +3762,18 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -3884,9 +3851,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -3934,16 +3901,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys 0.42.0", ] [[package]] @@ -4029,7 +3995,7 @@ dependencies = [ "tempdir", "tokio", "tokio-tungstenite", - "tokio-util 0.7.4", + "tokio-util 0.7.7", "wsl", ] @@ -4066,9 +4032,9 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d805f96b7e61fce8728f142e213a3eb2f6b10538efff2d637c923efa4bfca048" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ "cfg-if", "once_cell", @@ -4087,11 +4053,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" dependencies = [ - "itoa 1.0.5", + "itoa", "serde", "time-core", "time-macros", @@ -4105,9 +4071,9 @@ checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" dependencies = [ "time-core", ] @@ -4138,9 +4104,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.25.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg", "bytes", @@ -4152,7 +4118,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -4189,9 +4155,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ "futures-core", "pin-project-lite", @@ -4226,9 +4192,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ "bytes", "futures-core", @@ -4250,19 +4216,19 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" [[package]] name = "toml_edit" -version = "0.18.1" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" +checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825" dependencies = [ "indexmap", - "nom8", "toml_datetime", + "winnow", ] [[package]] @@ -4322,7 +4288,7 @@ dependencies = [ "rand 0.8.5", "slab", "tokio", - "tokio-util 0.7.4", + "tokio-util 0.7.7", "tower-layer", "tower-service", "tracing", @@ -4343,12 +4309,30 @@ dependencies = [ "http-body 0.4.5", "http-range-header", "pin-project-lite", - "tower", "tower-layer", "tower-service", "tracing", ] +[[package]] +name = "tower-http" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body 0.4.5", + "http-range-header", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.2" @@ -4380,7 +4364,7 @@ source = "git+https://github.com/metalbear-co/tracing?branch=worker_options_non_ dependencies = [ "crossbeam-channel", "thiserror", - "time 0.3.17", + "time 0.3.20", "tracing-subscriber", ] @@ -4949,6 +4933,15 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +[[package]] +name = "winnow" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf09497b8f8b5ac5d3bb4d05c0a99be20f26fd3d5f2db7b0716e946d5103658" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.10.1" @@ -4980,7 +4973,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.20", ] [[package]] @@ -5031,7 +5024,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aed2e7a52e3744ab4d0c05c20aa065258e84c49fd4226f5191b2ed29712710b4" dependencies = [ - "time 0.3.17", + "time 0.3.20", ] [[package]] diff --git a/mirrord/layer/src/lib.rs b/mirrord/layer/src/lib.rs index 932fbd02d68..cd0f3be5801 100644 --- a/mirrord/layer/src/lib.rs +++ b/mirrord/layer/src/lib.rs @@ -115,6 +115,7 @@ use crate::{ common::HookMessage, file::{filter::FILE_FILTER, FileHandler}, load::LoadType, + socket::CONNECTION_QUEUE, }; mod common; @@ -841,9 +842,10 @@ pub(crate) fn close_layer_fd(fd: c_int) { .expect("Should be set during initialization!") .is_active(); - // Remove from sockets, or if not a socket, remove from files if file mode active - if SOCKETS.lock().unwrap().remove(&fd).is_none() && file_mode_active { - // SOCKETS lock dropped, not holding it while locking OPEN_FILES. + // Remove from sockets, also removing the `ConnectionQueue` associated with the socket. + if let Some(socket) = SOCKETS.lock().unwrap().remove(&fd) { + CONNECTION_QUEUE.lock().unwrap().remove(socket.id); + } else if file_mode_active { OPEN_FILES.lock().unwrap().remove(&fd); } } diff --git a/mirrord/layer/src/socket.rs b/mirrord/layer/src/socket.rs index d52c647423f..7a4f40f9581 100644 --- a/mirrord/layer/src/socket.rs +++ b/mirrord/layer/src/socket.rs @@ -13,17 +13,31 @@ use socket2::SockAddr; use tracing::warn; use trust_dns_resolver::config::Protocol; +use self::id::SocketId; use crate::{ detour::{Bypass, Detour, OptionExt}, error::{HookError, HookResult}, }; pub(super) mod hooks; +pub(crate) mod id; pub(crate) mod ops; pub(crate) static SOCKETS: LazyLock>>> = LazyLock::new(|| Mutex::new(HashMap::new())); +/// Holds the connections that have yet to be [`accept`](ops::accept)ed. +/// +/// ## Details +/// +/// The connections here are added by +/// [`TcpHandler::create_local_stream`](crate::tcp::TcpHandler::create_local_stream) when the agent +/// sends us a [`NewTcpConnection`](mirrord_protocol::tcp::NewTcpConnection). +/// +/// And they become part of the [`UserSocket`]'s [`SocketState`] when [`ops::accept`] is called. +/// +/// Finally, we remove a socket's queue when the socket's `fd` is closed in +/// [`close_layer_fd`](crate::close_layer_fd). pub static CONNECTION_QUEUE: LazyLock> = LazyLock::new(|| Mutex::new(ConnectionQueue::default())); @@ -39,27 +53,37 @@ pub struct SocketInformation { /// poll_agent loop inserts connection data into this queue, and accept reads it. #[derive(Debug, Default)] pub struct ConnectionQueue { - connections: HashMap>, + connections: HashMap>, } impl ConnectionQueue { - pub fn add(&mut self, fd: &RawFd, info: SocketInformation) { - self.connections.entry(*fd).or_default().push_back(info); + /// Adds a connection. + /// + /// See [`TcpHandler::create_local_stream`](crate::tcp::TcpHandler::create_local_stream). + #[tracing::instrument(level = "trace", skip(self))] + pub(crate) fn add(&mut self, id: SocketId, info: SocketInformation) { + self.connections.entry(id).or_default().push_back(info); } - pub fn get(&mut self, fd: &RawFd) -> Option { - let mut queue = self.connections.remove(fd)?; - if let Some(info) = queue.pop_front() { - if !queue.is_empty() { - self.connections.insert(*fd, queue); - } - Some(info) - } else { - None - } + + /// Pops the next connection to be handled from `Self`. + /// + /// See [`ops::accept]. + #[tracing::instrument(level = "trace", skip(self))] + pub(crate) fn pop_front(&mut self, id: SocketId) -> Option { + self.connections.get_mut(&id)?.pop_front() + } + + /// Removes the [`ConnectionQueue`] associated with the [`UserSocket`]. + /// + /// See [`crate::close_layer_fd]. + #[tracing::instrument(level = "trace", skip(self))] + pub(crate) fn remove(&mut self, id: SocketId) -> Option> { + self.connections.remove(&id) } } impl SocketInformation { + #[tracing::instrument(level = "trace")] pub fn new(remote_address: SocketAddr, local_address: SocketAddr) -> Self { Self { remote_address, @@ -113,7 +137,8 @@ impl TryFrom for SocketKind { #[derive(Debug)] #[allow(dead_code)] -pub struct UserSocket { +pub(crate) struct UserSocket { + pub(crate) id: SocketId, domain: c_int, type_: c_int, protocol: c_int, @@ -121,6 +146,25 @@ pub struct UserSocket { pub(crate) kind: SocketKind, } +impl UserSocket { + pub(crate) fn new( + domain: c_int, + type_: c_int, + protocol: c_int, + state: SocketState, + kind: SocketKind, + ) -> Self { + Self { + id: Default::default(), + domain, + type_, + protocol, + state, + kind, + } + } +} + #[inline] fn is_ignored_port(addr: SocketAddr) -> bool { let (ip, port) = (addr.ip(), addr.port()); diff --git a/mirrord/layer/src/socket/id.rs b/mirrord/layer/src/socket/id.rs new file mode 100644 index 00000000000..abb030b7207 --- /dev/null +++ b/mirrord/layer/src/socket/id.rs @@ -0,0 +1,25 @@ +//! The types in this module should **NOT** be constructed directly. + +use std::sync::atomic::AtomicU64; + +/// Holds the latest `u64` to be used as a new [`SocketId`]. +static SOCKET_ID_ALLOCATOR: AtomicU64 = AtomicU64::new(0); + +/// Better way of identifying a socket than just relying on its `fd`. +/// +/// ## Details +/// +/// Due to how we handle [`ops::dup`], if we were to rely solely on `fd`s to identify a socket, then +/// we can miss changes that should happen on the _original_ `fd` (but were triggered on the +/// _dupped_ `fd`). +/// +/// This is mostly to help the [`ConnectionQueue`] tracking the correct socket for [`ops::accept`]. +#[derive(Debug, PartialOrd, PartialEq, Ord, Eq, Clone, Copy, Hash)] +pub(crate) struct SocketId(u64); + +impl Default for SocketId { + /// Increments [`SOCKET_ID_ALLOCATOR`] and uses the latest value as an id for `Self`. + fn default() -> Self { + Self(SOCKET_ID_ALLOCATOR.fetch_add(1, std::sync::atomic::Ordering::Relaxed)) + } +} diff --git a/mirrord/layer/src/socket/ops.rs b/mirrord/layer/src/socket/ops.rs index eb95b274ea5..0027be8a177 100644 --- a/mirrord/layer/src/socket/ops.rs +++ b/mirrord/layer/src/socket/ops.rs @@ -98,13 +98,7 @@ pub(super) fn socket(domain: c_int, type_: c_int, protocol: c_int) -> Detour Detour { mirror_port: address.port(), requested_port, ipv6: address.is_ipv6(), - fd: sockfd, + id: socket.id, })))?; Arc::get_mut(&mut socket).unwrap().state = SocketState::Listening(Bound { @@ -476,8 +470,9 @@ pub(super) fn getsockname( } /// When the fd is "ours", we accept and recv the first bytes that contain metadata on the -/// connection to be set in our lock This enables us to have a safe way to get "remote" information -/// (remote ip, port, etc). +/// connection to be set in our lock. +/// +/// This enables us to have a safe way to get "remote" information (remote ip, port, etc). #[tracing::instrument(level = "trace", skip(address, address_len))] pub(super) fn accept( sockfd: RawFd, @@ -485,14 +480,14 @@ pub(super) fn accept( address_len: *mut socklen_t, new_fd: RawFd, ) -> Detour { - let (domain, protocol, type_) = { + let (id, domain, protocol, type_) = { SOCKETS .lock()? .get(&sockfd) .bypass(Bypass::LocalFdNotFound(sockfd)) .and_then(|socket| match &socket.state { SocketState::Listening(_) => { - Detour::Success((socket.domain, socket.protocol, socket.type_)) + Detour::Success((socket.id, socket.domain, socket.protocol, socket.type_)) } _ => Detour::Bypass(Bypass::InvalidState(sockfd)), })? @@ -501,21 +496,17 @@ pub(super) fn accept( let (local_address, remote_address) = { CONNECTION_QUEUE .lock()? - .get(&sockfd) + .pop_front(id) .bypass(Bypass::LocalFdNotFound(sockfd)) .map(|socket| (socket.local_address, socket.remote_address))? }; - let new_socket = UserSocket { - domain, - protocol, - type_, - state: SocketState::Connected(Connected { - remote_address, - local_address, - }), - kind: type_.try_into()?, - }; + let state = SocketState::Connected(Connected { + remote_address, + local_address, + }); + let new_socket = UserSocket::new(domain, type_, protocol, state, type_.try_into()?); + fill_address(address, address_len, remote_address)?; SOCKETS.lock()?.insert(new_fd, Arc::new(new_socket)); diff --git a/mirrord/layer/src/tcp.rs b/mirrord/layer/src/tcp.rs index 1b2d600abc9..8922823e27d 100644 --- a/mirrord/layer/src/tcp.rs +++ b/mirrord/layer/src/tcp.rs @@ -5,7 +5,6 @@ use std::{ hash::{Hash, Hasher}, net::SocketAddr, net::{IpAddr, Ipv4Addr, Ipv6Addr}, - os::unix::io::RawFd, }; use async_trait::async_trait; @@ -20,7 +19,7 @@ use tracing::{debug, error, log::trace}; use crate::{ detour::DetourGuard, error::LayerError, - socket::{SocketInformation, CONNECTION_QUEUE}, + socket::{id::SocketId, SocketInformation, CONNECTION_QUEUE}, LayerError::{PortAlreadyStolen, UnexpectedResponseError}, }; @@ -34,7 +33,7 @@ pub(crate) struct Listen { pub mirror_port: Port, pub requested_port: Port, pub ipv6: bool, - pub fd: RawFd, + pub id: SocketId, } impl PartialEq for Listen { @@ -162,7 +161,7 @@ pub(crate) trait TcpHandler { ); { - CONNECTION_QUEUE.lock().unwrap().add(&listen.fd, info); + CONNECTION_QUEUE.lock().unwrap().add(listen.id, info); } #[allow(clippy::let_and_return)]