From ed4c00e4f4e662d9b3faa40de9a2fa99c265dc3f Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 24 Jan 2021 21:21:35 -0500 Subject: [PATCH] check yggdrasil ipv6 range --- libi2pd/util.cpp | 5 ++++- libi2pd/util.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libi2pd/util.cpp b/libi2pd/util.cpp index bb3f60d1..123d233c 100644 --- a/libi2pd/util.cpp +++ b/libi2pd/util.cpp @@ -446,7 +446,8 @@ namespace net #endif } - bool IsInReservedRange (const boost::asio::ip::address& host) { + bool IsInReservedRange (const boost::asio::ip::address& host, bool checkYggdrasil) + { // https://en.wikipedia.org/wiki/Reserved_IP_addresses if(host.is_v4()) { @@ -486,6 +487,8 @@ namespace net if (ipv6_address >= it.first && ipv6_address <= it.second) return true; } + if (checkYggdrasil && (ipv6_address[0] == 0x02 || ipv6_address[0] == 0x03)) // yggdrasil? + return true; } return false; } diff --git a/libi2pd/util.h b/libi2pd/util.h index 7a45dc9b..fedab8e1 100644 --- a/libi2pd/util.h +++ b/libi2pd/util.h @@ -189,7 +189,7 @@ namespace util int GetMTU (const boost::asio::ip::address& localAddress); const boost::asio::ip::address GetInterfaceAddress (const std::string & ifname, bool ipv6=false); boost::asio::ip::address_v6 GetYggdrasilAddress (); - bool IsInReservedRange (const boost::asio::ip::address& host); + bool IsInReservedRange (const boost::asio::ip::address& host, bool checkYggdrasil = true); } } }