oops port 0

This commit is contained in:
John Smith 2022-08-22 15:19:39 -04:00
parent 997eca05b6
commit c7e184541e

View File

@ -64,7 +64,10 @@ impl IGDManager {
AddressType::IPV6 => SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), 0), AddressType::IPV6 => SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), 0),
}) { }) {
Ok(s) => s, Ok(s) => s,
Err(_) => return None, Err(e) => {
log_net!(debug "failed to bind to unspecified address: {}", e);
return None;
}
}; };
// can be any routable ip address, // can be any routable ip address,
@ -72,11 +75,14 @@ impl IGDManager {
// using google's dns, but it wont actually send any packets to it // using google's dns, but it wont actually send any packets to it
socket socket
.connect(match address_type { .connect(match address_type {
AddressType::IPV4 => SocketAddr::new(IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8)), 0), AddressType::IPV4 => SocketAddr::new(IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8)), 80),
AddressType::IPV6 => SocketAddr::new( AddressType::IPV6 => SocketAddr::new(
IpAddr::V6(Ipv6Addr::new(0x2001, 0x4860, 0x4860, 0, 0, 0, 0, 0x8888)), IpAddr::V6(Ipv6Addr::new(0x2001, 0x4860, 0x4860, 0, 0, 0, 0, 0x8888)),
0, 80,
), ),
}).map_err(|e| {
log_net!(debug "failed to connect to dummy address: {}", e);
e
}) })
.ok()?; .ok()?;
@ -93,7 +99,7 @@ impl IGDManager {
let ip = match Self::get_routed_local_ip_address(address_type) { let ip = match Self::get_routed_local_ip_address(address_type) {
Some(x) => x, Some(x) => x,
None => { None => {
log_net!("failed to get local ip address"); log_net!(debug "failed to get local ip address: address_type={:?}", address_type);
return None; return None;
} }
}; };
@ -127,7 +133,7 @@ impl IGDManager {
)) { )) {
Ok(v) => v, Ok(v) => v,
Err(e) => { Err(e) => {
log_net!("couldn't find ipv4 igd: {}", e); log_net!(debug "couldn't find ipv4 igd: {}", e);
return None; return None;
} }
} }
@ -139,7 +145,7 @@ impl IGDManager {
)) { )) {
Ok(v) => v, Ok(v) => v,
Err(e) => { Err(e) => {
log_net!("couldn't find ipv6 igd: {}", e); log_net!(debug "couldn't find ipv6 igd: {}", e);
return None; return None;
} }
} }