Browse Source

fixed few small issues

pull/11/merge
orignal 11 years ago
parent
commit
991a80428d
  1. 6
      NTCPSession.cpp
  2. 2
      RouterInfo.h
  3. 8
      Streaming.cpp
  4. 2
      Streaming.h

6
NTCPSession.cpp

@ -1,13 +1,13 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "I2PEndian.h" #include "I2PEndian.h"
#include <time.h>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <cryptopp/dh.h> #include <cryptopp/dh.h>
#include <cryptopp/secblock.h> #include <cryptopp/secblock.h>
#include <cryptopp/dsa.h> #include <cryptopp/dsa.h>
#include "base64.h" #include "base64.h"
#include "Log.h" #include "Log.h"
#include "Timestamp.h"
#include "CryptoConst.h" #include "CryptoConst.h"
#include "I2NPProtocol.h" #include "I2NPProtocol.h"
#include "RouterContext.h" #include "RouterContext.h"
@ -149,7 +149,7 @@ namespace ntcp
memcpy (xy, m_Phase1.pubKey, 256); memcpy (xy, m_Phase1.pubKey, 256);
memcpy (xy + 256, y, 256); memcpy (xy + 256, y, 256);
CryptoPP::SHA256().CalculateDigest(m_Phase2.encrypted.hxy, xy, 512); CryptoPP::SHA256().CalculateDigest(m_Phase2.encrypted.hxy, xy, 512);
uint32_t tsB = htobe32 (time(0)); uint32_t tsB = htobe32 (i2p::util::GetSecondsSinceEpoch ());
m_Phase2.encrypted.timestamp = tsB; m_Phase2.encrypted.timestamp = tsB;
// TODO: fill filler // TODO: fill filler
@ -217,7 +217,7 @@ namespace ntcp
{ {
m_Phase3.size = htons (sizeof (m_Phase3.ident)); m_Phase3.size = htons (sizeof (m_Phase3.ident));
memcpy (&m_Phase3.ident, &i2p::context.GetRouterIdentity (), sizeof (m_Phase3.ident)); memcpy (&m_Phase3.ident, &i2p::context.GetRouterIdentity (), sizeof (m_Phase3.ident));
uint32_t tsA = htobe32 (time(0)); uint32_t tsA = htobe32 (i2p::util::GetSecondsSinceEpoch ());
m_Phase3.timestamp = tsA; m_Phase3.timestamp = tsA;
SignedData s; SignedData s;

2
RouterInfo.h

@ -7,7 +7,7 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include "LeaseSet.h" #include "Identity.h"
namespace i2p namespace i2p
{ {

8
Streaming.cpp

@ -24,6 +24,8 @@ namespace stream
{ {
const uint8_t * end = buf + len; const uint8_t * end = buf + len;
buf += 4; // sendStreamID buf += 4; // sendStreamID
if (!m_SendStreamID)
m_SendStreamID = be32toh (*(uint32_t *)buf);
buf += 4; // receiveStreamID buf += 4; // receiveStreamID
buf += 4; // sequenceNum buf += 4; // sequenceNum
buf += 4; // ackThrough buf += 4; // ackThrough
@ -150,10 +152,10 @@ namespace stream
I2NPMessage * StreamingDestination::GetLeaseSet () I2NPMessage * StreamingDestination::GetLeaseSet ()
{ {
if (!m_LeaseSet) if (m_LeaseSet) // temporary always create new LeaseSet
DeleteI2NPMessage (m_LeaseSet);
m_LeaseSet = CreateLeaseSet (); m_LeaseSet = CreateLeaseSet ();
else
FillI2NPMessageHeader (m_LeaseSet, eI2NPDatabaseStore); // refresh msgID
return m_LeaseSet; return m_LeaseSet;
} }

2
Streaming.h

@ -35,7 +35,7 @@ namespace stream
uint32_t GetSendStreamID () const { return m_SendStreamID; }; uint32_t GetSendStreamID () const { return m_SendStreamID; };
uint32_t GetRecvStreamID () const { return m_RecvStreamID; }; uint32_t GetRecvStreamID () const { return m_RecvStreamID; };
const i2p::data::LeaseSet * GetRemoteLeaseSet () const { return m_RemoteLeaseSet; }; const i2p::data::LeaseSet * GetRemoteLeaseSet () const { return m_RemoteLeaseSet; };
bool IsEstablished () const { return !m_SendStreamID; }; bool IsEstablished () const { return m_SendStreamID; };
void HandleNextPacket (const uint8_t * buf, size_t len); void HandleNextPacket (const uint8_t * buf, size_t len);
size_t Send (uint8_t * buf, size_t len, int timeout); // timeout in seconds size_t Send (uint8_t * buf, size_t len, int timeout); // timeout in seconds

Loading…
Cancel
Save