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

Method ExtractExpirationTimestamp

libi2pd/LeaseSet.cpp:178–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176 }
177
178 uint64_t LeaseSet::ExtractExpirationTimestamp (const uint8_t * buf, size_t len) const
179 {
180 if (!m_Identity) return 0;
181 size_t size = m_Identity->GetFullLen ();
182 if (size > len) return 0;
183 size += 256; // encryption key
184 size += m_Identity->GetSigningPublicKeyLen (); // unused signing key
185 if (size > len) return 0;
186 uint8_t num = buf[size];
187 size++; // num
188 if (size + num*LEASE_SIZE > len) return 0;
189 uint64_t timestamp= 0 ;
190 for (int i = 0; i < num; i++)
191 {
192 size += 36; // gateway (32) + tunnelId(4)
193 auto endDate = bufbe64toh (buf + size);
194 size += 8; // end date
195 if (!timestamp || endDate < timestamp)
196 timestamp = endDate;
197 }
198 return timestamp;
199 }
200
201 bool LeaseSet::IsNewer (const uint8_t * buf, size_t len) const
202 {

Callers

nothing calls this directly

Calls 3

bufbe64tohFunction · 0.85
GetFullLenMethod · 0.45

Tested by

no test coverage detected