|
|
@ -72,19 +72,26 @@ namespace client |
|
|
|
if (eol != receiver->buffer && eol[-1] == '\r') eol[-1] = 0; // workaround for Transmission, it sends '\r\n' terminated address
|
|
|
|
if (eol != receiver->buffer && eol[-1] == '\r') eol[-1] = 0; // workaround for Transmission, it sends '\r\n' terminated address
|
|
|
|
receiver->data = (uint8_t *)eol + 1; |
|
|
|
receiver->data = (uint8_t *)eol + 1; |
|
|
|
receiver->dataLen = receiver->bufferOffset - (eol - receiver->buffer + 1); |
|
|
|
receiver->dataLen = receiver->bufferOffset - (eol - receiver->buffer + 1); |
|
|
|
i2p::data::IdentHash ident; |
|
|
|
auto addr = context.GetAddressBook ().GetAddress (receiver->buffer); |
|
|
|
if (!context.GetAddressBook ().GetIdentHash (receiver->buffer, ident)) |
|
|
|
if (!addr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogError, "BOB: address ", receiver->buffer, " not found"); |
|
|
|
LogPrint (eLogError, "BOB: address ", receiver->buffer, " not found"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
auto leaseSet = GetLocalDestination ()->FindLeaseSet (ident); |
|
|
|
if (addr->IsIdentHash ()) |
|
|
|
if (leaseSet) |
|
|
|
{ |
|
|
|
CreateConnection (receiver, leaseSet); |
|
|
|
auto leaseSet = GetLocalDestination ()->FindLeaseSet (addr->identHash); |
|
|
|
|
|
|
|
if (leaseSet) |
|
|
|
|
|
|
|
CreateConnection (receiver, leaseSet); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
GetLocalDestination ()->RequestDestination (addr->identHash, |
|
|
|
|
|
|
|
std::bind (&BOBI2PInboundTunnel::HandleDestinationRequestComplete, |
|
|
|
|
|
|
|
this, std::placeholders::_1, receiver)); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
GetLocalDestination ()->RequestDestination (ident, |
|
|
|
GetLocalDestination ()->RequestDestinationWithEncryptedLeaseSet (addr->blindedPublicKey, |
|
|
|
std::bind (&BOBI2PInboundTunnel::HandleDestinationRequestComplete, |
|
|
|
std::bind (&BOBI2PInboundTunnel::HandleDestinationRequestComplete, |
|
|
|
this, std::placeholders::_1, receiver)); |
|
|
|
this, std::placeholders::_1, receiver)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -540,29 +547,37 @@ namespace client |
|
|
|
void BOBCommandSession::LookupCommandHandler (const char * operand, size_t len) |
|
|
|
void BOBCommandSession::LookupCommandHandler (const char * operand, size_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogDebug, "BOB: lookup ", operand); |
|
|
|
LogPrint (eLogDebug, "BOB: lookup ", operand); |
|
|
|
i2p::data::IdentHash ident; |
|
|
|
auto addr = context.GetAddressBook ().GetAddress (operand); |
|
|
|
if (!context.GetAddressBook ().GetIdentHash (operand, ident)) |
|
|
|
if (!addr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SendReplyError ("Address Not found"); |
|
|
|
SendReplyError ("Address Not found"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
auto localDestination = m_CurrentDestination ? m_CurrentDestination->GetLocalDestination () : i2p::client::context.GetSharedLocalDestination (); |
|
|
|
auto localDestination = m_CurrentDestination ? m_CurrentDestination->GetLocalDestination () : i2p::client::context.GetSharedLocalDestination (); |
|
|
|
auto leaseSet = localDestination->FindLeaseSet (ident); |
|
|
|
if (addr->IsIdentHash ()) |
|
|
|
if (leaseSet) |
|
|
|
{ |
|
|
|
SendReplyOK (leaseSet->GetIdentity ()->ToBase64 ().c_str ()); |
|
|
|
// we might have leaseset already
|
|
|
|
else |
|
|
|
auto leaseSet = localDestination->FindLeaseSet (addr->identHash); |
|
|
|
{ |
|
|
|
if (leaseSet) |
|
|
|
auto s = shared_from_this (); |
|
|
|
{ |
|
|
|
localDestination->RequestDestination (ident, |
|
|
|
SendReplyOK (leaseSet->GetIdentity ()->ToBase64 ().c_str ()); |
|
|
|
[s](std::shared_ptr<i2p::data::LeaseSet> ls) |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// trying to request
|
|
|
|
|
|
|
|
auto s = shared_from_this (); |
|
|
|
|
|
|
|
auto requstCallback = |
|
|
|
|
|
|
|
[s](std::shared_ptr<i2p::data::LeaseSet> ls) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ls) |
|
|
|
if (ls) |
|
|
|
s->SendReplyOK (ls->GetIdentity ()->ToBase64 ().c_str ()); |
|
|
|
s->SendReplyOK (ls->GetIdentity ()->ToBase64 ().c_str ()); |
|
|
|
else |
|
|
|
else |
|
|
|
s->SendReplyError ("LeaseSet Not found"); |
|
|
|
s->SendReplyError ("LeaseSet Not found"); |
|
|
|
} |
|
|
|
}; |
|
|
|
); |
|
|
|
if (addr->IsIdentHash ()) |
|
|
|
} |
|
|
|
localDestination->RequestDestination (addr->identHash, requstCallback); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
localDestination->RequestDestinationWithEncryptedLeaseSet (addr->blindedPublicKey, requstCallback); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void BOBCommandSession::ClearCommandHandler (const char * operand, size_t len) |
|
|
|
void BOBCommandSession::ClearCommandHandler (const char * operand, size_t len) |
|
|
|