mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-31 13:14:13 +00:00
alsways set some port to SSU2 address
This commit is contained in:
parent
d10c86b849
commit
81f53d313c
@ -373,14 +373,26 @@ namespace i2p
|
|||||||
|
|
||||||
void RouterContext::PublishSSU2Address (int port, bool publish, bool v4, bool v6)
|
void RouterContext::PublishSSU2Address (int port, bool publish, bool v4, bool v6)
|
||||||
{
|
{
|
||||||
if (!m_SSU2Keys || (publish && !port)) return;
|
if (!m_SSU2Keys) return;
|
||||||
|
int newPort = 0;
|
||||||
|
if (!port)
|
||||||
|
{
|
||||||
|
for (const auto& address : m_RouterInfo.GetAddresses ())
|
||||||
|
if (address->port)
|
||||||
|
{
|
||||||
|
newPort = address->port;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!newPort) newPort = SelectRandomPort ();
|
||||||
|
}
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
for (auto& address : m_RouterInfo.GetAddresses ())
|
for (auto& address : m_RouterInfo.GetAddresses ())
|
||||||
{
|
{
|
||||||
if (address->IsSSU2 () && (address->port != port || address->published != publish) &&
|
if (address->IsSSU2 () && (!address->port || address->port != port || address->published != publish) &&
|
||||||
((v4 && address->IsV4 ()) || (v6 && address->IsV6 ())))
|
((v4 && address->IsV4 ()) || (v6 && address->IsV6 ())))
|
||||||
{
|
{
|
||||||
address->port = port;
|
if (port) address->port = port;
|
||||||
|
else if (!address->port) address->port = newPort;
|
||||||
address->published = publish;
|
address->published = publish;
|
||||||
if (publish)
|
if (publish)
|
||||||
address->caps |= (i2p::data::RouterInfo::eSSUIntroducer | i2p::data::RouterInfo::eSSUTesting);
|
address->caps |= (i2p::data::RouterInfo::eSSUIntroducer | i2p::data::RouterInfo::eSSUTesting);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user