mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
Merge branch 'master' of https://github.com/orignal/i2pd
This commit is contained in:
commit
654fe138a8
@ -80,7 +80,7 @@ void AddressBook::LoadHosts ()
|
||||
getline(f, s);
|
||||
|
||||
if (!s.length())
|
||||
break;
|
||||
continue; // skip empty line
|
||||
|
||||
size_t pos = s.find('=');
|
||||
|
||||
@ -90,8 +90,11 @@ void AddressBook::LoadHosts ()
|
||||
std::string addr = s.substr(pos);
|
||||
|
||||
Identity ident;
|
||||
Base64ToByteStream (addr.c_str(), addr.length(), (uint8_t *)&ident, sizeof (ident));
|
||||
m_Addresses[name] = CalculateIdentHash (ident);
|
||||
if (!ident.FromBase64(addr)) {
|
||||
LogPrint ("hosts.txt: ignore ", name);
|
||||
continue;
|
||||
}
|
||||
m_Addresses[name] = ident.Hash();
|
||||
numAddresses++;
|
||||
}
|
||||
}
|
||||
|
14
Identity.cpp
14
Identity.cpp
@ -6,6 +6,7 @@
|
||||
#include <cryptopp/dsa.h>
|
||||
#include "CryptoConst.h"
|
||||
#include "Identity.h"
|
||||
#include "base64.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
@ -17,6 +18,19 @@ namespace data
|
||||
memcpy (publicKey, keys.publicKey, sizeof (publicKey) + sizeof (signingKey));
|
||||
memset (certificate, 0, sizeof (certificate));
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Identity::FromBase64 (const std::string& s)
|
||||
{
|
||||
size_t count = Base64ToByteStream (s.c_str(), s.length(), reinterpret_cast<uint8_t*> (this), sizeof (Identity));
|
||||
return count == sizeof(Identity);
|
||||
}
|
||||
|
||||
IdentHash Identity::Hash()
|
||||
{
|
||||
IdentHash hash;
|
||||
CryptoPP::SHA256().CalculateDigest(reinterpret_cast<uint8_t*>(&hash), reinterpret_cast<uint8_t*> (this), sizeof (Identity));
|
||||
return hash;
|
||||
}
|
||||
|
||||
PrivateKeys& PrivateKeys::operator=(const Keys& keys)
|
||||
|
@ -9,6 +9,8 @@ namespace i2p
|
||||
{
|
||||
namespace data
|
||||
{
|
||||
class IdentHash;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
struct DHKeysPair // transient keys for transport sessions
|
||||
@ -32,6 +34,8 @@ namespace data
|
||||
uint8_t certificate[3];
|
||||
|
||||
Identity& operator=(const Keys& keys);
|
||||
bool FromBase64(const std::string&);
|
||||
IdentHash Hash();
|
||||
};
|
||||
|
||||
struct PrivateKeys // for eepsites
|
||||
|
Loading…
Reference in New Issue
Block a user