|
|
@ -13,6 +13,7 @@ |
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
#include <set> |
|
|
|
#include <set> |
|
|
|
#include <memory> |
|
|
|
#include <memory> |
|
|
|
|
|
|
|
#include <functional> |
|
|
|
#include "Crypto.h" |
|
|
|
#include "Crypto.h" |
|
|
|
#include "I2PEndian.h" |
|
|
|
#include "I2PEndian.h" |
|
|
|
#include "Identity.h" |
|
|
|
#include "Identity.h" |
|
|
@ -149,6 +150,7 @@ namespace tunnel |
|
|
|
uint8_t * buf; |
|
|
|
uint8_t * buf; |
|
|
|
size_t len, offset, maxLen; |
|
|
|
size_t len, offset, maxLen; |
|
|
|
std::shared_ptr<i2p::tunnel::InboundTunnel> from; |
|
|
|
std::shared_ptr<i2p::tunnel::InboundTunnel> from; |
|
|
|
|
|
|
|
std::function<void ()> onDrop; |
|
|
|
|
|
|
|
|
|
|
|
I2NPMessage (): buf (nullptr),len (I2NP_HEADER_SIZE + 2), |
|
|
|
I2NPMessage (): buf (nullptr),len (I2NP_HEADER_SIZE + 2), |
|
|
|
offset(2), maxLen (0), from (nullptr) {}; // reserve 2 bytes for NTCP header
|
|
|
|
offset(2), maxLen (0), from (nullptr) {}; // reserve 2 bytes for NTCP header
|
|
|
@ -241,7 +243,6 @@ namespace tunnel |
|
|
|
SetSize (len - offset - I2NP_HEADER_SIZE); |
|
|
|
SetSize (len - offset - I2NP_HEADER_SIZE); |
|
|
|
SetChks (0); |
|
|
|
SetChks (0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ToNTCP2 () |
|
|
|
void ToNTCP2 () |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t * ntcp2 = GetNTCP2Header (); |
|
|
|
uint8_t * ntcp2 = GetNTCP2Header (); |
|
|
@ -253,6 +254,8 @@ namespace tunnel |
|
|
|
void RenewI2NPMessageHeader (); |
|
|
|
void RenewI2NPMessageHeader (); |
|
|
|
bool IsExpired () const; |
|
|
|
bool IsExpired () const; |
|
|
|
bool IsExpired (uint64_t ts) const; // in milliseconds
|
|
|
|
bool IsExpired (uint64_t ts) const; // in milliseconds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Drop () { if (onDrop) { onDrop (); onDrop = nullptr; }; } |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<int sz> |
|
|
|
template<int sz> |
|
|
|