mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
rewire up dns reconfiguration for macos
This commit is contained in:
parent
52c6cd497f
commit
13d1301e08
|
@ -400,9 +400,11 @@ namespace llarp::dns
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ResetInternalState() override
|
ResetInternalState(std::optional<std::vector<SockAddr>> replace_upstream) override
|
||||||
{
|
{
|
||||||
Down();
|
Down();
|
||||||
|
if (replace_upstream)
|
||||||
|
m_conf.m_upstreamDNS = *replace_upstream;
|
||||||
Up(m_conf);
|
Up(m_conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,9 +174,12 @@ namespace llarp::dns
|
||||||
virtual std::string_view
|
virtual std::string_view
|
||||||
ResolverName() const = 0;
|
ResolverName() const = 0;
|
||||||
|
|
||||||
/// reset state
|
/// reset state, replace upstream info with new info if desired
|
||||||
virtual void
|
virtual void
|
||||||
ResetInternalState(){};
|
ResetInternalState(std::optional<std::vector<SockAddr>> replace_upstream = std::nullopt)
|
||||||
|
{
|
||||||
|
(void)replace_upstream;
|
||||||
|
};
|
||||||
|
|
||||||
/// cancel all pending requests and ceace further operation
|
/// cancel all pending requests and ceace further operation
|
||||||
virtual void
|
virtual void
|
||||||
|
|
|
@ -24,9 +24,6 @@ namespace llarp
|
||||||
return "snode";
|
return "snode";
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ResetInternalState() override{};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CancelPendingQueries() override{};
|
CancelPendingQueries() override{};
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace llarp
|
||||||
: m_Reply{std::move(reply)}, m_OurIP{std::move(our_ip)}, m_Config{std::move(conf)}
|
: m_Reply{std::move(reply)}, m_OurIP{std::move(our_ip)}, m_Config{std::move(conf)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~DnsInterceptor() override = default;
|
~DnsInterceptor() override = default;
|
||||||
|
|
||||||
void
|
void
|
||||||
SendTo(const SockAddr& to, const SockAddr& from, OwnedBuffer buf) const override
|
SendTo(const SockAddr& to, const SockAddr& from, OwnedBuffer buf) const override
|
||||||
|
@ -91,14 +91,16 @@ namespace llarp
|
||||||
bool
|
bool
|
||||||
WouldLoop(const SockAddr& to, const SockAddr& from) const override
|
WouldLoop(const SockAddr& to, const SockAddr& from) const override
|
||||||
{
|
{
|
||||||
if constexpr (platform::is_apple) {
|
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
|
// DNS on Apple is a bit weird because in order for the NetworkExtension itself to send
|
||||||
// upstream DNS won't be set in our resolvers, which is why the vanilla WouldLoop won't work
|
// data through the tunnel we have to proxy DNS requests through Apple APIs (and so our
|
||||||
// for us). However when active the mac also only queries the main tunnel IP for DNS, so we
|
// actual upstream DNS won't be set in our resolvers, which is why the vanilla WouldLoop
|
||||||
// consider anything else to be upstream-bound DNS to let it through the tunnel.
|
// won't work for us). However when active the mac also only queries the main tunnel IP
|
||||||
return to.getIP() != m_OurIP;
|
// 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)
|
else if (auto maybe_addr = m_Config.m_QueryBind)
|
||||||
{
|
{
|
||||||
const auto& addr = *maybe_addr;
|
const auto& addr = *maybe_addr;
|
||||||
|
@ -261,7 +263,14 @@ namespace llarp
|
||||||
std::vector<SockAddr>
|
std::vector<SockAddr>
|
||||||
TunEndpoint::ReconfigureDNS(std::vector<SockAddr> servers)
|
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;
|
return servers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
namespace llarp::net
|
namespace llarp::net
|
||||||
{
|
{
|
||||||
|
|
||||||
class Platform_Impl : public Platform
|
class Platform_Impl : public Platform
|
||||||
{
|
{
|
||||||
template <typename Visit_t>
|
template <typename Visit_t>
|
||||||
|
|
Loading…
Reference in a new issue