1
0
mirror of https://github.com/tonarino/innernet.git synced 2024-11-24 08:42:33 +02:00

Fix macos ip/route setup for ipv6 nets

This commit is contained in:
Anselm Eberhardt 2021-03-31 18:16:00 +02:00
parent 03576a5892
commit c3ae74bd34

View File

@ -24,6 +24,8 @@ fn cmd(bin: &str, args: &[&str]) -> Result<process::Output, Error> {
#[cfg(target_os = "macos")]
pub fn set_addr(interface: &str, addr: IpNetwork) -> Result<(), Error> {
let real_interface = wgctrl::backends::userspace::resolve_tun(interface).with_str(interface)?;
if addr.is_ipv4() {
cmd(
"ifconfig",
&[
@ -34,6 +36,12 @@ pub fn set_addr(interface: &str, addr: IpNetwork) -> Result<(), Error> {
"alias",
],
)?;
} else {
cmd(
"ifconfig",
&[&real_interface, "inet6", &addr.to_string(), "alias"],
)?;
}
cmd("ifconfig", &[&real_interface, "mtu", "1420"])?;
Ok(())
}
@ -113,7 +121,7 @@ pub fn add_route(interface: &str, cidr: IpNetwork) -> Result<bool, Error> {
&[
"-n",
"add",
"-inet",
if cidr.is_ipv4() { "-inet" } else { "-inet6" },
&cidr.to_string(),
"-interface",
&real_interface,