more client to snode quic fixes

pull/1576/head
Jeff Becker 3 years ago
parent 0ee40c1720
commit 1ea77e6a68
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -119,6 +119,8 @@ namespace llarp
if (not quic)
return false;
quic->receive_packet(tag, buf.underlying);
m_LastActive = m_Parent->Now();
m_TxRate += buf.underlying.sz;
return true;
}
// queue overflow

@ -115,10 +115,10 @@ namespace llarp
}
}
std::vector<byte_t> data{};
data.resize(payload.sz);
std::copy_n(payload.base, data.size(), data.data());
ObtainSNodeSession(*rid, [data, type](auto session) {
if (not m_Router->ConnectionToRouterAllowed(*rid))
return false;
ObtainSNodeSession(*rid, [data = payload.copy(), type](auto session) {
if (session and session->IsReady())
{
session->SendPacketToRemote(data, type);
@ -141,20 +141,28 @@ namespace llarp
return false;
if (auto* rid = std::get_if<RouterID>(&addr))
{
ObtainSNodeSession(
*rid, [hook, routerID = *rid](std::shared_ptr<exit::BaseSession> session) {
if (session and session->IsReady())
{
if (auto path = session->GetPathByRouter(routerID))
if (m_SNodeKeys.count(PubKey{*rid}) or m_Router->ConnectionToRouterAllowed(*rid))
{
ObtainSNodeSession(
*rid, [hook, routerID = *rid](std::shared_ptr<exit::BaseSession> session) {
if (session and session->IsReady())
{
hook(service::ConvoTag{path->RXID().as_array()});
if (auto path = session->GetPathByRouter(routerID))
{
hook(service::ConvoTag{path->RXID().as_array()});
}
else
hook(std::nullopt);
}
else
hook(std::nullopt);
}
else
hook(std::nullopt);
});
});
}
else
{
// probably a client
hook(GetBestConvoTagFor(addr));
}
}
return true;
}

@ -115,6 +115,15 @@ llarp_buffer_t::read_until(char c_delim, byte_t* result, size_t resultsize)
return 0;
}
std::vector<byte_t>
llarp_buffer_t::copy() const
{
std::vector<byte_t> copy;
copy.resize(sz);
std::copy_n(base, sz, copy.data());
return copy;
}
bool
operator==(const llarp_buffer_t& buff, const char* c_str)
{

@ -171,6 +171,10 @@ struct llarp_buffer_t
size_t
read_until(char delim, byte_t* result, size_t resultlen);
/// make a copy of this buffer
std::vector<byte_t>
copy() const;
private:
friend struct ManagedBuffer;
llarp_buffer_t(const llarp_buffer_t&) = default;

Loading…
Cancel
Save