From dbda68f6966ccc0c7a6f23d1a51cd360daa0d07f Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Mon, 22 May 2023 21:20:51 +0900 Subject: [PATCH 1/5] Update windows dependency --- Cargo.toml | 4 ++-- src/interface/windows.rs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c01ce45..e023e32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,8 @@ netlink-sys = "0.8" memalloc = "0.1.0" [target.'cfg(windows)'.dependencies.windows] -version = "0.32.0" -features = ["Win32_Foundation","Win32_NetworkManagement_IpHelper", "Win32_Networking_WinSock"] +version = "0.48.0" +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.5.0" diff --git a/src/interface/windows.rs b/src/interface/windows.rs index 65c5de5..7166712 100644 --- a/src/interface/windows.rs +++ b/src/interface/windows.rs @@ -6,10 +6,10 @@ use std::convert::TryInto; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use windows::Win32::Foundation::{ERROR_BUFFER_OVERFLOW, NO_ERROR}; use windows::Win32::NetworkManagement::IpHelper::{ - GetAdaptersAddresses, SendARP, AF_INET, AF_INET6, AF_UNSPEC, GAA_FLAG_INCLUDE_GATEWAYS, + GetAdaptersAddresses, SendARP, GAA_FLAG_INCLUDE_GATEWAYS, IP_ADAPTER_ADDRESSES_LH, }; -use windows::Win32::Networking::WinSock::{SOCKADDR_IN, SOCKADDR_IN6}; +use windows::Win32::Networking::WinSock::{SOCKADDR_IN, SOCKADDR_IN6, AF_INET, AF_INET6, AF_UNSPEC}; use crate::gateway::Gateway; use crate::interface::{Interface, InterfaceType, MacAddr}; @@ -61,10 +61,10 @@ pub fn interfaces() -> Vec { let old_size = dwsize as usize; ret_val = unsafe { GetAdaptersAddresses( - AF_UNSPEC, + AF_UNSPEC.0 as u32, GAA_FLAG_INCLUDE_GATEWAYS, - std::ptr::null_mut::(), - mem, + Some(std::ptr::null_mut::()), + Some(mem), &mut dwsize, ) }; @@ -126,7 +126,7 @@ pub fn interfaces() -> Vec { let addr = unsafe { (*cur_a).Address }; let prefix_len = unsafe { (*cur_a).OnLinkPrefixLength }; let sockaddr = unsafe { *addr.lpSockaddr }; - if sockaddr.sa_family == AF_INET.0 as u16 { + if sockaddr.sa_family == AF_INET { let sockaddr: *mut SOCKADDR_IN = addr.lpSockaddr as *mut SOCKADDR_IN; let a = unsafe { (*sockaddr).sin_addr.S_un.S_addr }; let ipv4 = if cfg!(target_endian = "little") { @@ -136,7 +136,7 @@ pub fn interfaces() -> Vec { }; let ipv4_net: Ipv4Net = Ipv4Net::new(ipv4, prefix_len); ipv4_vec.push(ipv4_net); - } else if sockaddr.sa_family == AF_INET6.0 as u16 { + } else if sockaddr.sa_family == AF_INET6 { let sockaddr: *mut SOCKADDR_IN6 = addr.lpSockaddr as *mut SOCKADDR_IN6; let a = unsafe { (*sockaddr).sin6_addr.u.Byte }; let ipv6 = Ipv6Addr::from(a); @@ -152,7 +152,7 @@ pub fn interfaces() -> Vec { while !cur_g.is_null() { let addr = unsafe { (*cur_g).Address }; let sockaddr = unsafe { *addr.lpSockaddr }; - if sockaddr.sa_family == AF_INET.0 as u16 { + if sockaddr.sa_family == AF_INET { let sockaddr: *mut SOCKADDR_IN = addr.lpSockaddr as *mut SOCKADDR_IN; let a = unsafe { (*sockaddr).sin_addr.S_un.S_addr }; let ipv4 = if cfg!(target_endian = "little") { From de905706e05a5f7d9b32c08b9679bb72fe11df32 Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Mon, 22 May 2023 21:30:49 +0900 Subject: [PATCH 2/5] Run rustfmt --- src/interface/windows.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/interface/windows.rs b/src/interface/windows.rs index 7166712..f9c7fa8 100644 --- a/src/interface/windows.rs +++ b/src/interface/windows.rs @@ -6,10 +6,11 @@ use std::convert::TryInto; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use windows::Win32::Foundation::{ERROR_BUFFER_OVERFLOW, NO_ERROR}; use windows::Win32::NetworkManagement::IpHelper::{ - GetAdaptersAddresses, SendARP, GAA_FLAG_INCLUDE_GATEWAYS, - IP_ADAPTER_ADDRESSES_LH, + GetAdaptersAddresses, SendARP, GAA_FLAG_INCLUDE_GATEWAYS, IP_ADAPTER_ADDRESSES_LH, +}; +use windows::Win32::Networking::WinSock::{ + AF_INET, AF_INET6, AF_UNSPEC, SOCKADDR_IN, SOCKADDR_IN6, }; -use windows::Win32::Networking::WinSock::{SOCKADDR_IN, SOCKADDR_IN6, AF_INET, AF_INET6, AF_UNSPEC}; use crate::gateway::Gateway; use crate::interface::{Interface, InterfaceType, MacAddr}; From 95ed57922dff183a65f03ad73607f731c083d30c Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Mon, 22 May 2023 21:54:28 +0900 Subject: [PATCH 3/5] Update ci.yml --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 121804e..0d944bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,9 +53,7 @@ jobs: - uses: actions/checkout@master - name: Install Rust Toolchain - # See https://github.com/cross-rs/cross/issues/1222 for when - # stable can be used instead of 1.67 again. - run: rustup toolchain install 1.67 --profile minimal --no-self-update + run: rustup toolchain install stable --profile minimal --no-self-update - uses: swatinem/rust-cache@v2 From 3b7f4de183ea53be8a39ed557574cfa6b586abff Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Mon, 22 May 2023 22:00:04 +0900 Subject: [PATCH 4/5] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d944bd..f9b194e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: fail-fast: false matrix: target: - - i686-unknown-linux-gnu + - x86_64-unknown-linux-gnu - armv7-linux-androideabi - aarch64-linux-android From b67ffecf951c7fa2381c34f91fd907766d4bd656 Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Mon, 22 May 2023 22:02:26 +0900 Subject: [PATCH 5/5] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9b194e..5ad873c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,7 @@ jobs: matrix: target: - x86_64-unknown-linux-gnu + - i686-unknown-linux-gnu - armv7-linux-androideabi - aarch64-linux-android