mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
upddate DSA router keys
This commit is contained in:
parent
30d6bd144b
commit
0436a65baa
@ -563,6 +563,7 @@ namespace i2p
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RouterContext::Load ()
|
bool RouterContext::Load ()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
std::ifstream fk (i2p::fs::DataDirPath (ROUTER_KEYS), std::ifstream::in | std::ifstream::binary);
|
std::ifstream fk (i2p::fs::DataDirPath (ROUTER_KEYS), std::ifstream::in | std::ifstream::binary);
|
||||||
if (!fk.is_open ()) return false;
|
if (!fk.is_open ()) return false;
|
||||||
@ -583,12 +584,22 @@ namespace i2p
|
|||||||
m_Keys.FromBuffer (buf, len);
|
m_Keys.FromBuffer (buf, len);
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
std::shared_ptr<const i2p::data::IdentityEx> oldIdentity;
|
||||||
|
if (m_Keys.GetPublic ()->GetSigningKeyType () == i2p::data::SIGNING_KEY_TYPE_DSA_SHA1)
|
||||||
|
{
|
||||||
|
// update keys
|
||||||
|
LogPrint (eLogInfo, "Router: router keys are obsolete. Creating new");
|
||||||
|
oldIdentity = m_Keys.GetPublic ();
|
||||||
|
m_Keys = i2p::data::PrivateKeys::CreateRandomKeys (i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519);
|
||||||
|
SaveKeys ();
|
||||||
|
}
|
||||||
// read NTCP2 keys if available
|
// read NTCP2 keys if available
|
||||||
std::ifstream n2k (i2p::fs::DataDirPath (NTCP2_KEYS), std::ifstream::in | std::ifstream::binary);
|
std::ifstream n2k (i2p::fs::DataDirPath (NTCP2_KEYS), std::ifstream::in | std::ifstream::binary);
|
||||||
if (n2k)
|
if (n2k)
|
||||||
{
|
{
|
||||||
n2k.seekg (0, std::ios::end);
|
n2k.seekg (0, std::ios::end);
|
||||||
len = n2k.tellg();
|
size_t len = n2k.tellg();
|
||||||
n2k.seekg (0, std::ios::beg);
|
n2k.seekg (0, std::ios::beg);
|
||||||
if (len == sizeof (NTCP2PrivateKeys))
|
if (len == sizeof (NTCP2PrivateKeys))
|
||||||
{
|
{
|
||||||
@ -598,17 +609,15 @@ namespace i2p
|
|||||||
n2k.close ();
|
n2k.close ();
|
||||||
}
|
}
|
||||||
// read RouterInfo
|
// read RouterInfo
|
||||||
m_RouterInfo.SetRouterIdentity (GetIdentity ());
|
m_RouterInfo.SetRouterIdentity (oldIdentity ? oldIdentity : GetIdentity ());
|
||||||
i2p::data::RouterInfo routerInfo(i2p::fs::DataDirPath (ROUTER_INFO));
|
i2p::data::RouterInfo routerInfo(i2p::fs::DataDirPath (ROUTER_INFO));
|
||||||
if (!routerInfo.IsUnreachable ()) // router.info looks good
|
if (!routerInfo.IsUnreachable ()) // router.info looks good
|
||||||
{
|
{
|
||||||
m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ());
|
m_RouterInfo.Update (routerInfo.GetBuffer (), routerInfo.GetBufferLen ());
|
||||||
|
if (oldIdentity)
|
||||||
|
m_RouterInfo.SetRouterIdentity (GetIdentity ()); // from new keys
|
||||||
m_RouterInfo.SetProperty ("coreVersion", I2P_VERSION);
|
m_RouterInfo.SetProperty ("coreVersion", I2P_VERSION);
|
||||||
m_RouterInfo.SetProperty ("router.version", I2P_VERSION);
|
m_RouterInfo.SetProperty ("router.version", I2P_VERSION);
|
||||||
|
|
||||||
// Migration to 0.9.24. TODO: remove later
|
|
||||||
m_RouterInfo.DeleteProperty ("coreVersion");
|
|
||||||
m_RouterInfo.DeleteProperty ("stat_uptime");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user