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

Method ExtractRouterInfo

libi2pd/SSU2Session.cpp:3216–3236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3214 }
3215
3216 std::shared_ptr<const i2p::data::RouterInfo> SSU2Session::ExtractRouterInfo (const uint8_t * buf, size_t size)
3217 {
3218 if (size < 2) return nullptr;
3219 // TODO: handle frag
3220 std::shared_ptr<const i2p::data::RouterInfo> ri;
3221 if (buf[0] & SSU2_ROUTER_INFO_FLAG_GZIP)
3222 {
3223 i2p::data::GzipInflator inflator;
3224 uint8_t uncompressed[i2p::data::MAX_RI_BUFFER_SIZE];
3225 size_t uncompressedSize = inflator.Inflate (buf + 2, size - 2, uncompressed, i2p::data::MAX_RI_BUFFER_SIZE);
3226 if (uncompressedSize && uncompressedSize <= i2p::data::MAX_RI_BUFFER_SIZE)
3227 ri = std::make_shared<i2p::data::RouterInfo>(uncompressed, uncompressedSize);
3228 else
3229 LogPrint (eLogInfo, "SSU2: RouterInfo decompression failed ", uncompressedSize);
3230 }
3231 else if (size <= i2p::data::MAX_RI_BUFFER_SIZE + 2)
3232 ri = std::make_shared<i2p::data::RouterInfo>(buf + 2, size - 2);
3233 else
3234 LogPrint (eLogInfo, "SSU2: RouterInfo is too long ", size);
3235 return ri;
3236 }
3237
3238 bool SSU2Session::UpdateReceivePacketNum (uint32_t packetNum)
3239 {

Callers

nothing calls this directly

Calls 2

LogPrintFunction · 0.85
InflateMethod · 0.80

Tested by

no test coverage detected