Don't use reversed port for choise random port. (by whothefuckami)

This commit is contained in:
weko 2023-02-14 14:58:11 +03:00
parent 03111ad0df
commit 9e0c5d67c7
3 changed files with 24 additions and 1 deletions

View file

@ -202,7 +202,13 @@ namespace i2p
uint16_t RouterContext::SelectRandomPort () const
{
uint16_t port = rand () % (30777 - 9111) + 9111; // I2P network ports range
uint16_t port;
do
{
port = rand () % (30777 - 9111) + 9111; // I2P network ports range
}
while(i2p::util::net::IsPortInReservedRange(port));
if (port == 9150) port = 9151; // Tor browser
return port;
}