mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
check local address
This commit is contained in:
parent
05c7aacfa5
commit
a74f685a5d
@ -152,7 +152,8 @@ namespace i2p
|
|||||||
if (!yggaddress.empty ())
|
if (!yggaddress.empty ())
|
||||||
{
|
{
|
||||||
yggaddr = boost::asio::ip::address_v6::from_string (yggaddress);
|
yggaddr = boost::asio::ip::address_v6::from_string (yggaddress);
|
||||||
if (yggaddr.is_unspecified () || i2p::util::net::GetMTU (yggaddr) != 0xFFFF) // ygg's MTU is always 65535
|
if (yggaddr.is_unspecified () || !i2p::util::net::IsYggdrasilAddress (yggaddr) ||
|
||||||
|
!i2p::util::net::IsLocalAddress (yggaddr))
|
||||||
{
|
{
|
||||||
LogPrint(eLogWarning, "Daemon: Can't find Yggdrasil address ", yggaddress);
|
LogPrint(eLogWarning, "Daemon: Can't find Yggdrasil address ", yggaddress);
|
||||||
ygg = false;
|
ygg = false;
|
||||||
|
@ -461,6 +461,17 @@ namespace net
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsLocalAddress (const boost::asio::ip::address& addr)
|
||||||
|
{
|
||||||
|
auto mtu = // TODO: implement better
|
||||||
|
#ifdef _WIN32
|
||||||
|
GetMTUWindows(addr, 0);
|
||||||
|
#else
|
||||||
|
GetMTUUnix(addr, 0);
|
||||||
|
#endif
|
||||||
|
return mtu > 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsInReservedRange (const boost::asio::ip::address& host)
|
bool IsInReservedRange (const boost::asio::ip::address& host)
|
||||||
{
|
{
|
||||||
// https://en.wikipedia.org/wiki/Reserved_IP_addresses
|
// https://en.wikipedia.org/wiki/Reserved_IP_addresses
|
||||||
|
@ -189,6 +189,7 @@ namespace util
|
|||||||
int GetMTU (const boost::asio::ip::address& localAddress);
|
int GetMTU (const boost::asio::ip::address& localAddress);
|
||||||
const boost::asio::ip::address GetInterfaceAddress (const std::string & ifname, bool ipv6=false);
|
const boost::asio::ip::address GetInterfaceAddress (const std::string & ifname, bool ipv6=false);
|
||||||
boost::asio::ip::address_v6 GetYggdrasilAddress ();
|
boost::asio::ip::address_v6 GetYggdrasilAddress ();
|
||||||
|
bool IsLocalAddress (const boost::asio::ip::address& addr);
|
||||||
bool IsInReservedRange (const boost::asio::ip::address& host);
|
bool IsInReservedRange (const boost::asio::ip::address& host);
|
||||||
bool IsYggdrasilAddress (const boost::asio::ip::address& addr);
|
bool IsYggdrasilAddress (const boost::asio::ip::address& addr);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user