mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
handle NTCP2 RouterInfo flag
This commit is contained in:
parent
0e9074aaba
commit
42ed312384
|
@ -695,7 +695,7 @@ namespace transport
|
|||
SendTerminationAndTerminate (eNTCP2IncorrectSParameter);
|
||||
return;
|
||||
}
|
||||
i2p::data::netdb.PostI2NPMsg (CreateI2NPMessage (eI2NPDummyMsg, buf.data () + 4, size - 1)); // TODO: should insert ri and not parse it twice
|
||||
i2p::data::netdb.PostI2NPMsg (CreateI2NPMessage (eI2NPDummyMsg, buf.data () + 3, size)); // TODO: should insert ri and not parse it twice
|
||||
// TODO: process options
|
||||
|
||||
// ready to communicate
|
||||
|
@ -860,7 +860,7 @@ namespace transport
|
|||
case eNTCP2BlkRouterInfo:
|
||||
{
|
||||
LogPrint (eLogDebug, "NTCP2: RouterInfo flag=", (int)frame[offset]);
|
||||
i2p::data::netdb.PostI2NPMsg (CreateI2NPMessage (eI2NPDummyMsg, frame + offset + 1, size - 1));
|
||||
i2p::data::netdb.PostI2NPMsg (CreateI2NPMessage (eI2NPDummyMsg, frame + offset, size));
|
||||
break;
|
||||
}
|
||||
case eNTCP2BlkI2NPMessage:
|
||||
|
|
|
@ -73,6 +73,8 @@ namespace transport
|
|||
eNTCP2Banned, // 17
|
||||
};
|
||||
|
||||
// RouterInfo flags
|
||||
const uint8_t NTCP2_ROUTER_INFO_FLAG_REQUEST_FLOOD = 0x01;
|
||||
|
||||
typedef std::array<uint8_t, NTCP2_UNENCRYPTED_FRAME_MAX_SIZE> NTCP2FrameBuffer;
|
||||
struct NTCP2Establisher
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "I2NPProtocol.h"
|
||||
#include "Tunnel.h"
|
||||
#include "Transports.h"
|
||||
#include "NTCP2.h"
|
||||
#include "RouterContext.h"
|
||||
#include "Garlic.h"
|
||||
#include "NetDb.hpp"
|
||||
|
@ -99,8 +100,8 @@ namespace data
|
|||
HandleDatabaseLookupMsg (msg);
|
||||
break;
|
||||
case eI2NPDummyMsg:
|
||||
// plain RouterInfo from NTCP2 for now
|
||||
AddRouterInfo (msg->GetPayload (), msg->GetPayloadLength ());
|
||||
// plain RouterInfo from NTCP2 with flag for now
|
||||
HandleNTCP2RouterInfoMsg (msg);
|
||||
break;
|
||||
default: // WTF?
|
||||
LogPrint (eLogError, "NetDb: unexpected message type ", (int) msg->GetTypeID ());
|
||||
|
@ -574,6 +575,16 @@ namespace data
|
|||
transports.SendMessage (from, dest->CreateRequestMessage (nullptr, nullptr));
|
||||
}
|
||||
|
||||
void NetDb::HandleNTCP2RouterInfoMsg (std::shared_ptr<const I2NPMessage> m)
|
||||
{
|
||||
uint8_t flood = m->GetPayload ()[0] & NTCP2_ROUTER_INFO_FLAG_REQUEST_FLOOD;
|
||||
bool updated = AddRouterInfo (m->GetPayload () + 1, m->GetPayloadLength () - 1); // without flag
|
||||
if (flood && updated && context.IsFloodfill ())
|
||||
{
|
||||
// TODO: flood
|
||||
LogPrint (eLogInfo, "NetDb: NTCP RouterInfo flood is not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
void NetDb::HandleDatabaseStoreMsg (std::shared_ptr<const I2NPMessage> m)
|
||||
{
|
||||
|
|
|
@ -65,7 +65,8 @@ namespace data
|
|||
void HandleDatabaseStoreMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
void HandleDatabaseSearchReplyMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
void HandleDatabaseLookupMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
|
||||
void HandleNTCP2RouterInfoMsg (std::shared_ptr<const I2NPMessage> m);
|
||||
|
||||
std::shared_ptr<const RouterInfo> GetRandomRouter () const;
|
||||
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
|
||||
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
|
||||
|
|
Loading…
Reference in a new issue