mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-30 04:37:50 +02:00
result
This commit is contained in:
parent
885dc6603f
commit
2deb4118bc
31 changed files with 783 additions and 212 deletions
|
@ -43,7 +43,7 @@ namespace i2p
|
|||
void RouterContext::OverrideNTCPAddress (const char * host, int port)
|
||||
{
|
||||
m_RouterInfo.CreateBuffer ();
|
||||
auto address = m_RouterInfo.GetNTCPAddress ();
|
||||
auto address = const_cast<i2p::data::RouterInfo::Address *>(m_RouterInfo.GetNTCPAddress ());
|
||||
if (address)
|
||||
{
|
||||
address->host = boost::asio::ip::address::from_string (host);
|
||||
|
@ -68,24 +68,46 @@ namespace i2p
|
|||
|
||||
bool RouterContext::Load ()
|
||||
{
|
||||
std::ifstream fk (ROUTER_KEYS, std::ifstream::binary | std::ofstream::in);
|
||||
std::string dataDir = i2p::util::filesystem::GetDataDir ().string ();
|
||||
#ifndef _WIN32
|
||||
dataDir.append ("/");
|
||||
#else
|
||||
dataDir.append ("\\");
|
||||
#endif
|
||||
std::string router_keys = dataDir;
|
||||
router_keys.append (ROUTER_KEYS);
|
||||
std::string router_info = dataDir;
|
||||
router_info.append (ROUTER_INFO);
|
||||
|
||||
std::ifstream fk (router_keys.c_str (), std::ifstream::binary | std::ofstream::in);
|
||||
if (!fk.is_open ()) return false;
|
||||
|
||||
fk.read ((char *)&m_Keys, sizeof (m_Keys));
|
||||
m_SigningPrivateKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag,
|
||||
CryptoPP::Integer (m_Keys.signingPrivateKey, 20));
|
||||
|
||||
m_RouterInfo = i2p::data::RouterInfo (ROUTER_INFO); // TODO
|
||||
m_RouterInfo = i2p::data::RouterInfo (router_info.c_str ()); // TODO
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RouterContext::Save ()
|
||||
{
|
||||
std::ofstream fk (ROUTER_KEYS, std::ofstream::binary | std::ofstream::out);
|
||||
std::string dataDir = i2p::util::filesystem::GetDataDir ().string ();
|
||||
#ifndef _WIN32
|
||||
dataDir.append ("/");
|
||||
#else
|
||||
dataDir.append ("\\");
|
||||
#endif
|
||||
std::string router_keys = dataDir;
|
||||
router_keys.append (ROUTER_KEYS);
|
||||
std::string router_info = dataDir;
|
||||
router_info.append (ROUTER_INFO);
|
||||
|
||||
std::ofstream fk (router_keys.c_str (), std::ofstream::binary | std::ofstream::out);
|
||||
fk.write ((char *)&m_Keys, sizeof (m_Keys));
|
||||
|
||||
std::ofstream fi (ROUTER_INFO, std::ofstream::binary | std::ofstream::out);
|
||||
std::ofstream fi (router_info.c_str (), std::ofstream::binary | std::ofstream::out);
|
||||
fi.write ((char *)m_RouterInfo.GetBuffer (), m_RouterInfo.GetBufferLen ());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue