From 8f0330c9f22eaf120efe0c85e1fadd5c3306ac3f Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Mon, 15 Jun 2020 14:22:52 -0400 Subject: [PATCH] std::vector instead of std::array --- llarp/dns/server.cpp | 10 ++++------ llarp/dns/server.hpp | 2 +- llarp/dns/unbound_resolver.cpp | 4 ++-- llarp/dns/unbound_resolver.hpp | 3 +-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/llarp/dns/server.cpp b/llarp/dns/server.cpp index 6c56846d8..b2c7ca58d 100644 --- a/llarp/dns/server.cpp +++ b/llarp/dns/server.cpp @@ -106,12 +106,11 @@ namespace llarp } }; - auto replyFunc = [self = weak_from_this()]( - SockAddr to, std::array buf, size_t len) { + auto replyFunc = [self = weak_from_this()](SockAddr to, std::vector buf) { auto this_ptr = self.lock(); if (this_ptr) { - this_ptr->HandleUpstreamResponse(to, std::move(buf), len); + this_ptr->HandleUpstreamResponse(to, std::move(buf)); } }; @@ -166,12 +165,11 @@ namespace llarp } void - Proxy::HandleUpstreamResponse(SockAddr to, std::array buf, size_t len) + Proxy::HandleUpstreamResponse(SockAddr to, std::vector buf) { auto self = shared_from_this(); - LogicCall(m_ServerLogic, [to, buffer = std::move(buf), self, len]() { + LogicCall(m_ServerLogic, [to, buffer = std::move(buf), self]() { llarp_buffer_t buf(buffer); - buf.sz = len; self->SendServerMessageBufferTo(to, buf); }); } diff --git a/llarp/dns/server.hpp b/llarp/dns/server.hpp index fb91cbdbb..5ecaee124 100644 --- a/llarp/dns/server.hpp +++ b/llarp/dns/server.hpp @@ -72,7 +72,7 @@ namespace llarp SendServerMessageTo(const SockAddr& to, Message msg); void - HandleUpstreamResponse(SockAddr to, std::array buf, size_t len); + HandleUpstreamResponse(SockAddr to, std::vector buf); void HandleUpstreamFailure(const SockAddr& to, Message msg); diff --git a/llarp/dns/unbound_resolver.cpp b/llarp/dns/unbound_resolver.cpp index 6b02e8b32..e8192c990 100644 --- a/llarp/dns/unbound_resolver.cpp +++ b/llarp/dns/unbound_resolver.cpp @@ -77,10 +77,10 @@ namespace llarp::dns buf.cur = buf.base; hdr.Encode(&buf); - std::array buf_copy; + std::vector buf_copy(buf.sz); std::copy_n(buf.base, buf.sz, buf_copy.begin()); - this_ptr->replyFunc(lookup->source, std::move(buf_copy), buf.sz); + this_ptr->replyFunc(lookup->source, std::move(buf_copy)); ub_resolve_free(result); } diff --git a/llarp/dns/unbound_resolver.hpp b/llarp/dns/unbound_resolver.hpp index 1e7ffb235..24c7594e6 100644 --- a/llarp/dns/unbound_resolver.hpp +++ b/llarp/dns/unbound_resolver.hpp @@ -13,8 +13,7 @@ namespace llarp::dns { - using ReplyFunction = - std::function buf, size_t size)>; + using ReplyFunction = std::function buf)>; using FailFunction = std::function; class UnboundResolver : public std::enable_shared_from_this