std::vector instead of std::array

pull/1307/head
Thomas Winget 4 years ago
parent b875d40491
commit 8f0330c9f2

@ -106,12 +106,11 @@ namespace llarp
} }
}; };
auto replyFunc = [self = weak_from_this()]( auto replyFunc = [self = weak_from_this()](SockAddr to, std::vector<byte_t> buf) {
SockAddr to, std::array<byte_t, 1500> buf, size_t len) {
auto this_ptr = self.lock(); auto this_ptr = self.lock();
if (this_ptr) 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 void
Proxy::HandleUpstreamResponse(SockAddr to, std::array<byte_t, 1500> buf, size_t len) Proxy::HandleUpstreamResponse(SockAddr to, std::vector<byte_t> buf)
{ {
auto self = shared_from_this(); 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); llarp_buffer_t buf(buffer);
buf.sz = len;
self->SendServerMessageBufferTo(to, buf); self->SendServerMessageBufferTo(to, buf);
}); });
} }

@ -72,7 +72,7 @@ namespace llarp
SendServerMessageTo(const SockAddr& to, Message msg); SendServerMessageTo(const SockAddr& to, Message msg);
void void
HandleUpstreamResponse(SockAddr to, std::array<byte_t, 1500> buf, size_t len); HandleUpstreamResponse(SockAddr to, std::vector<byte_t> buf);
void void
HandleUpstreamFailure(const SockAddr& to, Message msg); HandleUpstreamFailure(const SockAddr& to, Message msg);

@ -77,10 +77,10 @@ namespace llarp::dns
buf.cur = buf.base; buf.cur = buf.base;
hdr.Encode(&buf); hdr.Encode(&buf);
std::array<byte_t, 1500> buf_copy; std::vector<byte_t> buf_copy(buf.sz);
std::copy_n(buf.base, buf.sz, buf_copy.begin()); 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); ub_resolve_free(result);
} }

@ -13,8 +13,7 @@
namespace llarp::dns namespace llarp::dns
{ {
using ReplyFunction = using ReplyFunction = std::function<void(SockAddr source, std::vector<byte_t> buf)>;
std::function<void(SockAddr source, std::array<byte_t, 1500> buf, size_t size)>;
using FailFunction = std::function<void(SockAddr source, Message msg)>; using FailFunction = std::function<void(SockAddr source, Message msg)>;
class UnboundResolver : public std::enable_shared_from_this<UnboundResolver> class UnboundResolver : public std::enable_shared_from_this<UnboundResolver>

Loading…
Cancel
Save