|
|
@ -971,10 +971,10 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!IsV6 ()) |
|
|
|
if (!IsV6 ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_SupportedTransports |= eSSUV6 | eNTCP2V6; |
|
|
|
|
|
|
|
uint8_t addressCaps = AddressCaps::eV6; |
|
|
|
uint8_t addressCaps = AddressCaps::eV6; |
|
|
|
if (IsV4 ()) addressCaps |= AddressCaps::eV4; |
|
|
|
if (IsV4 ()) addressCaps |= AddressCaps::eV4; |
|
|
|
SetUnreachableAddressesTransportCaps (addressCaps); |
|
|
|
SetUnreachableAddressesTransportCaps (addressCaps); |
|
|
|
|
|
|
|
UpdateSupportedTransports (); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -982,10 +982,10 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!IsV4 ()) |
|
|
|
if (!IsV4 ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_SupportedTransports |= eSSUV4 | eNTCP2V4; |
|
|
|
|
|
|
|
uint8_t addressCaps = AddressCaps::eV4; |
|
|
|
uint8_t addressCaps = AddressCaps::eV4; |
|
|
|
if (IsV6 ()) addressCaps |= AddressCaps::eV6; |
|
|
|
if (IsV6 ()) addressCaps |= AddressCaps::eV6; |
|
|
|
SetUnreachableAddressesTransportCaps (addressCaps); |
|
|
|
SetUnreachableAddressesTransportCaps (addressCaps); |
|
|
|
|
|
|
|
UpdateSupportedTransports (); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -994,7 +994,6 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (IsV6 ()) |
|
|
|
if (IsV6 ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_SupportedTransports &= ~(eSSUV6 | eNTCP2V6); |
|
|
|
|
|
|
|
for (auto it = m_Addresses->begin (); it != m_Addresses->end ();) |
|
|
|
for (auto it = m_Addresses->begin (); it != m_Addresses->end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto addr = *it; |
|
|
|
auto addr = *it; |
|
|
@ -1011,6 +1010,7 @@ namespace data |
|
|
|
else |
|
|
|
else |
|
|
|
++it; |
|
|
|
++it; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
UpdateSupportedTransports (); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1018,7 +1018,6 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (IsV4 ()) |
|
|
|
if (IsV4 ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_SupportedTransports &= ~(eSSUV4 | eNTCP2V4); |
|
|
|
|
|
|
|
for (auto it = m_Addresses->begin (); it != m_Addresses->end ();) |
|
|
|
for (auto it = m_Addresses->begin (); it != m_Addresses->end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto addr = *it; |
|
|
|
auto addr = *it; |
|
|
@ -1035,13 +1034,17 @@ namespace data |
|
|
|
else |
|
|
|
else |
|
|
|
++it; |
|
|
|
++it; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
UpdateSupportedTransports (); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RouterInfo::EnableMesh () |
|
|
|
void RouterInfo::EnableMesh () |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!IsMesh ()) |
|
|
|
if (!IsMesh ()) |
|
|
|
|
|
|
|
{ |
|
|
|
m_SupportedTransports |= eNTCP2V6Mesh; |
|
|
|
m_SupportedTransports |= eNTCP2V6Mesh; |
|
|
|
|
|
|
|
m_ReachableTransports |= eNTCP2V6Mesh; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RouterInfo::DisableMesh () |
|
|
|
void RouterInfo::DisableMesh () |
|
|
@ -1049,6 +1052,7 @@ namespace data |
|
|
|
if (IsMesh ()) |
|
|
|
if (IsMesh ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_SupportedTransports &= ~eNTCP2V6Mesh; |
|
|
|
m_SupportedTransports &= ~eNTCP2V6Mesh; |
|
|
|
|
|
|
|
m_ReachableTransports &= ~eNTCP2V6Mesh; |
|
|
|
for (auto it = m_Addresses->begin (); it != m_Addresses->end ();) |
|
|
|
for (auto it = m_Addresses->begin (); it != m_Addresses->end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto addr = *it; |
|
|
|
auto addr = *it; |
|
|
@ -1177,24 +1181,7 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
bool RouterInfo::IsReachableFrom (const RouterInfo& other) const |
|
|
|
bool RouterInfo::IsReachableFrom (const RouterInfo& other) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto commonTransports = m_SupportedTransports & other.m_SupportedTransports; |
|
|
|
return m_ReachableTransports & other.m_SupportedTransports; |
|
|
|
if (!commonTransports) return false; |
|
|
|
|
|
|
|
if (commonTransports & eNTCP2V6Mesh) return true; |
|
|
|
|
|
|
|
return (bool)GetAddress ( |
|
|
|
|
|
|
|
[commonTransports](std::shared_ptr<const RouterInfo::Address> address)->bool |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (address->IsPublishedNTCP2 ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ((commonTransports & eNTCP2V4) && address->IsV4 ()) return true; |
|
|
|
|
|
|
|
if ((commonTransports & eNTCP2V6) && address->IsV6 ()) return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (address->IsReachableSSU ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ((commonTransports & eSSUV4) && address->IsV4 ()) return true; |
|
|
|
|
|
|
|
if ((commonTransports & eSSUV6) && address->IsV6 ()) return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RouterInfo::SetUnreachableAddressesTransportCaps (uint8_t transports) |
|
|
|
void RouterInfo::SetUnreachableAddressesTransportCaps (uint8_t transports) |
|
|
|