|
|
@ -315,7 +315,7 @@ namespace i2p |
|
|
|
if (v4) |
|
|
|
if (v4) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V4Idx]; |
|
|
|
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V4Idx]; |
|
|
|
if (addr) |
|
|
|
if (addr && (addr->port != port || addr->published != publish)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PublishNTCP2Address (addr, port, publish); |
|
|
|
PublishNTCP2Address (addr, port, publish); |
|
|
|
updated = true; |
|
|
|
updated = true; |
|
|
@ -324,7 +324,7 @@ namespace i2p |
|
|
|
if (v6) |
|
|
|
if (v6) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6Idx]; |
|
|
|
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6Idx]; |
|
|
|
if (addr) |
|
|
|
if (addr && (addr->port != port || addr->published != publish)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PublishNTCP2Address (addr, port, publish); |
|
|
|
PublishNTCP2Address (addr, port, publish); |
|
|
|
updated = true; |
|
|
|
updated = true; |
|
|
@ -333,7 +333,7 @@ namespace i2p |
|
|
|
if (ygg) |
|
|
|
if (ygg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6MeshIdx]; |
|
|
|
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6MeshIdx]; |
|
|
|
if (addr) |
|
|
|
if (addr && (addr->port != port || addr->published != publish)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PublishNTCP2Address (addr, port, publish); |
|
|
|
PublishNTCP2Address (addr, port, publish); |
|
|
|
updated = true; |
|
|
|
updated = true; |
|
|
@ -1011,41 +1011,10 @@ namespace i2p |
|
|
|
} |
|
|
|
} |
|
|
|
n2k.close (); |
|
|
|
n2k.close (); |
|
|
|
} |
|
|
|
} |
|
|
|
// read RouterInfo
|
|
|
|
// create new NTCP2 keys if required
|
|
|
|
m_RouterInfo.SetRouterIdentity (oldIdentity ? oldIdentity : GetIdentity ()); |
|
|
|
|
|
|
|
i2p::data::RouterInfo routerInfo(i2p::fs::DataDirPath (ROUTER_INFO)); |
|
|
|
|
|
|
|
if (!routerInfo.IsUnreachable ()) // router.info looks good
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ()); |
|
|
|
|
|
|
|
if (oldIdentity) |
|
|
|
|
|
|
|
m_RouterInfo.SetRouterIdentity (GetIdentity ()); // from new keys
|
|
|
|
|
|
|
|
m_RouterInfo.SetProperty ("router.version", I2P_VERSION); |
|
|
|
|
|
|
|
m_RouterInfo.DeleteProperty ("coreVersion"); // TODO: remove later
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogError, ROUTER_INFO, " is malformed. Creating new"); |
|
|
|
|
|
|
|
NewRouterInfo (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IsUnreachable ()) |
|
|
|
|
|
|
|
SetReachable (true, true); // we assume reachable until we discover firewall through peer tests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// read NTCP2
|
|
|
|
|
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg); |
|
|
|
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg); |
|
|
|
if (ntcp2 || ygg) |
|
|
|
if ((ntcp2 || ygg) && !m_NTCP2Keys) NewNTCP2Keys (); |
|
|
|
{ |
|
|
|
|
|
|
|
if (!m_NTCP2Keys) NewNTCP2Keys (); |
|
|
|
|
|
|
|
UpdateNTCP2Address (true); // enable NTCP2
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
UpdateNTCP2Address (false); // disable NTCP2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// read SSU2
|
|
|
|
|
|
|
|
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2); |
|
|
|
|
|
|
|
if (ssu2) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// read SSU2 keys if available
|
|
|
|
// read SSU2 keys if available
|
|
|
|
std::ifstream s2k (i2p::fs::DataDirPath (SSU2_KEYS), std::ifstream::in | std::ifstream::binary); |
|
|
|
std::ifstream s2k (i2p::fs::DataDirPath (SSU2_KEYS), std::ifstream::in | std::ifstream::binary); |
|
|
|
if (s2k) |
|
|
|
if (s2k) |
|
|
@ -1060,12 +1029,28 @@ namespace i2p |
|
|
|
} |
|
|
|
} |
|
|
|
s2k.close (); |
|
|
|
s2k.close (); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!m_SSU2Keys) NewSSU2Keys (); |
|
|
|
// create new SSU2 keys if required
|
|
|
|
UpdateSSU2Address (true); // enable SSU2
|
|
|
|
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2); |
|
|
|
|
|
|
|
if (ssu2 && !m_SSU2Keys) NewSSU2Keys (); |
|
|
|
|
|
|
|
// read RouterInfo
|
|
|
|
|
|
|
|
m_RouterInfo.SetRouterIdentity (oldIdentity ? oldIdentity : GetIdentity ()); |
|
|
|
|
|
|
|
i2p::data::RouterInfo routerInfo(i2p::fs::DataDirPath (ROUTER_INFO)); |
|
|
|
|
|
|
|
if (!routerInfo.IsUnreachable ()) // router.info looks good
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ()); |
|
|
|
|
|
|
|
if (oldIdentity) |
|
|
|
|
|
|
|
m_RouterInfo.SetRouterIdentity (GetIdentity ()); // from new keys
|
|
|
|
|
|
|
|
m_RouterInfo.SetProperty ("router.version", I2P_VERSION); |
|
|
|
|
|
|
|
m_RouterInfo.DeleteProperty ("coreVersion"); // TODO: remove later
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
UpdateSSU2Address (false); // disable SSU2
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogError, ROUTER_INFO, " is malformed. Creating new"); |
|
|
|
|
|
|
|
NewRouterInfo (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IsUnreachable ()) |
|
|
|
|
|
|
|
SetReachable (true, true); // we assume reachable until we discover firewall through peer tests
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1098,7 +1083,6 @@ namespace i2p |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RouterContext::ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg) |
|
|
|
void RouterContext::ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::unique_lock<std::mutex> l(m_GarlicMutex); |
|
|
|
std::unique_lock<std::mutex> l(m_GarlicMutex); |
|
|
|