|
|
@ -63,7 +63,6 @@ namespace i2p |
|
|
|
bool ipv4; i2p::config::GetOption("ipv4", ipv4); |
|
|
|
bool ipv4; i2p::config::GetOption("ipv4", ipv4); |
|
|
|
bool ipv6; i2p::config::GetOption("ipv6", ipv6); |
|
|
|
bool ipv6; i2p::config::GetOption("ipv6", ipv6); |
|
|
|
bool ssu; i2p::config::GetOption("ssu", ssu); |
|
|
|
bool ssu; i2p::config::GetOption("ssu", ssu); |
|
|
|
bool ntcp; i2p::config::GetOption("ntcp", ntcp); |
|
|
|
|
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
bool nat; i2p::config::GetOption("nat", nat); |
|
|
|
bool nat; i2p::config::GetOption("nat", nat); |
|
|
|
std::string ifname; i2p::config::GetOption("ifname", ifname); |
|
|
|
std::string ifname; i2p::config::GetOption("ifname", ifname); |
|
|
@ -83,8 +82,6 @@ namespace i2p |
|
|
|
|
|
|
|
|
|
|
|
if (ssu) |
|
|
|
if (ssu) |
|
|
|
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ()); |
|
|
|
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ()); |
|
|
|
if (ntcp) |
|
|
|
|
|
|
|
routerInfo.AddNTCPAddress (host.c_str(), port); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (ipv6) |
|
|
|
if (ipv6) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -99,8 +96,6 @@ namespace i2p |
|
|
|
|
|
|
|
|
|
|
|
if (ssu) |
|
|
|
if (ssu) |
|
|
|
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ()); |
|
|
|
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ()); |
|
|
|
if (ntcp) |
|
|
|
|
|
|
|
routerInfo.AddNTCPAddress (host.c_str(), port); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
routerInfo.SetCaps (i2p::data::RouterInfo::eReachable | |
|
|
|
routerInfo.SetCaps (i2p::data::RouterInfo::eReachable | |
|
|
@ -115,20 +110,17 @@ namespace i2p |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_NTCP2Keys) NewNTCP2Keys (); |
|
|
|
if (!m_NTCP2Keys) NewNTCP2Keys (); |
|
|
|
UpdateNTCP2Address (true); |
|
|
|
UpdateNTCP2Address (true); |
|
|
|
if (!ntcp) // NTCP2 should replace NTCP
|
|
|
|
bool published; i2p::config::GetOption("ntcp2.published", published); |
|
|
|
|
|
|
|
if (published) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool published; i2p::config::GetOption("ntcp2.published", published); |
|
|
|
PublishNTCP2Address (port, true); |
|
|
|
if (published) |
|
|
|
if (ipv6) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PublishNTCP2Address (port, true); |
|
|
|
// add NTCP2 ipv6 address
|
|
|
|
if (ipv6) |
|
|
|
std::string host = "::1"; |
|
|
|
{ |
|
|
|
if (!i2p::config::IsDefault ("ntcp2.addressv6")) |
|
|
|
// add NTCP2 ipv6 address
|
|
|
|
i2p::config::GetOption ("ntcp2.addressv6", host); |
|
|
|
std::string host = "::1"; |
|
|
|
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address_v6::from_string (host), port); |
|
|
|
if (!i2p::config::IsDefault ("ntcp2.addressv6")) |
|
|
|
|
|
|
|
i2p::config::GetOption ("ntcp2.addressv6", host); |
|
|
|
|
|
|
|
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address_v6::from_string (host), port); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -444,16 +436,10 @@ namespace i2p |
|
|
|
addr->ssu->introducers.clear (); |
|
|
|
addr->ssu->introducers.clear (); |
|
|
|
port = addr->port; |
|
|
|
port = addr->port; |
|
|
|
} |
|
|
|
} |
|
|
|
// remove NTCP or NTCP2 v4 address
|
|
|
|
// remove NTCP2 v4 address
|
|
|
|
bool ntcp; i2p::config::GetOption("ntcp", ntcp); |
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
if (ntcp) |
|
|
|
if (ntcp2) |
|
|
|
PublishNTCPAddress (false); |
|
|
|
PublishNTCP2Address (port, false, true); |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
|
|
|
|
if (ntcp2) |
|
|
|
|
|
|
|
PublishNTCP2Address (port, false, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// update
|
|
|
|
// update
|
|
|
|
UpdateRouterInfo (); |
|
|
|
UpdateRouterInfo (); |
|
|
|
} |
|
|
|
} |
|
|
@ -477,23 +463,16 @@ namespace i2p |
|
|
|
addr->ssu->introducers.clear (); |
|
|
|
addr->ssu->introducers.clear (); |
|
|
|
port = addr->port; |
|
|
|
port = addr->port; |
|
|
|
} |
|
|
|
} |
|
|
|
// insert NTCP or NTCP2 back
|
|
|
|
// insert NTCP2 back
|
|
|
|
bool ntcp; i2p::config::GetOption("ntcp", ntcp); |
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
if (ntcp) |
|
|
|
if (ntcp2) |
|
|
|
PublishNTCPAddress (true); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// ntcp2
|
|
|
|
bool published; i2p::config::GetOption ("ntcp2.published", published); |
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
if (published) |
|
|
|
if (ntcp2) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
bool published; i2p::config::GetOption ("ntcp2.published", published); |
|
|
|
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port); |
|
|
|
if (published) |
|
|
|
if (!ntcp2Port) ntcp2Port = port; |
|
|
|
{ |
|
|
|
PublishNTCP2Address (ntcp2Port, true, true); |
|
|
|
uint16_t ntcp2Port; i2p::config::GetOption ("ntcp2.port", ntcp2Port); |
|
|
|
|
|
|
|
if (!ntcp2Port) ntcp2Port = port; |
|
|
|
|
|
|
|
PublishNTCP2Address (ntcp2Port, true, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// update
|
|
|
|
// update
|
|
|
@ -506,7 +485,7 @@ namespace i2p |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_RouterInfo.EnableV6 (); |
|
|
|
m_RouterInfo.EnableV6 (); |
|
|
|
// insert v6 addresses if necessary
|
|
|
|
// insert v6 addresses if necessary
|
|
|
|
bool foundSSU = false, foundNTCP = false, foundNTCP2 = false; |
|
|
|
bool foundSSU = false, foundNTCP2 = false; |
|
|
|
uint16_t port = 0; |
|
|
|
uint16_t port = 0; |
|
|
|
auto& addresses = m_RouterInfo.GetAddresses (); |
|
|
|
auto& addresses = m_RouterInfo.GetAddresses (); |
|
|
|
for (auto& addr: addresses) |
|
|
|
for (auto& addr: addresses) |
|
|
@ -515,12 +494,8 @@ namespace i2p |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (addr->transportStyle == i2p::data::RouterInfo::eTransportSSU) |
|
|
|
if (addr->transportStyle == i2p::data::RouterInfo::eTransportSSU) |
|
|
|
foundSSU = true; |
|
|
|
foundSSU = true; |
|
|
|
else if (addr->IsNTCP2 ()) |
|
|
|
else if (addr->IsPublishedNTCP2 ()) |
|
|
|
{ |
|
|
|
foundNTCP2 = true; |
|
|
|
if (addr->IsPublishedNTCP2 ()) foundNTCP2 = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
foundNTCP = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
port = addr->port; |
|
|
|
port = addr->port; |
|
|
|
} |
|
|
|
} |
|
|
@ -552,16 +527,6 @@ namespace i2p |
|
|
|
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address::from_string (ntcp2Host), ntcp2Port); |
|
|
|
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address::from_string (ntcp2Host), ntcp2Port); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// NTCP
|
|
|
|
|
|
|
|
if (!foundNTCP) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool ntcp; i2p::config::GetOption("ntcp", ntcp); |
|
|
|
|
|
|
|
if (ntcp) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::string host = "::1"; |
|
|
|
|
|
|
|
m_RouterInfo.AddNTCPAddress (host.c_str (), port); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
m_RouterInfo.DisableV6 (); |
|
|
|
m_RouterInfo.DisableV6 (); |
|
|
|