Merge pull request #21 from aeber/fix_macos_ipv6
Fix macos ip/route setup for ipv6 netspull/31/head
commit
d2bc2b3506
|
@ -24,16 +24,24 @@ fn cmd(bin: &str, args: &[&str]) -> Result<process::Output, Error> {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub fn set_addr(interface: &str, addr: IpNetwork) -> Result<(), Error> {
|
pub fn set_addr(interface: &str, addr: IpNetwork) -> Result<(), Error> {
|
||||||
let real_interface = wgctrl::backends::userspace::resolve_tun(interface).with_str(interface)?;
|
let real_interface = wgctrl::backends::userspace::resolve_tun(interface).with_str(interface)?;
|
||||||
cmd(
|
|
||||||
"ifconfig",
|
if addr.is_ipv4() {
|
||||||
&[
|
cmd(
|
||||||
&real_interface,
|
"ifconfig",
|
||||||
"inet",
|
&[
|
||||||
&addr.to_string(),
|
&real_interface,
|
||||||
&addr.ip().to_string(),
|
"inet",
|
||||||
"alias",
|
&addr.to_string(),
|
||||||
],
|
&addr.ip().to_string(),
|
||||||
)?;
|
"alias",
|
||||||
|
],
|
||||||
|
)?;
|
||||||
|
} else {
|
||||||
|
cmd(
|
||||||
|
"ifconfig",
|
||||||
|
&[&real_interface, "inet6", &addr.to_string(), "alias"],
|
||||||
|
)?;
|
||||||
|
}
|
||||||
cmd("ifconfig", &[&real_interface, "mtu", "1420"])?;
|
cmd("ifconfig", &[&real_interface, "mtu", "1420"])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -113,7 +121,7 @@ pub fn add_route(interface: &str, cidr: IpNetwork) -> Result<bool, Error> {
|
||||||
&[
|
&[
|
||||||
"-n",
|
"-n",
|
||||||
"add",
|
"add",
|
||||||
"-inet",
|
if cidr.is_ipv4() { "-inet" } else { "-inet6" },
|
||||||
&cidr.to_string(),
|
&cidr.to_string(),
|
||||||
"-interface",
|
"-interface",
|
||||||
&real_interface,
|
&real_interface,
|
||||||
|
|
Loading…
Reference in New Issue