|
|
|
@ -315,7 +315,7 @@ namespace i2p
@@ -315,7 +315,7 @@ namespace i2p
|
|
|
|
|
if (v4) |
|
|
|
|
{ |
|
|
|
|
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V4Idx]; |
|
|
|
|
if (addr) |
|
|
|
|
if (addr && (addr->port != port || addr->published != publish)) |
|
|
|
|
{ |
|
|
|
|
PublishNTCP2Address (addr, port, publish); |
|
|
|
|
updated = true; |
|
|
|
@ -324,7 +324,7 @@ namespace i2p
@@ -324,7 +324,7 @@ namespace i2p
|
|
|
|
|
if (v6) |
|
|
|
|
{ |
|
|
|
|
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6Idx]; |
|
|
|
|
if (addr) |
|
|
|
|
if (addr && (addr->port != port || addr->published != publish)) |
|
|
|
|
{ |
|
|
|
|
PublishNTCP2Address (addr, port, publish); |
|
|
|
|
updated = true; |
|
|
|
@ -333,7 +333,7 @@ namespace i2p
@@ -333,7 +333,7 @@ namespace i2p
|
|
|
|
|
if (ygg) |
|
|
|
|
{ |
|
|
|
|
auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6MeshIdx]; |
|
|
|
|
if (addr) |
|
|
|
|
if (addr && (addr->port != port || addr->published != publish)) |
|
|
|
|
{ |
|
|
|
|
PublishNTCP2Address (addr, port, publish); |
|
|
|
|
updated = true; |
|
|
|
@ -1011,41 +1011,10 @@ namespace i2p
@@ -1011,41 +1011,10 @@ namespace i2p
|
|
|
|
|
} |
|
|
|
|
n2k.close (); |
|
|
|
|
} |
|
|
|
|
// 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 |
|
|
|
|
{ |
|
|
|
|
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
|
|
|
|
|
// create new NTCP2 keys if required
|
|
|
|
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2); |
|
|
|
|
bool ygg; i2p::config::GetOption("meshnets.yggdrasil", ygg); |
|
|
|
|
if (ntcp2 || ygg) |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
if ((ntcp2 || ygg) && !m_NTCP2Keys) NewNTCP2Keys (); |
|
|
|
|
// read SSU2 keys if available
|
|
|
|
|
std::ifstream s2k (i2p::fs::DataDirPath (SSU2_KEYS), std::ifstream::in | std::ifstream::binary); |
|
|
|
|
if (s2k) |
|
|
|
@ -1060,12 +1029,28 @@ namespace i2p
@@ -1060,12 +1029,28 @@ namespace i2p
|
|
|
|
|
} |
|
|
|
|
s2k.close (); |
|
|
|
|
} |
|
|
|
|
if (!m_SSU2Keys) NewSSU2Keys (); |
|
|
|
|
UpdateSSU2Address (true); // enable SSU2
|
|
|
|
|
// create new SSU2 keys if required
|
|
|
|
|
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 |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1098,7 +1083,6 @@ namespace i2p
@@ -1098,7 +1083,6 @@ namespace i2p
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RouterContext::ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg) |
|
|
|
|
{ |
|
|
|
|
std::unique_lock<std::mutex> l(m_GarlicMutex); |
|
|
|
|