| 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 | { |
nothing calls this directly
no test coverage detected