diff --git a/llarp/quic/endpoint.cpp b/llarp/quic/endpoint.cpp index ddb0ca3f0..89c0270aa 100644 --- a/llarp/quic/endpoint.cpp +++ b/llarp/quic/endpoint.cpp @@ -185,9 +185,15 @@ namespace llarp::quic std::memcpy(&buf_[header_size], data.data(), data.size()); bstring_view outgoing{buf_.data(), outgoing_len}; - service_endpoint.SendToOrQueue(to, outgoing, service::ProtocolType::QUIC); - LogDebug("[", to, "]: sent ", outgoing.size(), " bytes"); - LogTrace("Full quic data: ", buffer_printer{outgoing}); + if (service_endpoint.SendToOrQueue(to, outgoing, service::ProtocolType::QUIC)) + { + LogDebug("[", to, "]: sent ", outgoing.size(), " bytes"); + LogTrace("Full quic data: ", buffer_printer{outgoing}); + } + else + { + LogDebug("Failed to send to quic endpoint ", to, "; was sending ", outgoing.size(), "B"); + } return {}; } diff --git a/llarp/quic/tunnel.cpp b/llarp/quic/tunnel.cpp index c972032c9..aaa9cc909 100644 --- a/llarp/quic/tunnel.cpp +++ b/llarp/quic/tunnel.cpp @@ -603,6 +603,7 @@ namespace llarp::quic quic::Endpoint* ep = nullptr; if (type == CLIENT_TO_SERVER) { + LogTrace("packet is client-to-server from client pport ", pseudo_port); // Client-to-server: the header port is the return port remote.setPort(pseudo_port); if (!server_) @@ -614,6 +615,7 @@ namespace llarp::quic } else if (type == SERVER_TO_CLIENT) { + LogTrace("packet is server-to-client to client pport ", pseudo_port); // Server-to-client: the header port tells us which client tunnel this is going to if (auto it = client_tunnels_.find(pseudo_port); it != client_tunnels_.end()) ep = it->second.client.get(); @@ -627,7 +629,10 @@ namespace llarp::quic // The server doesn't send back the port because we already know it 1-to-1 from our outgoing // connection. if (auto conn = static_cast(*ep).get_connection()) + { remote.setPort(conn->path.remote.port()); + LogTrace("remote port is ", remote.getPort()); + } else { LogWarn("Incoming quic to a quic::Client without an active quic::Connection; dropping"); diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index cc0a3104e..934fb6329 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -1355,18 +1355,22 @@ namespace llarp Endpoint::SendToOrQueue(ConvoTag tag, const llarp_buffer_t& pkt, ProtocolType t) { if (tag.IsZero()) + { + LogWarn("SendToOrQueue failed: convo tag is zero"); return false; - LogWarn("sent to tag T=", tag); + } if (auto maybe = GetEndpointWithConvoTag(tag)) { return SendToOrQueue(*maybe, pkt, t); } + LogDebug("SendToOrQueue failed: no endpoint for convo tag ", tag); return false; } bool Endpoint::SendToOrQueue(const RouterID& addr, const llarp_buffer_t& buf, ProtocolType t) { + LogTrace("SendToOrQueue: sending to snode ", addr); auto pkt = std::make_shared(); if (!pkt->Load(buf)) return false; @@ -1484,13 +1488,18 @@ namespace llarp bool Endpoint::SendToOrQueue(const Address& remote, const llarp_buffer_t& data, ProtocolType t) { + LogTrace("SendToOrQueue: sending to address ", remote); if (data.sz == 0) + { + LogTrace("SendToOrQueue: dropping because data.sz == 0"); return false; - // inbound converstation + } + // inbound conversation const auto now = Now(); if (HasInboundConvo(remote)) { + LogTrace("Have inbound convo"); auto transfer = std::make_shared(); ProtocolFrame& f = transfer->T; f.R = 0; @@ -1562,25 +1571,34 @@ namespace llarp }); return true; } + else + { + LogTrace("SendToOrQueue failed to return via inbound: no path"); + } + } + else + { + LogWarn("Have inbound convo but get-best returned none; bug?"); } } else { + LogTrace("Not an inbound convo"); auto& sessions = m_state->m_RemoteSessions; auto range = sessions.equal_range(remote); - auto itr = range.first; - while (itr != range.second) + for (auto itr = range.first; itr != range.second; ++itr) { if (itr->second->ReadyToSend()) { + LogTrace("Found an inbound session to use to reach ", remote); itr->second->AsyncEncryptAndSendTo(data, t); return true; } - ++itr; } // if we want to make an outbound session if (WantsOutboundSession(remote)) { + LogTrace("Making an outbound session and queuing the data"); // add pending traffic auto& traffic = m_state->m_PendingTraffic; traffic[remote].emplace_back(data, t); @@ -1603,6 +1621,10 @@ namespace llarp 1500ms); return true; } + else + { + LogDebug("SendOrQueue failed: no inbound/outbound sessions"); + } } return false; }