MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / HandleRouterInfo

Method HandleRouterInfo

libi2pd/SSU2Session.cpp:1951–1982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1949 }
1950
1951 void SSU2Session::HandleRouterInfo (const uint8_t * buf, size_t len)
1952 {
1953 if (len < 2) return;
1954 // not from SessionConfirmed, we must add it instantly to use in next block
1955 std::shared_ptr<const i2p::data::RouterInfo> newRi;
1956 if (buf[0] & SSU2_ROUTER_INFO_FLAG_GZIP) // compressed?
1957 {
1958 auto ri = ExtractRouterInfo (buf, len);
1959 if (ri)
1960 newRi = i2p::data::netdb.AddRouterInfo (ri->GetBuffer (), ri->GetBufferLen ());
1961 }
1962 else // use buffer directly. TODO: handle frag
1963 newRi = i2p::data::netdb.AddRouterInfo (buf + 2, len - 2);
1964
1965 if (newRi)
1966 {
1967 auto remoteIdentity = GetRemoteIdentity ();
1968 if (remoteIdentity && remoteIdentity->GetIdentHash () == newRi->GetIdentHash ())
1969 {
1970 // peer's RouterInfo update
1971 SetRemoteIdentity (newRi->GetIdentity ());
1972 auto address = m_RemoteEndpoint.address ().is_v6 () ? newRi->GetSSU2V6Address () : newRi->GetSSU2V4Address ();
1973 if (address)
1974 {
1975 m_Address = address;
1976 if (IsOutgoing () && m_RelayTag && !address->IsIntroducer ())
1977 m_RelayTag = 0; // not longer introducer
1978 }
1979 }
1980 i2p::transport::transports.UpdatePeerParams (newRi);
1981 }
1982 }
1983
1984 void SSU2Session::HandleAck (const uint8_t * buf, size_t len)
1985 {

Callers

nothing calls this directly

Calls 8

AddRouterInfoMethod · 0.80
GetSSU2V6AddressMethod · 0.80
GetSSU2V4AddressMethod · 0.80
IsIntroducerMethod · 0.80
UpdatePeerParamsMethod · 0.80
GetBufferMethod · 0.45
GetBufferLenMethod · 0.45
GetIdentityMethod · 0.45

Tested by

no test coverage detected