|
|
@ -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,8 +110,6 @@ 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); |
|
|
|
bool published; i2p::config::GetOption("ntcp2.published", published); |
|
|
|
if (published) |
|
|
|
if (published) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -132,7 +125,6 @@ namespace i2p |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RouterContext::UpdateRouterInfo () |
|
|
|
void RouterContext::UpdateRouterInfo () |
|
|
|
{ |
|
|
|
{ |
|
|
@ -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); |
|
|
|
|
|
|
|
if (ntcp) |
|
|
|
|
|
|
|
PublishNTCPAddress (false); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
if (ntcp2) |
|
|
|
if (ntcp2) |
|
|
|
PublishNTCP2Address (port, false, true); |
|
|
|
PublishNTCP2Address (port, false, true); |
|
|
|
} |
|
|
|
|
|
|
|
// update
|
|
|
|
// update
|
|
|
|
UpdateRouterInfo (); |
|
|
|
UpdateRouterInfo (); |
|
|
|
} |
|
|
|
} |
|
|
@ -477,13 +463,7 @@ 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); |
|
|
|
|
|
|
|
if (ntcp) |
|
|
|
|
|
|
|
PublishNTCPAddress (true); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// ntcp2
|
|
|
|
|
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
if (ntcp2) |
|
|
|
if (ntcp2) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -495,7 +475,6 @@ namespace i2p |
|
|
|
PublishNTCP2Address (ntcp2Port, true, true); |
|
|
|
PublishNTCP2Address (ntcp2Port, true, true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// update
|
|
|
|
// update
|
|
|
|
UpdateRouterInfo (); |
|
|
|
UpdateRouterInfo (); |
|
|
|
} |
|
|
|
} |
|
|
@ -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 (); |
|
|
|