mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-10 11:28:27 +01:00
publish/unpublish NTCP2 address depending on network status
This commit is contained in:
parent
61d84dd4c1
commit
685f45bd76
1 changed files with 4 additions and 4 deletions
|
@ -180,7 +180,7 @@ namespace i2p
|
||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterContext::PublishNTCP2Address (int port, bool publish)
|
void RouterContext::PublishNTCP2Address (int port, bool publish, bool v4only)
|
||||||
{
|
{
|
||||||
if (!m_NTCP2Keys) return;
|
if (!m_NTCP2Keys) return;
|
||||||
if (!port)
|
if (!port)
|
||||||
|
@ -191,7 +191,7 @@ namespace i2p
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
for (auto& address : m_RouterInfo.GetAddresses ())
|
for (auto& address : m_RouterInfo.GetAddresses ())
|
||||||
{
|
{
|
||||||
if (address->IsNTCP2 () && (address->port != port || address->ntcp2->isPublished != publish))
|
if (address->IsNTCP2 () && (address->port != port || address->ntcp2->isPublished != publish) && (!v4only || address->host.is_v4 ()))
|
||||||
{
|
{
|
||||||
address->port = port;
|
address->port = port;
|
||||||
address->cost = publish ? 3 : 14;
|
address->cost = publish ? 3 : 14;
|
||||||
|
@ -438,7 +438,7 @@ namespace i2p
|
||||||
{
|
{
|
||||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
if (ntcp2)
|
if (ntcp2)
|
||||||
PublishNTCP2Address (port, false);
|
PublishNTCP2Address (port, false, true);
|
||||||
}
|
}
|
||||||
// update
|
// update
|
||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
|
@ -478,7 +478,7 @@ namespace i2p
|
||||||
{
|
{
|
||||||
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
|
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
|
||||||
if (!ntcp2Port) ntcp2Port = port;
|
if (!ntcp2Port) ntcp2Port = port;
|
||||||
PublishNTCP2Address (ntcp2Port, true);
|
PublishNTCP2Address (ntcp2Port, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue