Skip to content

Commit

Permalink
!fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Serock3 committed Jan 8, 2025
1 parent 3316799 commit 67dc5e9
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions test/test-manager/src/vm/network/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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";

Expand Down Expand Up @@ -61,22 +55,15 @@ pub(crate) fn find_vm_bridge(guest_ip: &Ipv4Addr) -> Result<(String, Ipv4Addr)>
let to_sock_addr = |addr: Option<SockaddrStorage>| {
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));
}
};
};
Expand Down

0 comments on commit 67dc5e9

Please sign in to comment.