|
|
@ -42,14 +42,14 @@ namespace data |
|
|
|
// leases
|
|
|
|
// leases
|
|
|
|
for (auto it: tunnels) |
|
|
|
for (auto it: tunnels) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Lease lease; |
|
|
|
memcpy (m_Buffer + m_BufferLen, it->GetNextIdentHash (), 32); |
|
|
|
memcpy (lease.tunnelGateway, it->GetNextIdentHash (), 32); |
|
|
|
m_BufferLen += 32; // gateway id
|
|
|
|
lease.tunnelID = htobe32 (it->GetNextTunnelID ()); |
|
|
|
htobe32buf (m_Buffer + m_BufferLen, it->GetNextTunnelID ()); |
|
|
|
|
|
|
|
m_BufferLen += 4; // tunnel id
|
|
|
|
uint64_t ts = it->GetCreationTime () + i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT - 60; // 1 minute before expiration
|
|
|
|
uint64_t ts = it->GetCreationTime () + i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT - 60; // 1 minute before expiration
|
|
|
|
ts *= 1000; // in milliseconds
|
|
|
|
ts *= 1000; // in milliseconds
|
|
|
|
lease.endDate = htobe64 (ts); |
|
|
|
htobe64buf (m_Buffer + m_BufferLen, ts); |
|
|
|
memcpy(m_Buffer + m_BufferLen, &lease, sizeof(Lease)); |
|
|
|
m_BufferLen += 8; // end date
|
|
|
|
m_BufferLen += sizeof (Lease); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// signature
|
|
|
|
// signature
|
|
|
|
localDestination->Sign (m_Buffer, m_BufferLen, m_Buffer + m_BufferLen); |
|
|
|
localDestination->Sign (m_Buffer, m_BufferLen, m_Buffer + m_BufferLen); |
|
|
@ -82,11 +82,13 @@ namespace data |
|
|
|
for (int i = 0; i < num; i++) |
|
|
|
for (int i = 0; i < num; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Lease lease; |
|
|
|
Lease lease; |
|
|
|
memcpy (&lease, leases, sizeof(Lease)); |
|
|
|
lease.tunnelGateway = leases; |
|
|
|
lease.tunnelID = be32toh (lease.tunnelID); |
|
|
|
leases += 32; // gateway
|
|
|
|
lease.endDate = be64toh (lease.endDate); |
|
|
|
lease.tunnelID = bufbe32toh (leases); |
|
|
|
|
|
|
|
leases += 4; // tunnel ID
|
|
|
|
|
|
|
|
lease.endDate = bufbe64toh (leases); |
|
|
|
|
|
|
|
leases += 8; // end date
|
|
|
|
m_Leases.push_back (lease); |
|
|
|
m_Leases.push_back (lease); |
|
|
|
leases += sizeof (Lease); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check if lease's gateway is in our netDb
|
|
|
|
// check if lease's gateway is in our netDb
|
|
|
|
if (!netdb.FindRouter (lease.tunnelGateway)) |
|
|
|
if (!netdb.FindRouter (lease.tunnelGateway)) |
|
|
|