mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
detect MTU for some known ipv6 tunnel brokers
This commit is contained in:
parent
14a6947b02
commit
014e4b0e1d
|
@ -428,13 +428,13 @@ namespace i2p
|
|||
if (mtu)
|
||||
{
|
||||
LogPrint (eLogDebug, "Router: Our v6 MTU=", mtu);
|
||||
int maxMTU = address->IsSSU2 () ? 1500 : 1488; // must be multiple of 16 for SSU1
|
||||
int maxMTU = i2p::util::net::GetMaxMTU (host.to_v6 ());
|
||||
if (mtu > maxMTU)
|
||||
{
|
||||
mtu = maxMTU;
|
||||
LogPrint(eLogWarning, "Router: MTU dropped to upper limit of ", maxMTU, " bytes");
|
||||
}
|
||||
else if (mtu && !address->IsSSU2 ()) // SSU1
|
||||
if (mtu && !address->IsSSU2 ()) // SSU1
|
||||
mtu = (mtu >> 4) << 4; // round to multiple of 16
|
||||
if (address->ssu) address->ssu->mtu = mtu;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "util.h"
|
||||
#include "Log.h"
|
||||
#include "I2PEndian.h"
|
||||
|
||||
#if not defined (__FreeBSD__)
|
||||
#include <pthread.h>
|
||||
|
@ -423,6 +424,25 @@ namespace net
|
|||
#endif
|
||||
}
|
||||
|
||||
int GetMaxMTU (const boost::asio::ip::address_v6& localAddress)
|
||||
{
|
||||
uint32_t prefix = bufbe32toh (localAddress.to_bytes ().data ());
|
||||
switch (prefix)
|
||||
{
|
||||
case 0x20010470:
|
||||
case 0x260070ff:
|
||||
// Hurricane Electric
|
||||
return 1480;
|
||||
break;
|
||||
case 0x2a06a004:
|
||||
// route48
|
||||
return 1420;
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
return 1500;
|
||||
}
|
||||
|
||||
static bool IsYggdrasilAddress (const uint8_t addr[16])
|
||||
{
|
||||
return addr[0] == 0x02 || addr[0] == 0x03;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2021, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
|
@ -218,6 +218,7 @@ namespace util
|
|||
namespace net
|
||||
{
|
||||
int GetMTU (const boost::asio::ip::address& localAddress);
|
||||
int GetMaxMTU (const boost::asio::ip::address_v6& localAddress); // check tunnel broker for ipv6 address
|
||||
const boost::asio::ip::address GetInterfaceAddress (const std::string & ifname, bool ipv6=false);
|
||||
boost::asio::ip::address_v6 GetYggdrasilAddress ();
|
||||
bool IsLocalAddress (const boost::asio::ip::address& addr);
|
||||
|
|
Loading…
Reference in a new issue