mirror of https://github.com/oxen-io/lokinet
Reapply "fix dns on android" + fix argument order
The reason the dns fix on android didn't work is that the DnsInterceptor had a reversed to/from argument order for its `SendServerMessageBufferTo` overload, and so android/mac needed the to/from to be reversed so that the second reverse cancelled out the first one. Upon review, the DnsInterceptor order (to, from) is more intuitive than the base order (from, to), so this reapplies the dns fix and swaps everything *except* DnsInterceptor to match the (to, from) argument order.
This commit is contained in:
parent
a70035b7ec
commit
3ce329d2bf
|
@ -60,7 +60,7 @@ namespace llarp::dns
|
|||
auto failFunc = [self = weak_from_this()](
|
||||
const SockAddr& from, const SockAddr& to, Message msg) {
|
||||
if (auto this_ptr = self.lock())
|
||||
this_ptr->SendServerMessageBufferTo(from, to, msg.ToBuffer());
|
||||
this_ptr->SendServerMessageBufferTo(to, from, msg.ToBuffer());
|
||||
};
|
||||
|
||||
auto replyFunc = [self = weak_from_this()](auto&&... args) {
|
||||
|
@ -95,7 +95,8 @@ namespace llarp::dns
|
|||
}
|
||||
|
||||
void
|
||||
Proxy::SendServerMessageBufferTo(const SockAddr&, const SockAddr& to, llarp_buffer_t buf)
|
||||
Proxy::SendServerMessageBufferTo(
|
||||
const SockAddr& to, [[maybe_unused]] const SockAddr& from, llarp_buffer_t buf)
|
||||
{
|
||||
if (!m_Server->send(to, buf))
|
||||
llarp::LogError("dns reply failed");
|
||||
|
@ -157,7 +158,7 @@ namespace llarp::dns
|
|||
// yea it is, let's turn off DoH because god is dead.
|
||||
msg.AddNXReply();
|
||||
// press F to pay respects
|
||||
SendServerMessageBufferTo(resolver, from, msg.ToBuffer());
|
||||
SendServerMessageBufferTo(from, resolver, msg.ToBuffer());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +166,7 @@ namespace llarp::dns
|
|||
if (m_QueryHandler && m_QueryHandler->ShouldHookDNSMessage(msg))
|
||||
{
|
||||
auto reply = [self = shared_from_this(), to = from, resolver](dns::Message msg) {
|
||||
self->SendServerMessageBufferTo(resolver, to, msg.ToBuffer());
|
||||
self->SendServerMessageBufferTo(to, resolver, msg.ToBuffer());
|
||||
};
|
||||
if (!m_QueryHandler->HandleHookedDNSMessage(std::move(msg), reply))
|
||||
{
|
||||
|
@ -177,7 +178,7 @@ namespace llarp::dns
|
|||
// no upstream resolvers
|
||||
// let's serv fail it
|
||||
msg.AddServFail();
|
||||
SendServerMessageBufferTo(resolver, from, msg.ToBuffer());
|
||||
SendServerMessageBufferTo(from, resolver, msg.ToBuffer());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace llarp
|
|||
|
||||
protected:
|
||||
virtual void
|
||||
SendServerMessageBufferTo(const SockAddr& from, const SockAddr& to, llarp_buffer_t buf) = 0;
|
||||
SendServerMessageBufferTo(const SockAddr& to, const SockAddr& from, llarp_buffer_t buf) = 0;
|
||||
|
||||
private:
|
||||
void
|
||||
|
@ -84,7 +84,7 @@ namespace llarp
|
|||
protected:
|
||||
void
|
||||
SendServerMessageBufferTo(
|
||||
const SockAddr& from, const SockAddr& to, llarp_buffer_t buf) override;
|
||||
const SockAddr& to, const SockAddr& from, llarp_buffer_t buf) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<UDPHandle> m_Server;
|
||||
|
|
|
@ -87,8 +87,8 @@ namespace llarp
|
|||
|
||||
OwnedBuffer buf{pkt.sz - (8 + ip_header_size)};
|
||||
std::copy_n(ptr + 8, buf.sz, buf.buf.get());
|
||||
if (m_Resolver->ShouldHandlePacket(laddr, raddr, buf))
|
||||
m_Resolver->HandlePacket(laddr, raddr, buf);
|
||||
if (m_Resolver->ShouldHandlePacket(raddr, laddr, buf))
|
||||
m_Resolver->HandlePacket(raddr, laddr, buf);
|
||||
else
|
||||
HandleGotUserPacket(std::move(pkt));
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue