From c6320724d369902a54746140e9a3053873a25404 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 1 May 2021 08:55:54 -0400 Subject: [PATCH] parameterize traffic alignement timeout in dns lookups --- llarp/handlers/tun.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/llarp/handlers/tun.cpp b/llarp/handlers/tun.cpp index f58e6c5b8..cc7dd67e5 100644 --- a/llarp/handlers/tun.cpp +++ b/llarp/handlers/tun.cpp @@ -259,27 +259,29 @@ namespace llarp return service::Address{itr->second.as_array()}; } + constexpr auto TrafficAlignmentTimeout = 10s; + bool TunEndpoint::HandleHookedDNSMessage(dns::Message msg, std::function reply) { - auto ReplyToSNodeDNSWhenReady = [self = this, reply = reply]( - RouterID snode, auto msg, bool isV6) -> bool { - return self->EnsurePathToSNode( + auto ReplyToSNodeDNSWhenReady = [this, reply](RouterID snode, auto msg, bool isV6) -> bool { + return EnsurePathToSNode( snode, - [=](const RouterID&, exit::BaseSession_ptr s, [[maybe_unused]] service::ConvoTag tag) { - self->SendDNSReply(snode, s, msg, reply, isV6); + [this, snode, msg, reply, isV6]( + const RouterID&, exit::BaseSession_ptr s, [[maybe_unused]] service::ConvoTag tag) { + SendDNSReply(snode, s, msg, reply, isV6); }); }; - auto ReplyToLokiDNSWhenReady = [self = this, reply = reply]( + auto ReplyToLokiDNSWhenReady = [this, reply]( service::Address addr, auto msg, bool isV6) -> bool { using service::Address; using service::OutboundContext; - return self->EnsurePathToService( + return EnsurePathToService( addr, - [=](const Address&, OutboundContext* ctx) { - self->SendDNSReply(addr, ctx, msg, reply, isV6); + [this, addr, msg, reply, isV6](const Address&, OutboundContext* ctx) { + SendDNSReply(addr, ctx, msg, reply, isV6); }, - 2s); + TrafficAlignmentTimeout); }; auto ReplyToDNSWhenReady = [ReplyToLokiDNSWhenReady, ReplyToSNodeDNSWhenReady]( @@ -296,14 +298,13 @@ namespace llarp } }; - auto ReplyToLokiSRVWhenReady = [self = this, reply = reply]( - service::Address addr, auto msg) -> bool { + auto ReplyToLokiSRVWhenReady = [this, reply](service::Address addr, auto msg) -> bool { using service::Address; using service::OutboundContext; - return self->EnsurePathToService( + return EnsurePathToService( addr, - [=](const Address&, OutboundContext* ctx) { + [msg, addr, reply](const Address&, OutboundContext* ctx) { if (ctx == nullptr) return; @@ -311,7 +312,7 @@ namespace llarp msg->AddSRVReply(introset.GetMatchingSRVRecords(addr.subdomain)); reply(*msg); }, - 2s); + TrafficAlignmentTimeout); }; if (msg.answers.size() > 0) @@ -923,7 +924,7 @@ namespace llarp } self->SendToOrQueue(addr, pkt.ConstBuffer(), service::ProtocolType::Exit); }, - 1s); + TrafficAlignmentTimeout); return; } bool rewriteAddrs = true;