handle 'reservedrange' param properly

This commit is contained in:
orignal 2024-01-11 15:39:42 -05:00
parent 2ad26dd4c9
commit ca9782dd0d
8 changed files with 36 additions and 31 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2023, The PurpleI2P Project
* Copyright (c) 2013-2024, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@ -505,7 +505,7 @@ namespace transport
if (!m_NTCP2Server) continue;
std::shared_ptr<const RouterInfo::Address> address = (tr == i2p::data::RouterInfo::eNTCP2V6) ?
peer.router->GetPublishedNTCP2V6Address () : peer.router->GetPublishedNTCP2V4Address ();
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
if (address && IsInReservedRange(address->host))
address = nullptr;
if (address)
{
@ -524,7 +524,7 @@ namespace transport
if (!m_SSU2Server) continue;
std::shared_ptr<const RouterInfo::Address> address = (tr == i2p::data::RouterInfo::eSSU2V6) ?
peer.router->GetSSU2V6Address () : peer.router->GetSSU2V4Address ();
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
if (address && IsInReservedRange(address->host))
address = nullptr;
if (address && address->IsReachableSSU ())
{
@ -1084,6 +1084,11 @@ namespace transport
}
}
bool Transports::IsInReservedRange (const boost::asio::ip::address& host) const
{
return IsCheckReserved () && i2p::util::net::IsInReservedRange (host);
}
void InitAddressFromIface ()
{
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
@ -1196,6 +1201,8 @@ namespace transport
i2p::context.PublishSSU2Address (ssu2port, false, ipv4, ipv6); // unpublish
}
bool checkReserved; i2p::config::GetOption("reservedrange", checkReserved);
transports.SetCheckReserved (checkReserved);
}
}
}