changed to tabs, move tor port to function

This commit is contained in:
weko 2023-02-14 20:03:04 +03:00
parent 9e0c5d67c7
commit 76d39cc7c9
3 changed files with 19 additions and 19 deletions

View File

@ -204,12 +204,11 @@ namespace i2p
{ {
uint16_t port; uint16_t port;
do do
{ {
port = rand () % (30777 - 9111) + 9111; // I2P network ports range port = rand () % (30777 - 9111) + 9111; // I2P network ports range
} }
while(i2p::util::net::IsPortInReservedRange(port)); while(i2p::util::net::IsPortInReservedRange(port));
if (port == 9150) port = 9151; // Tor browser
return port; return port;
} }

View File

@ -488,20 +488,21 @@ namespace net
return IsYggdrasilAddress (addr.to_v6 ().to_bytes ().data ()); return IsYggdrasilAddress (addr.to_v6 ().to_bytes ().data ());
} }
bool IsPortInReservedRange (const uint16_t port) noexcept bool IsPortInReservedRange (const uint16_t port) noexcept
{ {
static const std::unordered_set<uint16_t> reservedPorts{ // https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers (Feb. 3, 2023) + Tor browser (9150)
9119,9306,9312,9389,9418,9535,9536,9695, static const std::unordered_set<uint16_t> reservedPorts{
9800,9899,10000,10050,10051,10110,10212, 9119,9150,9306,9312,9389,9418,9535,9536,9695,
10933,11001,11112,11235,11371,12222,12223, 9800,9899,10000,10050,10051,10110,10212,
13075,13400,13720,13721,13724,13782,13783, 10933,11001,11112,11235,11371,12222,12223,
13785,13786,15345,17224,17225,17500,18104, 13075,13400,13720,13721,13724,13782,13783,
19788,19812,19813,19814,19999,20000,24465, 13785,13786,15345,17224,17225,17500,18104,
24554,26000,27000,27001,27002,27003,27004, 19788,19812,19813,19814,19999,20000,24465,
27005,27006,27007,27008,27009,28000}; 24554,26000,27000,27001,27002,27003,27004,
27005,27006,27007,27008,27009,28000};
return (reservedPorts.find(port) != reservedPorts.end()); return (reservedPorts.find(port) != reservedPorts.end());
} }
boost::asio::ip::address_v6 GetYggdrasilAddress () boost::asio::ip::address_v6 GetYggdrasilAddress ()
{ {

View File

@ -224,7 +224,7 @@ namespace util
bool IsLocalAddress (const boost::asio::ip::address& addr); 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);
bool IsPortInReservedRange (const uint16_t port) noexcept; bool IsPortInReservedRange (const uint16_t port) noexcept;
} }
} }
} }