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

Method HandleReceivedAddress

libi2pd_client/BOB.cpp:85–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83 }
84
85 void BOBI2PInboundTunnel::HandleReceivedAddress (const boost::system::error_code& ecode, std::size_t bytes_transferred,
86 std::shared_ptr<AddressReceiver> receiver)
87 {
88 if (ecode)
89 LogPrint (eLogError, "BOB: Inbound tunnel read error: ", ecode.message ());
90 else
91 {
92 receiver->bufferOffset += bytes_transferred;
93 receiver->buffer[receiver->bufferOffset] = 0;
94 char * eol = strchr (receiver->buffer, '\n');
95 if (eol)
96 {
97 *eol = 0;
98 if (eol != receiver->buffer && eol[-1] == '\r') eol[-1] = 0; // workaround for Transmission, it sends '\r\n' terminated address
99 receiver->data = (uint8_t *)eol + 1;
100 receiver->dataLen = receiver->bufferOffset - (eol - receiver->buffer + 1);
101 auto addr = context.GetAddressBook ().GetAddress (receiver->buffer);
102 if (!addr)
103 {
104 LogPrint (eLogError, "BOB: Address ", receiver->buffer, " not found");
105 return;
106 }
107 if (addr->IsIdentHash ())
108 {
109 auto leaseSet = GetLocalDestination ()->FindLeaseSet (addr->identHash);
110 if (leaseSet)
111 CreateConnection (receiver, leaseSet);
112 else
113 GetLocalDestination ()->RequestDestination (addr->identHash,
114 std::bind (&BOBI2PInboundTunnel::HandleDestinationRequestComplete,
115 this, std::placeholders::_1, receiver));
116 }
117 else
118 GetLocalDestination ()->RequestDestinationWithEncryptedLeaseSet (addr->blindedPublicKey,
119 std::bind (&BOBI2PInboundTunnel::HandleDestinationRequestComplete,
120 this, std::placeholders::_1, receiver));
121 }
122 else
123 {
124 if (receiver->bufferOffset < BOB_COMMAND_BUFFER_SIZE)
125 ReceiveAddress (receiver);
126 else
127 LogPrint (eLogError, "BOB: Missing inbound address");
128 }
129 }
130 }
131
132 void BOBI2PInboundTunnel::HandleDestinationRequestComplete (std::shared_ptr<i2p::data::LeaseSet> leaseSet, std::shared_ptr<AddressReceiver> receiver)
133 {

Callers

nothing calls this directly

Calls 6

LogPrintFunction · 0.85
IsIdentHashMethod · 0.80
GetAddressMethod · 0.45
FindLeaseSetMethod · 0.45
RequestDestinationMethod · 0.45

Tested by

no test coverage detected