mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-23 09:14:13 +00:00
ssu2.mtu4 and ssu2.mtu6
This commit is contained in:
parent
4ed4e8708e
commit
e13f151474
@ -277,6 +277,8 @@ namespace config {
|
|||||||
("ssu2.enabled", value<bool>()->default_value(true), "Enable SSU2 (default: enabled)")
|
("ssu2.enabled", value<bool>()->default_value(true), "Enable SSU2 (default: enabled)")
|
||||||
("ssu2.published", value<bool>()->default_value(true), "Publish SSU2 (default: enabled)")
|
("ssu2.published", value<bool>()->default_value(true), "Publish SSU2 (default: enabled)")
|
||||||
("ssu2.port", value<uint16_t>()->default_value(0), "Port to listen for incoming SSU2 packets (default: auto)")
|
("ssu2.port", value<uint16_t>()->default_value(0), "Port to listen for incoming SSU2 packets (default: auto)")
|
||||||
|
("ssu2.mtu4", value<uint16_t>()->default_value(0), "MTU for ipv4 address (default: detect)")
|
||||||
|
("ssu2.mtu6", value<uint16_t>()->default_value(0), "MTU for ipv6 address (default: detect)")
|
||||||
("ssu2.proxy", value<std::string>()->default_value(""), "Socks5 proxy URL for SSU2 transport")
|
("ssu2.proxy", value<std::string>()->default_value(""), "Socks5 proxy URL for SSU2 transport")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -46,9 +46,19 @@ namespace transport
|
|||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
if (address->IsV6 ())
|
if (address->IsV6 ())
|
||||||
i2p::context.SetMTU (SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV6_REQUEST_HEADER_SIZE, false);
|
{
|
||||||
|
uint16_t mtu; i2p::config::GetOption ("ssu2.mtu6", mtu);
|
||||||
|
if (!mtu || mtu > SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV6_REQUEST_HEADER_SIZE)
|
||||||
|
mtu = SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV6_REQUEST_HEADER_SIZE;
|
||||||
|
i2p::context.SetMTU (mtu, false);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
i2p::context.SetMTU (SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV4_REQUEST_HEADER_SIZE, true);
|
{
|
||||||
|
uint16_t mtu; i2p::config::GetOption ("ssu2.mtu4", mtu);
|
||||||
|
if (!mtu || mtu > SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV4_REQUEST_HEADER_SIZE)
|
||||||
|
mtu = SSU2_MAX_PACKET_SIZE - SOCKS5_UDP_IPV4_REQUEST_HEADER_SIZE;
|
||||||
|
i2p::context.SetMTU (mtu, true);
|
||||||
|
}
|
||||||
continue; // we don't need port for proxy
|
continue; // we don't need port for proxy
|
||||||
}
|
}
|
||||||
auto port = address->port;
|
auto port = address->port;
|
||||||
@ -147,7 +157,8 @@ namespace transport
|
|||||||
if (localAddress.is_v4 ())
|
if (localAddress.is_v4 ())
|
||||||
{
|
{
|
||||||
m_AddressV4 = localAddress;
|
m_AddressV4 = localAddress;
|
||||||
int mtu = i2p::util::net::GetMTU (localAddress);
|
uint16_t mtu; i2p::config::GetOption ("ssu2.mtu4", mtu);
|
||||||
|
if (!mtu) mtu = i2p::util::net::GetMTU (localAddress);
|
||||||
if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
|
if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
|
||||||
if (mtu > (int)SSU2_MAX_PACKET_SIZE) mtu = SSU2_MAX_PACKET_SIZE;
|
if (mtu > (int)SSU2_MAX_PACKET_SIZE) mtu = SSU2_MAX_PACKET_SIZE;
|
||||||
i2p::context.SetMTU (mtu, true);
|
i2p::context.SetMTU (mtu, true);
|
||||||
@ -155,9 +166,15 @@ namespace transport
|
|||||||
else if (localAddress.is_v6 ())
|
else if (localAddress.is_v6 ())
|
||||||
{
|
{
|
||||||
m_AddressV6 = localAddress;
|
m_AddressV6 = localAddress;
|
||||||
int maxMTU = i2p::util::net::GetMaxMTU (localAddress.to_v6 ());
|
uint16_t mtu; i2p::config::GetOption ("ssu2.mtu6", mtu);
|
||||||
int mtu = i2p::util::net::GetMTU (localAddress);
|
if (!mtu)
|
||||||
if (mtu > maxMTU) mtu = maxMTU;
|
{
|
||||||
|
int maxMTU = i2p::util::net::GetMaxMTU (localAddress.to_v6 ());
|
||||||
|
mtu = i2p::util::net::GetMTU (localAddress);
|
||||||
|
if (mtu > maxMTU) mtu = maxMTU;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (mtu > (int)SSU2_MAX_PACKET_SIZE) mtu = SSU2_MAX_PACKET_SIZE;
|
||||||
if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
|
if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
|
||||||
i2p::context.SetMTU (mtu, false);
|
i2p::context.SetMTU (mtu, false);
|
||||||
}
|
}
|
||||||
|
@ -259,6 +259,17 @@ namespace transport
|
|||||||
if (m_SSU2Server) m_SSU2Server->SetLocalAddress (addr);
|
if (m_SSU2Server) m_SSU2Server->SetLocalAddress (addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enableSSU2)
|
||||||
|
{
|
||||||
|
uint16_t mtu; i2p::config::GetOption ("ssu2.mtu4", mtu);
|
||||||
|
if (mtu)
|
||||||
|
{
|
||||||
|
if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
|
||||||
|
if (mtu > (int)SSU2_MAX_PACKET_SIZE) mtu = SSU2_MAX_PACKET_SIZE;
|
||||||
|
i2p::context.SetMTU (mtu, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipv6)
|
if (ipv6)
|
||||||
@ -275,6 +286,17 @@ namespace transport
|
|||||||
if (m_SSU2Server) m_SSU2Server->SetLocalAddress (addr);
|
if (m_SSU2Server) m_SSU2Server->SetLocalAddress (addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enableSSU2)
|
||||||
|
{
|
||||||
|
uint16_t mtu; i2p::config::GetOption ("ssu2.mtu6", mtu);
|
||||||
|
if (mtu)
|
||||||
|
{
|
||||||
|
if (mtu < (int)SSU2_MIN_PACKET_SIZE) mtu = SSU2_MIN_PACKET_SIZE;
|
||||||
|
if (mtu > (int)SSU2_MAX_PACKET_SIZE) mtu = SSU2_MAX_PACKET_SIZE;
|
||||||
|
i2p::context.SetMTU (mtu, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
|
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user