From c855d8b413bf9b59073cb4443d78bc219ab9ef67 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 19 Mar 2014 16:38:55 -0400 Subject: [PATCH] load eepsite keys --- Identity.h | 7 +++++++ Streaming.cpp | 19 +++++++++++++++++-- Streaming.h | 2 ++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Identity.h b/Identity.h index 6552fa38..58d7849e 100644 --- a/Identity.h +++ b/Identity.h @@ -28,6 +28,13 @@ namespace data Identity& operator=(const Keys& keys); }; + struct PrivateKeys // for eepsites + { + Identity pub; + uint8_t privateKey[256]; + uint8_t signingPrivateKey[20]; + }; + #pragma pack() class IdentHash diff --git a/Streaming.cpp b/Streaming.cpp index a537def8..eedef81e 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include "Log.h" @@ -301,7 +301,6 @@ namespace stream StreamingDestination::StreamingDestination (): m_LeaseSet (nullptr) { - // TODO: read from file later m_Keys = i2p::data::CreateRandomKeys (); m_Identity = m_Keys; m_IdentHash = i2p::data::CalculateIdentHash (m_Identity); @@ -310,6 +309,22 @@ namespace stream m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this); } + StreamingDestination::StreamingDestination (const std::string& fullPath): m_LeaseSet (nullptr) + { + std::ifstream s(fullPath.c_str (), std::ifstream::binary); + if (s.is_open ()) + { + i2p::data::PrivateKeys keys; + s.read ((char *)&keys, sizeof (keys)); + // TODO: use PrivateKeys + m_Identity = keys.pub; + memcpy (m_Keys.privateKey, keys.privateKey, 276); + } + else + LogPrint ("Can't open file ", fullPath); + m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this); + } + StreamingDestination::~StreamingDestination () { if (m_LeaseSet) diff --git a/Streaming.h b/Streaming.h index 973c2a55..36140d0b 100644 --- a/Streaming.h +++ b/Streaming.h @@ -2,6 +2,7 @@ #define STREAMING_H__ #include +#include #include #include #include @@ -106,6 +107,7 @@ namespace stream public: StreamingDestination (); + StreamingDestination (const std::string& fullPath); ~StreamingDestination (); const i2p::data::Keys& GetKeys () const { return m_Keys; };