Skip to content

Commit

Permalink
Tweak Windows implementation
Browse files Browse the repository at this point in the history
 - Fewer deps for Windows (doesn't need libc and memalloc anymore).
 - Somewhat safer allocation - relying on Vec + Drop which is guaranteed to run on any panic / return / etc instead of manually tracking a raw pointer for the buffer.
 - Increase initial buffer size as per official recommendations.
 - Add safe iteration helper for Windows linked lists (assuming that, if the first pointer is valid, then all others should be as well and will have the same lifetime). This significantly reduces number of individual `unsafe` usages and paves path for shellrow#45 as the entire function is now just an iterator + `.collect()`.
 - Simplify socket address conversions by relying on Rust's built-in endianness helpers and the SOCKADDR_INET helper union.
  • Loading branch information
RReverser committed Aug 27, 2024
1 parent 2333a1a commit 1ec955b
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 158 deletions.
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ categories = ["network-programming"]
license = "MIT"

[dependencies]
libc = "0.2"
serde = { version = "1", features = ["derive"], optional = true }

[target.'cfg(unix)'.dependencies]
libc = "0.2"

[target.'cfg(target_os = "android")'.dependencies]
# DL Open
dlopen2 = { version = "0.5", default-features = false }
Expand All @@ -23,12 +25,9 @@ netlink-packet-core = "0.7"
netlink-packet-route = "0.17"
netlink-sys = "0.8"

[target.'cfg(windows)'.dependencies]
memalloc = "0.1.0"

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.52"
features = ["Win32_Foundation","Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock", "Win32_NetworkManagement_Ndis"]
features = ["Win32_Foundation", "Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock", "Win32_NetworkManagement_Ndis"]

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
system-configuration = "0.6"
Expand Down
Loading

0 comments on commit 1ec955b

Please sign in to comment.