mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 12:24:19 +00:00
don't overwrite NTCP2 keys
This commit is contained in:
parent
26d0177c01
commit
09c6faf923
@ -95,7 +95,7 @@ namespace i2p
|
|||||||
|
|
||||||
if (ntcp2) // TODO: should update routerInfo, but we ignore upublished NTCP2 addresses for now
|
if (ntcp2) // TODO: should update routerInfo, but we ignore upublished NTCP2 addresses for now
|
||||||
{
|
{
|
||||||
NewNTCP2Keys ();
|
if (!m_NTCP2Keys) NewNTCP2Keys ();
|
||||||
UpdateNTCP2Address (true);
|
UpdateNTCP2Address (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -473,7 +473,21 @@ namespace i2p
|
|||||||
m_Keys.FromBuffer (buf, len);
|
m_Keys.FromBuffer (buf, len);
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
}
|
}
|
||||||
|
// read NTCP2 keys if available
|
||||||
|
std::ifstream n2k (i2p::fs::DataDirPath (NTCP2_KEYS), std::ifstream::in | std::ifstream::binary);
|
||||||
|
if (n2k)
|
||||||
|
{
|
||||||
|
n2k.seekg (0, std::ios::end);
|
||||||
|
len = n2k.tellg();
|
||||||
|
n2k.seekg (0, std::ios::beg);
|
||||||
|
if (len == sizeof (NTCP2PrivateKeys))
|
||||||
|
{
|
||||||
|
m_NTCP2Keys.reset (new NTCP2PrivateKeys ());
|
||||||
|
n2k.read ((char *)m_NTCP2Keys.get (), sizeof (NTCP2PrivateKeys));
|
||||||
|
}
|
||||||
|
n2k.close ();
|
||||||
|
}
|
||||||
|
// read RouterInfo
|
||||||
m_RouterInfo.SetRouterIdentity (GetIdentity ());
|
m_RouterInfo.SetRouterIdentity (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
|
||||||
@ -499,24 +513,8 @@ namespace i2p
|
|||||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
if (ntcp2)
|
if (ntcp2)
|
||||||
{
|
{
|
||||||
std::ifstream n2k (i2p::fs::DataDirPath (NTCP2_KEYS), std::ifstream::in | std::ifstream::binary);
|
if (!m_NTCP2Keys) NewNTCP2Keys ();
|
||||||
if (n2k)
|
UpdateNTCP2Address (true); // enable NTCP2
|
||||||
{
|
|
||||||
n2k.seekg (0, std::ios::end);
|
|
||||||
len = n2k.tellg();
|
|
||||||
n2k.seekg (0, std::ios::beg);
|
|
||||||
if (len == sizeof (NTCP2PrivateKeys))
|
|
||||||
{
|
|
||||||
m_NTCP2Keys.reset (new NTCP2PrivateKeys ());
|
|
||||||
n2k.read ((char *)m_NTCP2Keys.get (), sizeof (NTCP2PrivateKeys));
|
|
||||||
}
|
|
||||||
n2k.close ();
|
|
||||||
}
|
|
||||||
if (!m_NTCP2Keys)
|
|
||||||
{
|
|
||||||
NewNTCP2Keys ();
|
|
||||||
UpdateNTCP2Address (true); // enable NTCP2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
UpdateNTCP2Address (false); // disable NTCP2
|
UpdateNTCP2Address (false); // disable NTCP2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user