mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-08 18:47:52 +00:00
publish/unpublish NTCP2 address depending on network status
This commit is contained in:
parent
fbb8903774
commit
4d10593bb1
@ -421,13 +421,25 @@ namespace i2p
|
|||||||
caps &= ~i2p::data::RouterInfo::eFloodfill; // can't be floodfill
|
caps &= ~i2p::data::RouterInfo::eFloodfill; // can't be floodfill
|
||||||
caps &= ~i2p::data::RouterInfo::eSSUIntroducer; // can't be introducer
|
caps &= ~i2p::data::RouterInfo::eSSUIntroducer; // can't be introducer
|
||||||
m_RouterInfo.SetCaps (caps);
|
m_RouterInfo.SetCaps (caps);
|
||||||
// remove NTCP v4 address
|
uint16_t port = 0;
|
||||||
PublishNTCPAddress (false);
|
|
||||||
// delete previous introducers
|
// delete previous introducers
|
||||||
auto& addresses = m_RouterInfo.GetAddresses ();
|
auto& addresses = m_RouterInfo.GetAddresses ();
|
||||||
for (auto& addr : addresses)
|
for (auto& addr : addresses)
|
||||||
if (addr->ssu)
|
if (addr->ssu)
|
||||||
|
{
|
||||||
addr->ssu->introducers.clear ();
|
addr->ssu->introducers.clear ();
|
||||||
|
port = addr->port;
|
||||||
|
}
|
||||||
|
// remove NTCP or NTCP2 v4 address
|
||||||
|
bool ntcp; i2p::config::GetOption("ntcp", ntcp);
|
||||||
|
if (ntcp)
|
||||||
|
PublishNTCPAddress (false);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
|
if (ntcp2)
|
||||||
|
PublishNTCP2Address (port, false);
|
||||||
|
}
|
||||||
// update
|
// update
|
||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
}
|
}
|
||||||
@ -442,15 +454,34 @@ namespace i2p
|
|||||||
if (m_IsFloodfill)
|
if (m_IsFloodfill)
|
||||||
caps |= i2p::data::RouterInfo::eFloodfill;
|
caps |= i2p::data::RouterInfo::eFloodfill;
|
||||||
m_RouterInfo.SetCaps (caps);
|
m_RouterInfo.SetCaps (caps);
|
||||||
// insert NTCP back
|
uint16_t port = 0;
|
||||||
bool ntcp; i2p::config::GetOption("ntcp", ntcp);
|
|
||||||
if (ntcp)
|
|
||||||
PublishNTCPAddress (true);
|
|
||||||
// delete previous introducers
|
// delete previous introducers
|
||||||
auto& addresses = m_RouterInfo.GetAddresses ();
|
auto& addresses = m_RouterInfo.GetAddresses ();
|
||||||
for (auto& addr : addresses)
|
for (auto& addr : addresses)
|
||||||
if (addr->ssu)
|
if (addr->ssu)
|
||||||
|
{
|
||||||
addr->ssu->introducers.clear ();
|
addr->ssu->introducers.clear ();
|
||||||
|
port = addr->port;
|
||||||
|
}
|
||||||
|
// insert NTCP or NTCP2 back
|
||||||
|
bool ntcp; i2p::config::GetOption("ntcp", ntcp);
|
||||||
|
if (ntcp)
|
||||||
|
PublishNTCPAddress (true);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ntcp2
|
||||||
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
|
if (ntcp2)
|
||||||
|
{
|
||||||
|
bool published; i2p::config::GetOption ("ntcp2.published", published);
|
||||||
|
if (published)
|
||||||
|
{
|
||||||
|
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
|
||||||
|
if (!ntcp2Port) ntcp2Port = port;
|
||||||
|
PublishNTCP2Address (ntcp2Port, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// update
|
// update
|
||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user