Browse Source

publish and upublish NTCP2 and yggdrasil addresses separatly

pull/1645/head
orignal 4 years ago
parent
commit
43d458cf72
  1. 6
      daemon/Daemon.cpp
  2. 10
      libi2pd/RouterContext.cpp
  3. 2
      libi2pd/RouterContext.h

6
daemon/Daemon.cpp

@ -218,7 +218,7 @@ namespace util @@ -218,7 +218,7 @@ namespace util
{
uint16_t ntcp2port; i2p::config::GetOption("ntcp2.port", ntcp2port);
if (!ntcp2port) ntcp2port = port; // use standard port
i2p::context.PublishNTCP2Address (ntcp2port, true); // publish
i2p::context.PublishNTCP2Address (ntcp2port, true, ipv4, ipv6, false); // publish
if (ipv6)
{
std::string ipv6Addr; i2p::config::GetOption("ntcp2.addressv6", ipv6Addr);
@ -228,12 +228,12 @@ namespace util @@ -228,12 +228,12 @@ namespace util
}
}
else
i2p::context.PublishNTCP2Address (port, false); // unpublish
i2p::context.PublishNTCP2Address (port, false, ipv4, ipv6, false); // unpublish
}
if (ygg)
{
if (!ntcp2)
i2p::context.PublishNTCP2Address (port, true);
i2p::context.PublishNTCP2Address (port, true, false, false, true);
i2p::context.UpdateNTCP2V6Address (yggaddr);
if (!ipv4 && !ipv6)
i2p::context.SetStatus (eRouterStatusMesh);

10
libi2pd/RouterContext.cpp

@ -225,13 +225,15 @@ namespace i2p @@ -225,13 +225,15 @@ namespace i2p
UpdateRouterInfo ();
}
void RouterContext::PublishNTCP2Address (int port, bool publish, bool v4only)
void RouterContext::PublishNTCP2Address (int port, bool publish, bool v4, bool v6, bool ygg)
{
if (!m_NTCP2Keys) return;
bool updated = false;
for (auto& address : m_RouterInfo.GetAddresses ())
{
if (address->IsNTCP2 () && (address->port != port || address->ntcp2->isPublished != publish) && (!v4only || address->IsV4 ()))
if (address->IsNTCP2 () && (address->port != port || address->ntcp2->isPublished != publish)
&& ((v4 && address->IsV4 ()) || (v6 && address->IsV6 ()) ||
(ygg && i2p::util::net::IsYggdrasilAddress (address->host))))
{
if (!port && !address->port)
{
@ -457,7 +459,7 @@ namespace i2p @@ -457,7 +459,7 @@ namespace i2p
// remove NTCP2 v4 address
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
if (ntcp2)
PublishNTCP2Address (port, false, true);
PublishNTCP2Address (port, false, true, false, false); // ipv4 only
// update
UpdateRouterInfo ();
}
@ -491,7 +493,7 @@ namespace i2p @@ -491,7 +493,7 @@ namespace i2p
{
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port);
if (!ntcp2Port) ntcp2Port = port;
PublishNTCP2Address (ntcp2Port, true, true);
PublishNTCP2Address (ntcp2Port, true, true, false, false); // ipv4 only
}
}
// update

2
libi2pd/RouterContext.h

@ -97,7 +97,7 @@ namespace garlic @@ -97,7 +97,7 @@ namespace garlic
void UpdatePort (int port); // called from Daemon
void UpdateAddress (const boost::asio::ip::address& host); // called from SSU or Daemon
void PublishNTCP2Address (int port, bool publish = true, bool v4only = false);
void PublishNTCP2Address (int port, bool publish, bool v4, bool v6, bool ygg);
void UpdateNTCP2Address (bool enable);
void RemoveNTCPAddress (bool v4only = true); // delete NTCP address for older routers. TODO: remove later
bool AddIntroducer (const i2p::data::RouterInfo::Introducer& introducer);

Loading…
Cancel
Save