|
|
@ -29,12 +29,14 @@ namespace tunnel |
|
|
|
|
|
|
|
|
|
|
|
void Tunnel::Build (uint32_t replyMsgID, std::shared_ptr<OutboundTunnel> outboundTunnel) |
|
|
|
void Tunnel::Build (uint32_t replyMsgID, std::shared_ptr<OutboundTunnel> outboundTunnel) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef WITH_EVENTS |
|
|
|
|
|
|
|
std::string peers = i2p::context.GetIdentity()->GetIdentHash().ToBase64(); |
|
|
|
|
|
|
|
#endif |
|
|
|
auto numHops = m_Config->GetNumHops (); |
|
|
|
auto numHops = m_Config->GetNumHops (); |
|
|
|
int numRecords = numHops <= STANDARD_NUM_RECORDS ? STANDARD_NUM_RECORDS : numHops; |
|
|
|
int numRecords = numHops <= STANDARD_NUM_RECORDS ? STANDARD_NUM_RECORDS : numHops; |
|
|
|
auto msg = NewI2NPShortMessage (); |
|
|
|
auto msg = NewI2NPShortMessage (); |
|
|
|
*msg->GetPayload () = numRecords; |
|
|
|
*msg->GetPayload () = numRecords; |
|
|
|
msg->len += numRecords*TUNNEL_BUILD_RECORD_SIZE + 1; |
|
|
|
msg->len += numRecords*TUNNEL_BUILD_RECORD_SIZE + 1; |
|
|
|
|
|
|
|
|
|
|
|
// shuffle records
|
|
|
|
// shuffle records
|
|
|
|
std::vector<int> recordIndicies; |
|
|
|
std::vector<int> recordIndicies; |
|
|
|
for (int i = 0; i < numRecords; i++) recordIndicies.push_back(i); |
|
|
|
for (int i = 0; i < numRecords; i++) recordIndicies.push_back(i); |
|
|
@ -55,8 +57,15 @@ namespace tunnel |
|
|
|
hop->CreateBuildRequestRecord (records + idx*TUNNEL_BUILD_RECORD_SIZE, msgID); |
|
|
|
hop->CreateBuildRequestRecord (records + idx*TUNNEL_BUILD_RECORD_SIZE, msgID); |
|
|
|
hop->recordIndex = idx; |
|
|
|
hop->recordIndex = idx; |
|
|
|
i++; |
|
|
|
i++; |
|
|
|
|
|
|
|
#ifdef WITH_EVENTS |
|
|
|
|
|
|
|
peers += ":" + hop->ident->GetIdentHash().ToBase64(); |
|
|
|
|
|
|
|
#endif |
|
|
|
hop = hop->next; |
|
|
|
hop = hop->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef WITH_EVENTS |
|
|
|
|
|
|
|
EmitTunnelEvent("tunnel.build", this, peers); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// fill up fake records with random data
|
|
|
|
// fill up fake records with random data
|
|
|
|
for (int i = numHops; i < numRecords; i++) |
|
|
|
for (int i = numHops; i < numRecords; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -182,6 +191,13 @@ namespace tunnel |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Tunnel::SetState(TunnelState state) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_State = state; |
|
|
|
|
|
|
|
EmitTunnelEvent("tunnel.state", this, state); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Tunnel::PrintHops (std::stringstream& s) const |
|
|
|
void Tunnel::PrintHops (std::stringstream& s) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
// hops are in inverted order, we must print in direct order
|
|
|
|
// hops are in inverted order, we must print in direct order
|
|
|
@ -778,7 +794,7 @@ namespace tunnel |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (config) |
|
|
|
if (config) |
|
|
|
return CreateTunnel<InboundTunnel>(config, outboundTunnel); |
|
|
|
return CreateTunnel<InboundTunnel>(config, outboundTunnel); |
|
|
|
else |
|
|
|
else |
|
|
|
return CreateZeroHopsInboundTunnel (); |
|
|
|
return CreateZeroHopsInboundTunnel (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|