diff --git a/test/test-manager/src/vm/network/macos.rs b/test/test-manager/src/vm/network/macos.rs index 5eeb6f611c3c..d0e48fbd7d7f 100644 --- a/test/test-manager/src/vm/network/macos.rs +++ b/test/test-manager/src/vm/network/macos.rs @@ -16,9 +16,6 @@ const CUSTOM_TUN_LOCAL_PUBKEY: &str = "h6elqt3dfamtS/p9jxJ8bIYs8UW9YHfTFhvx0fabT data_encoding_macro::base64_array!( "pub const CUSTOM_TUN_LOCAL_PRIVKEY" = "mPue6Xt0pdz4NRAhfQSp/SLKo7kV7DW+2zvBq0N9iUI=" ); -/// "Real" (non-tunnel) IP of the wireguard remote peer as defined in `setup-network.sh`. -/// TODO: This should not be hardcoded. Set by tart. -pub const CUSTOM_TUN_REMOTE_REAL_ADDR: Ipv4Addr = Ipv4Addr::new(192, 168, 64, 1); /// Port of the wireguard remote peer as defined in `setup-network.sh`. pub const CUSTOM_TUN_REMOTE_REAL_PORT: u16 = 51820; /// Tunnel address of the wireguard local peer as defined in `setup-network.sh`. @@ -27,9 +24,6 @@ pub const CUSTOM_TUN_LOCAL_TUN_ADDR: Ipv4Addr = Ipv4Addr::new(192, 168, 15, 2); pub const CUSTOM_TUN_REMOTE_TUN_ADDR: Ipv4Addr = Ipv4Addr::new(192, 168, 15, 1); /// Gateway (and default DNS resolver) of the wireguard tunnel. pub const CUSTOM_TUN_GATEWAY: Ipv4Addr = CUSTOM_TUN_REMOTE_TUN_ADDR; -/// Gateway of the non-tunnel interface. -/// TODO: This should not be hardcoded. Set by tart. -pub const NON_TUN_GATEWAY: Ipv4Addr = Ipv4Addr::new(192, 168, 64, 1); /// Name of the wireguard interface on the host pub const CUSTOM_TUN_INTERFACE_NAME: &str = "utun123"; @@ -61,22 +55,15 @@ pub(crate) fn find_vm_bridge(guest_ip: &Ipv4Addr) -> Result<(String, Ipv4Addr)> let to_sock_addr = |addr: Option| { addr.as_ref() .and_then(|addr| addr.as_sockaddr_in()) - .map(|addr| SocketAddrV4::from(*addr).ip()) + .map(|addr| *SocketAddrV4::from(*addr).ip()) }; - // if to_sock_addr(addr.address) - // .zip(to_sock_addr(addr.netmask)) - // .map(|(&address, &netmask)| ipnetwork::Ipv4Network::with_netmask(address, netmask)) - // .map(|ip_v4_network| ip_v4_network.contains(*guest_ip)) - // == Some(true) - // { - // return Ok((addr.interface_name.to_owned(), *address)); - // }; + if let (Some(address), Some(netmask)) = (to_sock_addr(addr.address), to_sock_addr(addr.netmask)) { - if let Ok(ip_v4_network) = ipnetwork::Ipv4Network::with_netmask(*address, *netmask) { + if let Ok(ip_v4_network) = ipnetwork::Ipv4Network::with_netmask(address, netmask) { if ip_v4_network.contains(*guest_ip) { - return Ok((addr.interface_name.to_owned(), *address)); + return Ok((addr.interface_name.to_owned(), address)); } }; };