improved local IP guessing slightly
This commit is contained in:
parent
3bfaaf1129
commit
674e1f96b1
|
@ -84,6 +84,9 @@ void lsd::rebind(address const& listen_interface)
|
|||
udp::resolver::iterator i = r.resolve(udp::resolver::query(asio::ip::host_name(), "0"));
|
||||
for (;i != udp::resolver_iterator(); ++i)
|
||||
{
|
||||
// ignore the loopback
|
||||
if (i->endpoint().address() == address_v4((127 << 24) + 1)) continue;
|
||||
// ignore non-IPv4 addresses
|
||||
if (i->endpoint().address().is_v4()) break;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,9 @@ void natpmp::rebind(address const& listen_interface) try
|
|||
udp::resolver::iterator i = r.resolve(udp::resolver::query(asio::ip::host_name(), "0"));
|
||||
for (;i != udp::resolver_iterator(); ++i)
|
||||
{
|
||||
// ignore the loopback
|
||||
if (i->endpoint().address() == address_v4((127 << 24) + 1)) continue;
|
||||
// ignore non-IPv4 addresses
|
||||
if (i->endpoint().address().is_v4()) break;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,13 +95,16 @@ void upnp::rebind(address const& listen_interface) try
|
|||
udp::resolver::iterator i = r.resolve(udp::resolver::query(asio::ip::host_name(), "0"));
|
||||
for (;i != udp::resolver_iterator(); ++i)
|
||||
{
|
||||
// ignore the loopback
|
||||
if (i->endpoint().address() == address_v4((127 << 24) + 1)) continue;
|
||||
// ignore non-IPv4 addresses
|
||||
if (i->endpoint().address().is_v4()) break;
|
||||
}
|
||||
|
||||
if (i == udp::resolver_iterator())
|
||||
{
|
||||
throw std::runtime_error("local host name did not resolve to an "
|
||||
"IPv4 address. disabling NAT-PMP");
|
||||
"IPv4 address. disabling UPnP");
|
||||
}
|
||||
|
||||
m_local_ip = i->endpoint().address().to_v4();
|
||||
|
|
Loading…
Reference in New Issue