Unbound callbacks also need arguments reversed

PR #1725 reversed argument orders but UnboundResolver was still using
(from,to) ordering in its callbacks, which leaked through to make a
wrong order in our reply function (which simply forwards arguments).

This fixes that bug by making UnboundResolver callback argument order
consistent (i.e. using to, from) with the PacketHandler argument order.
pull/1728/head
Jason Rhinelander 3 years ago
parent c0b8c87f81
commit 14c93e2b93

@ -58,7 +58,7 @@ namespace llarp::dns
return true;
auto failFunc = [self = weak_from_this()](
const SockAddr& from, const SockAddr& to, Message msg) {
const SockAddr& to, const SockAddr& from, Message msg) {
if (auto this_ptr = self.lock())
this_ptr->SendServerMessageBufferTo(to, from, msg.ToBuffer());
};

@ -58,7 +58,7 @@ namespace llarp::dns
{
Message& msg = lookup->msg;
msg.AddServFail();
this_ptr->failFunc(lookup->resolverAddr, lookup->askerAddr, msg);
this_ptr->failFunc(lookup->askerAddr, lookup->resolverAddr, msg);
ub_resolve_free(result);
return;
}
@ -73,7 +73,7 @@ namespace llarp::dns
buf.cur = buf.base;
hdr.Encode(&buf);
this_ptr->replyFunc(lookup->resolverAddr, lookup->askerAddr, std::move(pkt));
this_ptr->replyFunc(lookup->askerAddr, lookup->resolverAddr, std::move(pkt));
ub_resolve_free(result);
}
@ -145,7 +145,7 @@ namespace llarp::dns
if (not unboundContext)
{
msg.AddServFail();
failFunc(to, from, std::move(msg));
failFunc(from, to, std::move(msg));
return;
}
@ -163,7 +163,7 @@ namespace llarp::dns
if (err != 0)
{
msg.AddServFail();
failFunc(to, from, std::move(msg));
failFunc(from, to, std::move(msg));
return;
}
}

@ -18,9 +18,9 @@
namespace llarp::dns
{
using ReplyFunction =
std::function<void(const SockAddr& resolver, const SockAddr& source, OwnedBuffer buf)>;
std::function<void(const SockAddr& reply_to, const SockAddr& from_resolver, OwnedBuffer buf)>;
using FailFunction =
std::function<void(const SockAddr& resolver, const SockAddr& source, Message msg)>;
std::function<void(const SockAddr& reply_to, const SockAddr& from_resolver, Message msg)>;
class UnboundResolver : public std::enable_shared_from_this<UnboundResolver>
{

Loading…
Cancel
Save