diff --git a/Cargo.toml b/Cargo.toml index 6492fa16..9baa1026 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ eui48 = { version = "1.1", default-features = false } windows-sys = { version = "0.61", features = ["Win32_System_Threading"] } [target.'cfg(not(target_os = "windows"))'.dev-dependencies] -tun-tap = "0.1.3" +tun-rs = "2.8" [build-dependencies] libloading = "0.8" diff --git a/msrv.lock b/msrv.lock index 2148d849..6a903542 100644 --- a/msrv.lock +++ b/msrv.lock @@ -31,15 +31,15 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" [[package]] -name = "bitflags" -version = "2.13.1" +name = "bumpalo" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "byteorder" @@ -49,29 +49,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - -[[package]] -name = "cc" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509591b7bcd67f4ef775afad7662703b4935daaa6ec0e5605cfb1090b32a2b6d" -dependencies = [ - "find-msvc-tools", - "shlex", -] - -[[package]] -name = "cfg-if" -version = "0.1.10" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] name = "cfg-if" @@ -80,68 +60,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] -name = "cloudabi" -version = "0.0.3" +name = "cfg_aliases" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags 1.3.2", -] +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" [[package]] -name = "crossbeam-deque" -version = "0.7.4" +name = "core-foundation" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", - "maybe-uninit", + "core-foundation-sys", + "libc", ] [[package]] -name = "crossbeam-epoch" -version = "0.8.2" +name = "core-foundation-sys" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", -] +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] -name = "crossbeam-queue" -version = "0.2.3" +name = "downcast" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils", - "maybe-uninit", -] +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] -name = "crossbeam-utils" -version = "0.7.2" +name = "encoding_rs" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", + "cfg-if", ] -[[package]] -name = "downcast" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" - [[package]] name = "errno" version = "0.3.14" @@ -175,18 +129,21 @@ name = "fastrand" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" +dependencies = [ + "getrandom", +] [[package]] -name = "find-msvc-tools" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d45db016d36b838f563236e9193d0ee6ce38f3f68b6c94e914b4929c96bbb890" - -[[package]] -name = "fnv" -version = "1.0.7" +name = "flume" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be" +dependencies = [ + "fastrand", + "futures-core", + "futures-sink", + "spin", +] [[package]] name = "fragile" @@ -197,28 +154,6 @@ dependencies = [ "futures-core", ] -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags 1.3.2", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - [[package]] name = "futures" version = "0.3.34" @@ -328,46 +263,44 @@ dependencies = [ ] [[package]] -name = "getrandom" -version = "0.4.3" +name = "getifaddrs" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +checksum = "a542e1b7ac1f3d62c5777d430d66eca9cb59e813c46b86e29fa9ce94ff9a4810" dependencies = [ - "cfg-if 1.0.4", + "bitflags", "libc", - "r-efi", + "windows-sys", ] [[package]] -name = "hermit-abi" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" - -[[package]] -name = "iovec" -version = "0.1.4" +name = "getrandom" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ + "cfg-if", + "js-sys", "libc", + "r-efi", + "wasm-bindgen", ] [[package]] -name = "kernel32-sys" -version = "0.2.2" +name = "ipnet" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] +checksum = "6a756c3fac73139e83f14c2d742155dd2b78d3ee56597b419a0579b7bdd6dd78" [[package]] -name = "lazy_static" -version = "1.5.0" +name = "js-sys" +version = "0.3.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] [[package]] name = "libc" @@ -381,8 +314,18 @@ version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" dependencies = [ - "cfg-if 1.0.4", - "windows-link", + "cfg-if", + "windows-link 0.2.1", +] + +[[package]] +name = "libloading" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" +dependencies = [ + "cfg-if", + "windows-link 0.2.1", ] [[package]] @@ -393,9 +336,9 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "lock_api" -version = "0.3.4" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ "scopeguard", ] @@ -406,12 +349,6 @@ version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.8.3" @@ -420,32 +357,13 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "memoffset" -version = "0.5.6" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] -[[package]] -name = "mio" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow", - "net2", - "slab", - "winapi 0.2.8", -] - [[package]] name = "mio" version = "1.2.2" @@ -457,36 +375,13 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio 0.6.23", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - [[package]] name = "mockall" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a6ceddfe3ce334925e96bf420fdb2dcee5bed6c632a168ece622676dadeaf8a" dependencies = [ - "cfg-if 1.0.4", + "cfg-if", "downcast", "fragile", "mockall_derive", @@ -500,84 +395,134 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cfe16fbe8a314aeec0b861ac24e60b1e123e97634bab045475b9d6a18416fd8" dependencies = [ - "cfg-if 1.0.4", + "cfg-if", "proc-macro2", "quote", "syn 2.0.119", ] [[package]] -name = "net2" -version = "0.2.39" +name = "netconfig-rs" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac" +checksum = "733ad7a1352f0748a620368f2ea5cd94f0e449c5108fbac86ace31df1601bf6f" dependencies = [ - "cfg-if 0.1.10", + "cfg-if", + "core-foundation", + "ipnet", "libc", - "winapi 0.3.9", + "netlink-packet-core", + "netlink-packet-route 0.25.1", + "netlink-sys", + "nix 0.30.1", + "scopeguard", + "system-configuration-sys", + "thiserror", + "widestring", + "windows", +] + +[[package]] +name = "netlink-packet-core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b897d7bd4f0af82e68d40d0344cf37e97f9c97ddf74a098de3e4da05e96ca395" +dependencies = [ + "paste", ] [[package]] -name = "num_cpus" -version = "1.17.0" +name = "netlink-packet-route" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +checksum = "3ec2f5b6839be2a19d7fa5aab5bc444380f6311c2b693551cb80f45caaa7b5ef" dependencies = [ - "hermit-abi", + "bitflags", "libc", + "log", + "netlink-packet-core", ] [[package]] -name = "once_cell" -version = "1.21.4" +name = "netlink-packet-route" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +checksum = "e2288fcb784eb3defd5fb16f4c4160d5f477de192eac730f43e1d11c24d9a007" +dependencies = [ + "bitflags", + "libc", + "log", + "netlink-packet-core", +] [[package]] -name = "parking_lot" -version = "0.9.0" +name = "netlink-sys" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +checksum = "cd6c30ed10fa69cc491d491b85cc971f6bdeb8e7367b7cde2ee6cc878d583fae" dependencies = [ - "lock_api", - "parking_lot_core", - "rustc_version", + "bytes", + "libc", + "log", +] + +[[package]] +name = "nix" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" +dependencies = [ + "bitflags", + "cfg-if", + "cfg_aliases", + "libc", + "memoffset", ] [[package]] -name = "parking_lot_core" -version = "0.6.3" +name = "nix" +version = "0.31.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66b810a62be75176a80873726630147a5ca780cd33921e0b5709033e66b0a" +checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", + "bitflags", + "cfg-if", + "cfg_aliases", "libc", - "redox_syscall", - "rustc_version", - "smallvec", - "winapi 0.3.9", + "memoffset", ] +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pcap" version = "3.0.0" dependencies = [ - "bitflags 2.13.1", + "bitflags", "errno", "etherparse", "eui48", - "futures 0.3.34", + "futures", "gat-std", "libc", - "libloading", + "libloading 0.8.9", "mockall", "once_cell", "pkg-config", "regex", "tempfile", - "tokio 1.53.1", - "tun-tap", + "tokio", + "tun-rs", "windows-sys", ] @@ -643,12 +588,6 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - [[package]] name = "regex" version = "1.13.1" @@ -679,12 +618,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] -name = "rustc_version" -version = "0.2.3" +name = "route_manager" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "e06d678f16f191d7232488ef782418aafb953bccfc6c38d28255ed6610c18dce" dependencies = [ - "semver", + "flume", + "libc", + "netlink-packet-core", + "netlink-packet-route 0.31.0", + "netlink-sys", + "windows-sys", ] [[package]] @@ -693,7 +637,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.13.1", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -701,10 +645,10 @@ dependencies = [ ] [[package]] -name = "scoped-tls" -version = "0.1.2" +name = "rustversion" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" [[package]] name = "scopeguard" @@ -712,42 +656,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "shlex" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" - [[package]] name = "slab" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - [[package]] name = "socket2" version = "0.6.5" @@ -758,6 +672,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "spin" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" +dependencies = [ + "lock_api", +] + [[package]] name = "syn" version = "1.0.109" @@ -791,6 +714,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" version = "3.27.0" @@ -811,27 +744,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" [[package]] -name = "tokio" -version = "0.1.22" +name = "thiserror" +version = "2.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" +checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" dependencies = [ - "bytes", - "futures 0.1.31", - "mio 0.6.23", - "num_cpus", - "tokio-codec", - "tokio-current-thread", - "tokio-executor", - "tokio-fs", - "tokio-io", - "tokio-reactor", - "tokio-sync", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "tokio-udp", - "tokio-uds", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", ] [[package]] @@ -841,7 +770,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" dependencies = [ "libc", - "mio 1.2.2", + "mio", "pin-project-lite", "socket2", "tokio-macros", @@ -849,257 +778,209 @@ dependencies = [ ] [[package]] -name = "tokio-codec" -version = "0.1.2" +name = "tokio-macros" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" dependencies = [ - "bytes", - "futures 0.1.31", - "tokio-io", + "proc-macro2", + "quote", + "syn 3.0.3", ] [[package]] -name = "tokio-core" -version = "0.1.18" +name = "tun-rs" +version = "2.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87b1395334443abca552f63d4f61d0486f12377c2ba8b368e523f89e828cffd4" +checksum = "bb50fdefaf791097b5559791cef2b2e9da2fad974809264d104cafbaa3efc452" dependencies = [ + "byteorder", "bytes", - "futures 0.1.31", - "iovec", + "encoding_rs", + "getifaddrs", + "ipnet", + "libc", + "libloading 0.9.0", "log", - "mio 0.6.23", - "scoped-tls", - "tokio 0.1.22", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-timer", + "netconfig-rs", + "nix 0.31.3", + "route_manager", + "scopeguard", + "widestring", + "windows-sys", + "winreg", ] [[package]] -name = "tokio-current-thread" -version = "0.1.7" +name = "unicode-ident" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures 0.1.31", - "tokio-executor", -] +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] -name = "tokio-executor" -version = "0.1.10" +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils", - "futures 0.1.31", -] +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] -name = "tokio-fs" -version = "0.1.7" +name = "wasm-bindgen" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" +checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70" dependencies = [ - "futures 0.1.31", - "tokio-io", - "tokio-threadpool", + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", ] [[package]] -name = "tokio-io" -version = "0.1.13" +name = "wasm-bindgen-macro" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" +checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1" dependencies = [ - "bytes", - "futures 0.1.31", - "log", + "quote", + "wasm-bindgen-macro-support", ] [[package]] -name = "tokio-macros" -version = "2.7.2" +name = "wasm-bindgen-macro-support" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284" dependencies = [ + "bumpalo", "proc-macro2", "quote", - "syn 3.0.3", + "syn 2.0.119", + "wasm-bindgen-shared", ] [[package]] -name = "tokio-reactor" -version = "0.1.12" +name = "wasm-bindgen-shared" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" +checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf" dependencies = [ - "crossbeam-utils", - "futures 0.1.31", - "lazy_static", - "log", - "mio 0.6.23", - "num_cpus", - "parking_lot", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", + "unicode-ident", ] [[package]] -name = "tokio-sync" -version = "0.1.8" +name = "widestring" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures 0.1.31", -] +checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" [[package]] -name = "tokio-tcp" -version = "0.1.4" +name = "windows" +version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ - "bytes", - "futures 0.1.31", - "iovec", - "mio 0.6.23", - "tokio-io", - "tokio-reactor", + "windows-collections", + "windows-core", + "windows-future", + "windows-link 0.1.3", + "windows-numerics", ] [[package]] -name = "tokio-threadpool" -version = "0.1.18" +name = "windows-collections" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils", - "futures 0.1.31", - "lazy_static", - "log", - "num_cpus", - "slab", - "tokio-executor", + "windows-core", ] [[package]] -name = "tokio-timer" -version = "0.2.13" +name = "windows-core" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "crossbeam-utils", - "futures 0.1.31", - "slab", - "tokio-executor", + "windows-implement", + "windows-interface", + "windows-link 0.1.3", + "windows-result", + "windows-strings", ] [[package]] -name = "tokio-udp" -version = "0.1.6" +name = "windows-future" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "bytes", - "futures 0.1.31", - "log", - "mio 0.6.23", - "tokio-codec", - "tokio-io", - "tokio-reactor", + "windows-core", + "windows-link 0.1.3", + "windows-threading", ] [[package]] -name = "tokio-uds" -version = "0.2.7" +name = "windows-implement" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ - "bytes", - "futures 0.1.31", - "iovec", - "libc", - "log", - "mio 0.6.23", - "mio-uds", - "tokio-codec", - "tokio-io", - "tokio-reactor", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "tun-tap" -version = "0.1.4" +name = "windows-interface" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a477a4e9367c72ac875d23cd07ac99ffa932497d8428767fed0cfa27bbabe50" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ - "cc", - "futures 0.1.31", - "libc", - "mio 0.6.23", - "tokio-core", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "unicode-ident" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" +name = "windows-link" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" [[package]] -name = "winapi" -version = "0.2.8" +name = "windows-link" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-numerics" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-core", + "windows-link 0.1.3", ] [[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows-result" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link 0.1.3", +] [[package]] -name = "windows-link" -version = "0.2.1" +name = "windows-strings" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link 0.1.3", +] [[package]] name = "windows-sys" @@ -1107,15 +988,24 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link", + "windows-link 0.2.1", ] [[package]] -name = "ws2_32-sys" -version = "0.2.1" +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "winreg" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10" dependencies = [ - "winapi 0.2.8", - "winapi-build", + "cfg-if", + "windows-sys", ] diff --git a/tests/tap_tests.rs b/tests/tap_tests.rs index 991fc034..abe98b37 100644 --- a/tests/tap_tests.rs +++ b/tests/tap_tests.rs @@ -1,5 +1,5 @@ /*** -* These tests need to be run as root and currently only work on Linux (and maybe MacOs?) +* These tests need to be run as root and currently only work on Linux (and maybe macOS?) * * To build and run these tests, run: * @@ -12,7 +12,7 @@ * which does the build as a non-priv user, extracts the exec binary location of * the test from 'cargo test', and runs only that as root. * -* To develop on these tests, you need to manually enable this feature in VSCode ala: +* To develop on these tests, you need to turn this feature on by hand in VS Code: * * In VS Code, open the Extensions sidebar, click the gear icon next * to the rust-analyzer extension, and choose “Extension Settings.” @@ -24,10 +24,10 @@ * * to debug, run: * -* sudo rust-gdb ./target/debug/deps/tap_test-${BUILD} -* break tap_test::tests:: # to get a list of useful breakpoints +* sudo rust-gdb ./target/debug/deps/tap_tests-${BUILD} +* break tap_tests::tests:: # to get a list of useful breakpoints * -* NOTE: tests in rust capture stdio/stderr by default; add "-- --nocapture", e.g., +* NOTE: tests in Rust capture stdout and stderr by default; add "-- --nocapture", e.g., * 'cargo test -- --nocapture' */ #[cfg(not(windows))] @@ -35,7 +35,7 @@ mod tests { use etherparse::{PacketBuilder, PacketHeaders}; use pcap::Capture; - use tun_tap::Iface; + use tun_rs::SyncDevice; /*** * Create a Tap interface and make sure that the sendpacket() and next_packet() @@ -57,15 +57,15 @@ mod tests { let mut pkt1 = Vec::with_capacity(builder1.size(payload1.len())); builder1.write(&mut pkt1, &payload1).unwrap(); - // send it in the interface + // send it into the interface let send_len = iface.send(&pkt1).unwrap(); assert_eq!(send_len, pkt1.len()); // try to pcap capture it let test_pkt1 = cap.next_packet().unwrap(); - // did we capture the whole packet? + // was the whole packet captured? assert_eq!(pkt1.len(), test_pkt1.header.caplen as usize); - // does it match what we expect? + // does it match the packet that went in? assert_eq!(&pkt1, test_pkt1.data); // now, try to pcap send it back out that interface @@ -76,7 +76,7 @@ mod tests { let (test_sendpkt, _) = buf.split_at(recv_len); if recv_len != pkt1.len() { - // wtf!? + // something else came back, so decode it and say what it was let weird = PacketHeaders::from_ethernet_slice(test_sendpkt).unwrap(); panic!("weird packet !! {weird:#?}"); } @@ -88,19 +88,22 @@ mod tests { * Bind a tap interface and attach a pcap capture to it and return both * * Return as a Capture in case the caller wants to set some - * different options before opening it (maybe?) + * different options before opening it */ - fn capture_tap_interface() -> (Capture, Iface) { - use tun_tap::Mode; - - // without_packet_info sets ioctl(fd, IFF_NO_PI ) on the tap fd - // as described in https://www.gabriel.urdhr.fr/2021/05/08/tuntap/#packet-information - // it's not useful for l2 tap packets, so wouldl like to skip to simplify tests - let iface_result = Iface::without_packet_info("testtap%d", Mode::Tap); - // I know this could/should be a match(), but I think this is cleaner... + fn capture_tap_interface() -> (Capture, SyncDevice) { + use tun_rs::{DeviceBuilder, Layer}; + + // Layer::L2 is a tap rather than a tun. The builder leaves IFF_NO_PI set unless + // packet_information() asks for it, as described in + // https://www.gabriel.urdhr.fr/2021/05/08/tuntap/#packet-information + // it is not useful for l2 tap packets and would only complicate them + let iface_result = DeviceBuilder::new() + .name("testtap%d") + .layer(Layer::L2) + .build_sync(); if let Err(e) = iface_result { if e.kind() == std::io::ErrorKind::PermissionDenied { - println!("Permission denied - needs tp be run as root/sudo!"); + println!("Permission denied - needs to be run as root/sudo!"); panic!( "Failed to bind the tap interface: PermissionDenied - please run with root/sudo!" ); @@ -109,29 +112,29 @@ mod tests { panic!("Failed to bind the tap interface: {e:#?}"); } let iface = iface_result.unwrap(); + let iface_name = iface.name().unwrap(); if cfg!(target_os = "linux") { // If IPv6 is enabled, it will broadcast all sorts of stuff on this interface - // these broadcasts will periodically (heisenbug!) break tests that aren't smart enough - // so disable IPv6 on the test interface before we start any captures - // It's important to do this BEFORE bringing up the interface else there's still - // a race condition (that we were losing more often than not!) + // these broadcasts will periodically (heisenbug!) break tests that aren't smart + // enough to ignore them, so disable IPv6 on the test interface before any capture + // starts. It has to happen BEFORE the interface comes up, else there is still a + // race condition, and it was lost more often than not safe_run_command(format!( - "sysctl -w net.ipv6.conf.{}.disable_ipv6=1", - iface.name() + "sysctl -w net.ipv6.conf.{iface_name}.disable_ipv6=1" )); - // Under Linux, the interface is created, but defaults to 'down' state, where pcap needs it 'up' - // Yes, it's a hack to use the command line instead of an API, but the netdev APIs are messy - // TODO: decide if we should move to the https://crates.io/keywords/netlink crate - safe_run_command(format!("ip link set dev {} up", iface.name())); + // Under Linux, the interface is created in the 'down' state, and pcap needs it 'up' + // Shelling out instead of calling an API is a hack, but the netdev APIs are messy + // TODO: consider moving to the https://crates.io/keywords/netlink crate + safe_run_command(format!("ip link set dev {iface_name} up")); } - let device = pcap::Device::from(iface.name()); + let device = pcap::Device::from(iface_name.as_str()); (Capture::from_device(device).unwrap(), iface) } /** - * Run a command on the shell, check the output, and pretty print a panic message and the - * stderr if it fails. + * Run a command, check that it succeeded, and pretty print a panic message with its + * stderr if it did not */ fn safe_run_command(cmd: String) { use std::process::Command;