From ab843b6552b3b840f6a1ba21a5fa2f4b3336a5ae Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 21 Oct 2014 15:44:28 -0400 Subject: [PATCH] cleaned up from duplicated methods --- I2NPProtocol.cpp | 2 +- NTCPSession.cpp | 2 +- RouterContext.h | 3 --- SSU.cpp | 4 ++-- TunnelPool.cpp | 2 +- TunnelPool.h | 2 +- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index d4c6d71e..75606295 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -290,7 +290,7 @@ namespace i2p { LogPrint ("Record ",i," is ours"); - i2p::crypto::ElGamalDecrypt (i2p::context.GetPrivateKey (), records[i].encrypted, (uint8_t *)&clearText); + i2p::crypto::ElGamalDecrypt (i2p::context.GetEncryptionPrivateKey (), records[i].encrypted, (uint8_t *)&clearText); // replace record to reply I2NPBuildResponseRecord * reply = (I2NPBuildResponseRecord *)(records + i); if (i2p::context.AcceptsTunnels ()) diff --git a/NTCPSession.cpp b/NTCPSession.cpp index a4a73dd4..d1689bc1 100644 --- a/NTCPSession.cpp +++ b/NTCPSession.cpp @@ -275,7 +275,7 @@ namespace transport void NTCPSession::SendPhase3 () { m_Establisher->phase3.size = htons (i2p::data::DEFAULT_IDENTITY_SIZE); - memcpy (&m_Establisher->phase3.ident, &i2p::context.GetRouterIdentity (), i2p::data::DEFAULT_IDENTITY_SIZE); + memcpy (&m_Establisher->phase3.ident, &i2p::context.GetIdentity ().GetStandardIdentity (), i2p::data::DEFAULT_IDENTITY_SIZE); // TODO: uint32_t tsA = htobe32 (i2p::util::GetSecondsSinceEpoch ()); m_Establisher->phase3.timestamp = tsA; diff --git a/RouterContext.h b/RouterContext.h index 777482b8..e10a4192 100644 --- a/RouterContext.h +++ b/RouterContext.h @@ -22,9 +22,6 @@ namespace i2p void Init (); i2p::data::RouterInfo& GetRouterInfo () { return m_RouterInfo; }; - const uint8_t * GetPrivateKey () const { return m_Keys.GetPrivateKey (); }; - const i2p::data::Identity& GetRouterIdentity () const { return m_RouterInfo.GetRouterIdentity (); }; - const i2p::data::IdentHash& GetRouterIdentHash () const { return m_RouterInfo.GetIdentHash (); }; CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; }; void UpdatePort (int port); // called from Daemon diff --git a/SSU.cpp b/SSU.cpp index 0ceff06e..a316bddd 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -359,10 +359,10 @@ namespace transport uint8_t * payload = buf + sizeof (SSUHeader); *payload = 1; // 1 fragment payload++; // info - size_t identLen = sizeof (i2p::context.GetRouterIdentity ()); // 387 bytes + size_t identLen = i2p::data::DEFAULT_IDENTITY_SIZE; // 387 bytes *(uint16_t *)(payload) = htobe16 (identLen); payload += 2; // cursize - memcpy (payload, (uint8_t *)&i2p::context.GetRouterIdentity (), identLen); + memcpy (payload, (uint8_t *)&i2p::context.GetIdentity ().GetStandardIdentity (), identLen); // TODO payload += identLen; uint32_t signedOnTime = i2p::util::GetSecondsSinceEpoch (); *(uint32_t *)(payload) = htobe32 (signedOnTime); // signed on time diff --git a/TunnelPool.cpp b/TunnelPool.cpp index ac63cf7b..f756ebd4 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -257,7 +257,7 @@ namespace tunnel { // last hop auto hop = outboundTunnel->GetTunnelConfig ()->GetFirstHop ()->router; - if (hop->GetIdentHash () != i2p::context.GetRouterIdentHash ()) // outbound shouldn't be zero-hop tunnel + if (hop->GetIdentHash () != i2p::context.GetIdentHash ()) // outbound shouldn't be zero-hop tunnel { prevHop = hop; hops.push_back (prevHop); diff --git a/TunnelPool.h b/TunnelPool.h index da59866c..76ba45d8 100644 --- a/TunnelPool.h +++ b/TunnelPool.h @@ -33,7 +33,7 @@ namespace tunnel const uint8_t * GetEncryptionPublicKey () const { return m_LocalDestination.GetEncryptionPublicKey (); }; const i2p::data::LocalDestination& GetLocalDestination () const { return m_LocalDestination; }; i2p::garlic::GarlicDestination& GetGarlicDestination () const { return m_LocalDestination; }; - bool IsExploratory () const { return GetIdentHash () == i2p::context.GetRouterIdentHash (); }; + bool IsExploratory () const { return GetIdentHash () == i2p::context.GetIdentHash (); }; void CreateTunnels (); void TunnelCreated (InboundTunnel * createdTunnel);