Skip to content

Commit

Permalink
Bump version 6.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Oct 3, 2024
1 parent b931489 commit f588bcf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tproxy-config"
version = "6.0.5"
version = "6.0.6"
edition = "2021"
description = "Transparent proxy configuration"
license = "MIT"
Expand Down
10 changes: 7 additions & 3 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ fn _tproxy_remove(state: &mut TproxyState) -> std::io::Result<()> {
}

pub(crate) fn get_default_gateway() -> std::io::Result<(IpAddr, String)> {
let addr = get_default_gateway_ip()?;
let iface = get_default_gateway_interface()?;
Ok((addr, iface))
}

pub(crate) fn get_default_gateway_ip() -> std::io::Result<IpAddr> {
let cmd = "Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE | ForEach-Object { $_.DefaultIPGateway }";
let gateways = match run_command("powershell", &["-Command", cmd]) {
Ok(gateways) => gateways,
Expand Down Expand Up @@ -170,9 +176,7 @@ pub(crate) fn get_default_gateway() -> std::io::Result<(IpAddr, String)> {
}

let err = std::io::Error::new(std::io::ErrorKind::Other, "No default gateway found");
let addr = ipv4_gateway.or(ipv6_gateway).ok_or(err)?;
let iface = get_default_gateway_interface()?;
Ok((addr, iface))
ipv4_gateway.or(ipv6_gateway).ok_or(err)
}

pub(crate) fn get_default_gateway_interface() -> std::io::Result<String> {
Expand Down

0 comments on commit f588bcf

Please sign in to comment.