Fix cryptography memory leaks :P

This commit is contained in:
momo5502
2016-02-08 18:43:31 +01:00
parent 4d36a0b9ed
commit 87c239a1dc
6 changed files with 100 additions and 19 deletions

View File

@ -2,6 +2,8 @@
namespace Components
{
Utils::Cryptography::ECDSA::Key Node::SignatureKey;
std::vector<Node::NodeEntry> Node::Nodes;
std::vector<Node::DediEntry> Node::Dedis;
@ -396,6 +398,9 @@ namespace Components
// ZoneBuilder doesn't require node stuff
if (ZoneBuilder::IsEnabled()) return;
// Generate our ECDSA key
Node::SignatureKey = Utils::Cryptography::ECDSA::GenerateKey(512);
Dvar::OnInit([] ()
{
Node::Dedis.clear();
@ -570,6 +575,8 @@ namespace Components
Node::~Node()
{
Node::SignatureKey.Free();
Node::StoreNodes(true);
Node::Nodes.clear();
Node::Dedis.clear();

View File

@ -44,6 +44,7 @@ namespace Components
struct NodeEntry
{
Network::Address address;
Utils::Cryptography::ECDSA::Key publicKey;
EntryState state;
int lastTime; // Last time we heard anything from the server itself
int lastHeartbeat; // Last time we got a heartbeat from it
@ -84,6 +85,8 @@ namespace Components
};
#pragma pack(pop)
static Utils::Cryptography::ECDSA::Key SignatureKey;
static std::vector<NodeEntry> Nodes;
static std::vector<DediEntry> Dedis;