update right ipv6 only

This commit is contained in:
orignal 2021-02-01 12:47:41 -05:00
parent fef4f13b8f
commit ea19802d3f
2 changed files with 4 additions and 1 deletions

View File

@ -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)
{ {

View File

@ -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);
} }
} }