|
|
|
@ -420,8 +420,12 @@ namespace i2p
@@ -420,8 +420,12 @@ namespace i2p
|
|
|
|
|
if (address->host != host && address->IsCompatible (host) && |
|
|
|
|
!i2p::util::net::IsYggdrasilAddress (address->host)) |
|
|
|
|
{ |
|
|
|
|
// update host
|
|
|
|
|
address->host = host; |
|
|
|
|
if (host.is_v6 () && (address->transportStyle == i2p::data::RouterInfo::eTransportSSU || address->IsSSU2 ())) |
|
|
|
|
updated = true; |
|
|
|
|
} |
|
|
|
|
if (host.is_v6 () && address->IsV6 () && address->ssu && |
|
|
|
|
(!address->ssu->mtu || updated)) |
|
|
|
|
{ |
|
|
|
|
// update MTU
|
|
|
|
|
auto mtu = i2p::util::net::GetMTU (host); |
|
|
|
@ -436,12 +440,11 @@ namespace i2p
@@ -436,12 +440,11 @@ namespace i2p
|
|
|
|
|
} |
|
|
|
|
if (mtu && !address->IsSSU2 ()) // SSU1
|
|
|
|
|
mtu = (mtu >> 4) << 4; // round to multiple of 16
|
|
|
|
|
if (address->ssu) address->ssu->mtu = mtu; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
address->ssu->mtu = mtu; |
|
|
|
|
updated = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
auto ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
|
if (updated || ts > m_LastUpdateTime + ROUTER_INFO_UPDATE_INTERVAL) |
|
|
|
|
UpdateRouterInfo (); |
|
|
|
@ -866,6 +869,43 @@ namespace i2p
@@ -866,6 +869,43 @@ namespace i2p
|
|
|
|
|
UpdateRouterInfo (); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RouterContext::SetMTU (int mtu, bool v4) |
|
|
|
|
{ |
|
|
|
|
if (mtu < 1280 || mtu > 1500) return; |
|
|
|
|
auto& addresses = m_RouterInfo.GetAddresses (); |
|
|
|
|
for (auto& addr: addresses) |
|
|
|
|
{ |
|
|
|
|
if (addr->ssu && ((v4 && addr->IsV4 ()) || (!v4 && addr->IsV6 ()))) |
|
|
|
|
{ |
|
|
|
|
if (!addr->IsSSU2 ()) // SSU1
|
|
|
|
|
{ |
|
|
|
|
// round to multiple of 16
|
|
|
|
|
if (v4) |
|
|
|
|
{ |
|
|
|
|
if (mtu > 1484) mtu = 1484; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
mtu -= 12; |
|
|
|
|
mtu = (mtu >> 4) << 4; |
|
|
|
|
mtu += 12; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (mtu > 1488) mtu = 1488; |
|
|
|
|
else |
|
|
|
|
mtu = (mtu >> 4) << 4; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (mtu) |
|
|
|
|
{ |
|
|
|
|
addr->ssu->mtu = mtu; |
|
|
|
|
LogPrint (eLogDebug, "Router: MTU for ", v4 ? "ipv4" : "ipv6", " address is set to ", mtu); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RouterContext::UpdateNTCP2V6Address (const boost::asio::ip::address& host) |
|
|
|
|
{ |
|
|
|
|
bool isYgg = i2p::util::net::IsYggdrasilAddress (host); |
|
|
|
|