mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 19:27:49 +02:00
verify IP and netid only when RI parsed
This commit is contained in:
parent
a8984ad726
commit
c7debcf6ec
3 changed files with 5 additions and 12 deletions
|
@ -212,10 +212,10 @@ namespace data
|
|||
if (!ecode)
|
||||
{
|
||||
#if BOOST_VERSION >= 104900
|
||||
if (!hostaddr.is_unspecified () && !i2p::util::net::IsInReservedRange(hostaddr)) // check if address is valid
|
||||
if (!hostaddr.is_unspecified () && ((i2p::context.GetNetID () != I2PD_NET_ID) || !i2p::util::net::IsInReservedRange(hostaddr)))
|
||||
#else
|
||||
hostaddr.to_string (ecode);
|
||||
if (!ecode && !i2p::util::net::IsInReservedRange(hostaddr))
|
||||
if (!ecode && ((i2p::context.GetNetID () != I2PD_NET_ID) || !i2p::util::net::IsInReservedRange(hostaddr)))
|
||||
#endif
|
||||
{
|
||||
address->host = hostaddr;
|
||||
|
|
|
@ -406,7 +406,7 @@ namespace transport
|
|||
{
|
||||
peer.numAttempts++;
|
||||
auto address = peer.router->GetNTCP2Address (true, !context.SupportsV6 ()); // published only
|
||||
if (address && m_NTCP2Server && !i2p::util::net::IsInReservedRange(address->host))
|
||||
if (address && m_NTCP2Server)
|
||||
{ // we support NTCP2, it has priority over NTCP and remote address is not in reserved range
|
||||
auto s = std::make_shared<NTCP2Session> (*m_NTCP2Server, peer.router);
|
||||
m_NTCP2Server->Connect (address->host, address->port, s);
|
||||
|
@ -417,7 +417,7 @@ namespace transport
|
|||
{
|
||||
peer.numAttempts++;
|
||||
auto address = peer.router->GetNTCPAddress (!context.SupportsV6 ());
|
||||
if (address && m_NTCPServer && !i2p::util::net::IsInReservedRange(address->host))
|
||||
if (address && m_NTCPServer)
|
||||
{
|
||||
if (!peer.router->UsesIntroducer () && !peer.router->IsUnreachable ())
|
||||
{
|
||||
|
@ -451,7 +451,7 @@ namespace transport
|
|||
{
|
||||
peer.numAttempts++;
|
||||
auto address = peer.router->GetSSUAddress (!context.SupportsV6 ());
|
||||
if (address && m_SSUServer && !i2p::util::net::IsInReservedRange(address->host))
|
||||
if (address && m_SSUServer)
|
||||
{
|
||||
m_SSUServer->CreateSession (peer.router, address->host, address->port);
|
||||
return true;
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
#include <boost/asio.hpp>
|
||||
|
||||
#include "util.h"
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
#include "version.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <stdlib.h>
|
||||
|
@ -346,11 +344,6 @@ namespace net
|
|||
}
|
||||
|
||||
bool IsInReservedRange(const boost::asio::ip::address& host) {
|
||||
// ignore checking for netid other than main network
|
||||
int NetID; i2p::config::GetOption("netid", NetID);
|
||||
if (NetID != I2PD_NET_ID)
|
||||
return false;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Reserved_IP_addresses
|
||||
if(host.is_v4())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue