Browse Source

update right ipv6 only

pull/1634/head
orignal 4 years ago
parent
commit
ea19802d3f
  1. 4
      libi2pd/RouterContext.cpp
  2. 1
      libi2pd/util.cpp

4
libi2pd/RouterContext.cpp

@ -550,13 +550,15 @@ namespace i2p
void RouterContext::UpdateNTCP2V6Address (const boost::asio::ip::address& host) void RouterContext::UpdateNTCP2V6Address (const boost::asio::ip::address& host)
{ {
bool isYgg = i2p::util::net::IsYggdrasilAddress (host);
bool updated = false; bool updated = false;
auto& addresses = m_RouterInfo.GetAddresses (); auto& addresses = m_RouterInfo.GetAddresses ();
for (auto& addr: addresses) for (auto& addr: addresses)
{ {
if (addr->IsPublishedNTCP2 ()) if (addr->IsPublishedNTCP2 ())
{ {
if (addr->host.is_v6 ()) bool isYgg1 = i2p::util::net::IsYggdrasilAddress (addr->host);
if (addr->host.is_v6 () && ((isYgg && isYgg1) || (!isYgg && !isYgg1)))
{ {
if (addr->host != host) if (addr->host != host)
{ {

1
libi2pd/util.cpp

@ -449,6 +449,7 @@ namespace net
{ {
boost::asio::ip::address_v6::bytes_type bytes; boost::asio::ip::address_v6::bytes_type bytes;
memcpy (bytes.data (), &sa->sin6_addr, 16); memcpy (bytes.data (), &sa->sin6_addr, 16);
freeifaddrs(addrs);
return boost::asio::ip::address_v6 (bytes); return boost::asio::ip::address_v6 (bytes);
} }
} }

Loading…
Cancel
Save