mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 06:54:15 +00:00
insert RouterInfo from SessionConfirmed into netdb immediately
This commit is contained in:
parent
9fec1a86cf
commit
a3e19931f0
@ -240,11 +240,10 @@ namespace data
|
|||||||
m_HiddenMode = hide;
|
m_HiddenMode = hide;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetDb::AddRouterInfo (const uint8_t * buf, int len)
|
std::shared_ptr<const RouterInfo> NetDb::AddRouterInfo (const uint8_t * buf, int len)
|
||||||
{
|
{
|
||||||
bool updated;
|
bool updated;
|
||||||
AddRouterInfo (buf, len, updated);
|
return AddRouterInfo (buf, len, updated);
|
||||||
return updated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::AddRouterInfo (const uint8_t * buf, int len, bool& updated)
|
std::shared_ptr<const RouterInfo> NetDb::AddRouterInfo (const uint8_t * buf, int len, bool& updated)
|
||||||
@ -436,12 +435,15 @@ namespace data
|
|||||||
|
|
||||||
// try reseeding from floodfill first if specified
|
// try reseeding from floodfill first if specified
|
||||||
std::string riPath;
|
std::string riPath;
|
||||||
if(i2p::config::GetOption("reseed.floodfill", riPath)) {
|
if(i2p::config::GetOption("reseed.floodfill", riPath))
|
||||||
|
{
|
||||||
auto ri = std::make_shared<RouterInfo>(riPath);
|
auto ri = std::make_shared<RouterInfo>(riPath);
|
||||||
if (ri->IsFloodfill()) {
|
if (ri->IsFloodfill())
|
||||||
|
{
|
||||||
const uint8_t * riData = ri->GetBuffer();
|
const uint8_t * riData = ri->GetBuffer();
|
||||||
int riLen = ri->GetBufferLen();
|
int riLen = ri->GetBufferLen();
|
||||||
if(!i2p::data::netdb.AddRouterInfo(riData, riLen)) {
|
if (!i2p::data::netdb.AddRouterInfo(riData, riLen))
|
||||||
|
{
|
||||||
// bad router info
|
// bad router info
|
||||||
LogPrint(eLogError, "NetDb: Bad router info");
|
LogPrint(eLogError, "NetDb: Bad router info");
|
||||||
return;
|
return;
|
||||||
|
@ -69,7 +69,7 @@ namespace data
|
|||||||
void Start ();
|
void Start ();
|
||||||
void Stop ();
|
void Stop ();
|
||||||
|
|
||||||
bool AddRouterInfo (const uint8_t * buf, int len);
|
std::shared_ptr<const RouterInfo> AddRouterInfo (const uint8_t * buf, int len);
|
||||||
bool AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len);
|
bool AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len);
|
||||||
bool AddLeaseSet (const IdentHash& ident, const uint8_t * buf, int len);
|
bool AddLeaseSet (const IdentHash& ident, const uint8_t * buf, int len);
|
||||||
bool AddLeaseSet2 (const IdentHash& ident, const uint8_t * buf, int len, uint8_t storeType);
|
bool AddLeaseSet2 (const IdentHash& ident, const uint8_t * buf, int len, uint8_t storeType);
|
||||||
|
@ -827,17 +827,23 @@ namespace transport
|
|||||||
LogPrint (eLogError, "SSU2: SessionConfirmed malformed RouterInfo block");
|
LogPrint (eLogError, "SSU2: SessionConfirmed malformed RouterInfo block");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SetRemoteIdentity (ri->GetRouterIdentity ());
|
|
||||||
m_Address = ri->GetSSU2AddressWithStaticKey (S, m_RemoteEndpoint.address ().is_v6 ());
|
m_Address = ri->GetSSU2AddressWithStaticKey (S, m_RemoteEndpoint.address ().is_v6 ());
|
||||||
if (!m_Address)
|
if (!m_Address)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU2: No SSU2 address with static key found in SessionConfirmed");
|
LogPrint (eLogError, "SSU2: No SSU2 address with static key found in SessionConfirmed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// update RouterInfo in netdb
|
||||||
|
ri = i2p::data::netdb.AddRouterInfo (ri->GetBuffer (), ri->GetBufferLen ()); // ri points to one from netdb now
|
||||||
|
if (!ri)
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "SSU2: Couldn't update RouterInfo from SessionConfirmed in netdb");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SetRemoteIdentity (ri->GetRouterIdentity ());
|
||||||
AdjustMaxPayloadSize ();
|
AdjustMaxPayloadSize ();
|
||||||
m_Server.AddSessionByRouterHash (shared_from_this ()); // we know remote router now
|
m_Server.AddSessionByRouterHash (shared_from_this ()); // we know remote router now
|
||||||
m_RemoteTransports = ri->GetCompatibleTransports (false);
|
m_RemoteTransports = ri->GetCompatibleTransports (false);
|
||||||
i2p::data::netdb.PostI2NPMsg (CreateDatabaseStoreMsg (ri)); // TODO: should insert ri
|
|
||||||
// handle other blocks
|
// handle other blocks
|
||||||
HandlePayload (decryptedPayload.data () + riSize + 3, decryptedPayload.size () - riSize - 3);
|
HandlePayload (decryptedPayload.data () + riSize + 3, decryptedPayload.size () - riSize - 3);
|
||||||
Established ();
|
Established ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user