rewire up dns reconfiguration for macos

pull/1969/head
Jeff Becker 2 years ago committed by Jason Rhinelander
parent 52c6cd497f
commit 13d1301e08
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262

@ -400,9 +400,11 @@ namespace llarp::dns
}
void
ResetInternalState() override
ResetInternalState(std::optional<std::vector<SockAddr>> replace_upstream) override
{
Down();
if (replace_upstream)
m_conf.m_upstreamDNS = *replace_upstream;
Up(m_conf);
}

@ -174,9 +174,12 @@ namespace llarp::dns
virtual std::string_view
ResolverName() const = 0;
/// reset state
/// reset state, replace upstream info with new info if desired
virtual void
ResetInternalState(){};
ResetInternalState(std::optional<std::vector<SockAddr>> replace_upstream = std::nullopt)
{
(void)replace_upstream;
};
/// cancel all pending requests and ceace further operation
virtual void

@ -24,9 +24,6 @@ namespace llarp
return "snode";
}
void
ResetInternalState() override{};
void
CancelPendingQueries() override{};

@ -67,7 +67,7 @@ namespace llarp
: m_Reply{std::move(reply)}, m_OurIP{std::move(our_ip)}, m_Config{std::move(conf)}
{}
~DnsInterceptor() override = default;
~DnsInterceptor() override = default;
void
SendTo(const SockAddr& to, const SockAddr& from, OwnedBuffer buf) const override
@ -91,14 +91,16 @@ namespace llarp
bool
WouldLoop(const SockAddr& to, const SockAddr& from) const override
{
if constexpr (platform::is_apple) {
// DNS on Apple is a bit weird because in order for the NetworkExtension itself to send data
// through the tunnel we have to proxy DNS requests through Apple APIs (and so our actual
// upstream DNS won't be set in our resolvers, which is why the vanilla WouldLoop won't work
// for us). However when active the mac also only queries the main tunnel IP for DNS, so we
// consider anything else to be upstream-bound DNS to let it through the tunnel.
return to.getIP() != m_OurIP;
}
if constexpr (platform::is_apple)
{
// DNS on Apple is a bit weird because in order for the NetworkExtension itself to send
// data through the tunnel we have to proxy DNS requests through Apple APIs (and so our
// actual upstream DNS won't be set in our resolvers, which is why the vanilla WouldLoop
// won't work for us). However when active the mac also only queries the main tunnel IP
// for DNS, so we consider anything else to be upstream-bound DNS to let it through the
// tunnel.
return to.getIP() != m_OurIP;
}
else if (auto maybe_addr = m_Config.m_QueryBind)
{
const auto& addr = *maybe_addr;
@ -261,7 +263,14 @@ namespace llarp
std::vector<SockAddr>
TunEndpoint::ReconfigureDNS(std::vector<SockAddr> servers)
{
// TODO: implement me
if (m_DNS)
{
for (auto weak : m_DNS->GetAllResolvers())
{
if (auto ptr = weak.lock())
ptr->ResetInternalState(servers);
}
}
return servers;
}

@ -22,7 +22,6 @@
namespace llarp::net
{
class Platform_Impl : public Platform
{
template <typename Visit_t>

Loading…
Cancel
Save