mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-29 20:27:49 +02:00
handle I2NP messages drops
This commit is contained in:
parent
d926a31064
commit
f008478505
6 changed files with 24 additions and 4 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <string.h>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include "Crypto.h"
|
||||
#include "I2PEndian.h"
|
||||
#include "Identity.h"
|
||||
|
@ -149,7 +150,8 @@ namespace tunnel
|
|||
uint8_t * buf;
|
||||
size_t len, offset, maxLen;
|
||||
std::shared_ptr<i2p::tunnel::InboundTunnel> from;
|
||||
|
||||
std::function<void ()> onDrop;
|
||||
|
||||
I2NPMessage (): buf (nullptr),len (I2NP_HEADER_SIZE + 2),
|
||||
offset(2), maxLen (0), from (nullptr) {}; // reserve 2 bytes for NTCP header
|
||||
|
||||
|
@ -241,7 +243,6 @@ namespace tunnel
|
|||
SetSize (len - offset - I2NP_HEADER_SIZE);
|
||||
SetChks (0);
|
||||
}
|
||||
|
||||
void ToNTCP2 ()
|
||||
{
|
||||
uint8_t * ntcp2 = GetNTCP2Header ();
|
||||
|
@ -253,6 +254,8 @@ namespace tunnel
|
|||
void RenewI2NPMessageHeader ();
|
||||
bool IsExpired () const;
|
||||
bool IsExpired (uint64_t ts) const; // in milliseconds
|
||||
|
||||
void Drop () { if (onDrop) { onDrop (); onDrop = nullptr; }; }
|
||||
};
|
||||
|
||||
template<int sz>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue