Browse Source

handle RouterInfo from NTCP2 in netdb's thread

pull/1274/head
orignal 6 years ago
parent
commit
d7081c5f23
  1. 1
      libi2pd/I2NPProtocol.h
  2. 5
      libi2pd/NTCP2.cpp
  3. 4
      libi2pd/NetDb.cpp

1
libi2pd/I2NPProtocol.h

@ -75,6 +75,7 @@ namespace i2p
enum I2NPMessageType enum I2NPMessageType
{ {
eI2NPDummyMsg = 0,
eI2NPDatabaseStore = 1, eI2NPDatabaseStore = 1,
eI2NPDatabaseLookup = 2, eI2NPDatabaseLookup = 2,
eI2NPDatabaseSearchReply = 3, eI2NPDatabaseSearchReply = 3,

5
libi2pd/NTCP2.cpp

@ -695,8 +695,7 @@ namespace transport
SendTerminationAndTerminate (eNTCP2IncorrectSParameter); SendTerminationAndTerminate (eNTCP2IncorrectSParameter);
return; return;
} }
i2p::data::netdb.PostI2NPMsg (CreateI2NPMessage (eI2NPDummyMsg, buf.data () + 4, size - 1)); // TODO: should insert ri and not parse it twice
i2p::data::netdb.AddRouterInfo (buf.data () + 4, size - 1); // TODO: should insert ri and not parse it twice
// TODO: process options // TODO: process options
// ready to communicate // ready to communicate
@ -861,7 +860,7 @@ namespace transport
case eNTCP2BlkRouterInfo: case eNTCP2BlkRouterInfo:
{ {
LogPrint (eLogDebug, "NTCP2: RouterInfo flag=", (int)frame[offset]); LogPrint (eLogDebug, "NTCP2: RouterInfo flag=", (int)frame[offset]);
i2p::data::netdb.AddRouterInfo (frame + offset + 1, size - 1); i2p::data::netdb.PostI2NPMsg (CreateI2NPMessage (eI2NPDummyMsg, frame + offset + 1, size - 1));
break; break;
} }
case eNTCP2BlkI2NPMessage: case eNTCP2BlkI2NPMessage:

4
libi2pd/NetDb.cpp

@ -98,6 +98,10 @@ namespace data
case eI2NPDatabaseLookup: case eI2NPDatabaseLookup:
HandleDatabaseLookupMsg (msg); HandleDatabaseLookupMsg (msg);
break; break;
case eI2NPDummyMsg:
// plain RouterInfo from NTCP2 for now
AddRouterInfo (msg->GetPayload (), msg->GetPayloadLength ());
break;
default: // WTF? default: // WTF?
LogPrint (eLogError, "NetDb: unexpected message type ", (int) msg->GetTypeID ()); LogPrint (eLogError, "NetDb: unexpected message type ", (int) msg->GetTypeID ());
//i2p::HandleI2NPMessage (msg); //i2p::HandleI2NPMessage (msg);

Loading…
Cancel
Save