From baddad95645cc1f72faf1eaab5f368656346921a Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 22 Jun 2022 12:14:33 -0400 Subject: [PATCH] remove compat wrapper --- jni/lokinet_daemon.cpp | 5 +- llarp/CMakeLists.txt | 4 +- llarp/dns/multi_platform.cpp | 30 ++++ llarp/dns/multi_platform.hpp | 22 +++ llarp/dns/nm_platform.cpp | 24 +++ llarp/dns/nm_platform.hpp | 24 +++ llarp/dns/null_platform.hpp | 14 ++ llarp/dns/{resolver.hpp => platform.hpp} | 33 +--- llarp/dns/resolver.cpp | 220 ----------------------- llarp/dns/sd_platform.cpp | 134 ++++++++++++++ llarp/dns/sd_platform.hpp | 24 +++ llarp/dns/server.cpp | 30 +++- llarp/dns/server.hpp | 14 +- llarp/handlers/exit.cpp | 5 +- llarp/handlers/tun.cpp | 6 +- llarp/router/abstractrouter.hpp | 10 +- llarp/router/route_poker.cpp | 20 +-- llarp/router/router.hpp | 6 + 18 files changed, 342 insertions(+), 283 deletions(-) create mode 100644 llarp/dns/multi_platform.cpp create mode 100644 llarp/dns/multi_platform.hpp create mode 100644 llarp/dns/nm_platform.cpp create mode 100644 llarp/dns/nm_platform.hpp create mode 100644 llarp/dns/null_platform.hpp rename llarp/dns/{resolver.hpp => platform.hpp} (55%) delete mode 100644 llarp/dns/resolver.cpp create mode 100644 llarp/dns/sd_platform.cpp create mode 100644 llarp/dns/sd_platform.hpp diff --git a/jni/lokinet_daemon.cpp b/jni/lokinet_daemon.cpp index 4d4fa1638..8bd90f510 100644 --- a/jni/lokinet_daemon.cpp +++ b/jni/lokinet_daemon.cpp @@ -84,9 +84,8 @@ extern "C" JNIEXPORT jint JNICALL Java_network_loki_lokinet_LokinetDaemon_GetUDPSocket(JNIEnv* env, jobject self) { - auto ptr = GetImpl(env, self); - if (const auto& router = ptr->router; ptr and ptr->router) - return router->OutboundUDPSocket(); + if (auto ptr = GetImpl(env, self); ptr and ptr->router) + return ptr->router->OutboundUDPSocket(); return -1; } diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index b98cd4c1f..f80bdb77c 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -77,12 +77,14 @@ add_library(liblokinet dns/message.cpp dns/name.cpp + dns/multi_platform.cpp + dns/nm_platform.cpp + dns/sd_platform.cpp dns/question.cpp dns/rr.cpp dns/serialize.cpp dns/server.cpp dns/srv_data.cpp - dns/resolver.cpp consensus/table.cpp consensus/reachability_testing.cpp diff --git a/llarp/dns/multi_platform.cpp b/llarp/dns/multi_platform.cpp new file mode 100644 index 000000000..bf4b0f887 --- /dev/null +++ b/llarp/dns/multi_platform.cpp @@ -0,0 +1,30 @@ +#include "multi_platform.hpp" + +namespace llarp::dns +{ + void + Multi_Platform::add_impl(std::unique_ptr impl) + { + m_Impls.emplace_back(std::move(impl)); + } + + void + Multi_Platform::set_resolver(std::string ifname, llarp::SockAddr dns, bool global) + { + size_t fails{0}; + for (const auto& ptr : m_Impls) + { + try + { + ptr->set_resolver(ifname, dns, global); + } + catch (std::exception& ex) + { + LogWarn(ex.what()); + fails++; + } + } + if (fails == m_Impls.size()) + throw std::runtime_error{"tried all ways to set resolver and failed"}; + } +} // namespace llarp::dns diff --git a/llarp/dns/multi_platform.hpp b/llarp/dns/multi_platform.hpp new file mode 100644 index 000000000..8f05d7ed7 --- /dev/null +++ b/llarp/dns/multi_platform.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "platform.hpp" +#include + +namespace llarp::dns +{ + /// a collection of dns platforms that are tried in order when setting dns + class Multi_Platform : public I_Platform + { + std::vector> m_Impls; + + public: + /// add a platform to be owned + void + add_impl(std::unique_ptr impl); + + /// try all owned platforms to set the resolver, throws if none of them work + void + set_resolver(std::string ifname, llarp::SockAddr dns, bool global) override; + }; +} // namespace llarp::dns diff --git a/llarp/dns/nm_platform.cpp b/llarp/dns/nm_platform.cpp new file mode 100644 index 000000000..d4315a049 --- /dev/null +++ b/llarp/dns/nm_platform.cpp @@ -0,0 +1,24 @@ +#include "nm_platform.hpp" +#ifdef WITH_SYSTEMD + +extern "C" +{ +#include +} + +#include + +using namespace std::literals; + +namespace llarp::dns::nm +{ + Platform::Platform() + {} + + void + Platform::set_resolver(std::string, llarp::SockAddr, bool) + { + // todo: implement me eventually + } +} // namespace llarp::dns::nm +#endif diff --git a/llarp/dns/nm_platform.hpp b/llarp/dns/nm_platform.hpp new file mode 100644 index 000000000..e41e858cb --- /dev/null +++ b/llarp/dns/nm_platform.hpp @@ -0,0 +1,24 @@ +#pragma once +#include "platform.hpp" +#include "null_platform.hpp" + +#include +#include +#include + +namespace llarp::dns +{ + namespace nm + { + // a dns platform that sets dns via network manager + class Platform : public I_Platform + { + public: + virtual ~Platform() = default; + + void + set_resolver(std::string ifname, llarp::SockAddr dns, bool global) override; + }; + }; // namespace nm + using NM_Platform_t = std::conditional_t; +} // namespace llarp::dns diff --git a/llarp/dns/null_platform.hpp b/llarp/dns/null_platform.hpp new file mode 100644 index 000000000..2b31ee8a2 --- /dev/null +++ b/llarp/dns/null_platform.hpp @@ -0,0 +1,14 @@ +#pragma once +#include "platform.hpp" + +namespace llarp::dns +{ + /// a dns platform does silently does nothing, successfully + class Null_Platform : public I_Platform + { + public: + void + set_resolver(std::string, llarp::SockAddr, bool) override + {} + }; +} // namespace llarp::dns diff --git a/llarp/dns/resolver.hpp b/llarp/dns/platform.hpp similarity index 55% rename from llarp/dns/resolver.hpp rename to llarp/dns/platform.hpp index 7f71ef66c..25402db26 100644 --- a/llarp/dns/resolver.hpp +++ b/llarp/dns/platform.hpp @@ -6,18 +6,13 @@ #include -namespace llarp -{ - struct AbstractRouter; -} - namespace llarp::dns { /// sets dns settings in a platform dependant way - class I_SystemSettings + class I_Platform { public: - virtual ~I_SystemSettings() = default; + virtual ~I_Platform() = default; /// Attempts to set lokinet as the DNS server. /// throws if unsupported or fails. @@ -32,28 +27,4 @@ namespace llarp::dns set_resolver(std::string if_name, llarp::SockAddr dns, bool global) = 0; }; - /// creates for the current platform - std::shared_ptr - MakeSystemSettings(); - - /// compat wrapper - inline bool - set_resolver(std::string if_name, llarp::SockAddr dns, bool global) - { - try - { - if (auto settings = MakeSystemSettings()) - { - settings->set_resolver(std::move(if_name), std::move(dns), global); - return true; - } - } - catch (std::exception& ex) - { - LogError("failed to set DNS: ", ex.what()); - } - LogWarn("did not set dns"); - return false; - } - } // namespace llarp::dns diff --git a/llarp/dns/resolver.cpp b/llarp/dns/resolver.cpp deleted file mode 100644 index f3e2f22a2..000000000 --- a/llarp/dns/resolver.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#include "resolver.hpp" -#include -#include - -namespace llarp::dns -{ - class Null_SystemSettings : public I_SystemSettings - { - void - set_resolver(std::string, llarp::SockAddr, bool) override - { - LogDebug("lokinet is not built with systemd support, cannot set systemd resolved DNS"); - } - }; -} // namespace llarp::dns - -#ifdef WITH_SYSTEMD -extern "C" -{ -#include -} - -#include - -using namespace std::literals; - -namespace llarp::dns -{ - class SD_SystemSettings : public I_SystemSettings - { - public: - void - set_resolver(std::string ifname, llarp::SockAddr dns, bool global) override - { - unsigned int if_ndx = if_nametoindex(ifname.c_str()); - if (if_ndx == 0) - { - throw std::runtime_error{"No such interface '" + ifname + "'"}; - } - - linux::DBUS _dbus{ - "org.freedesktop.resolve1", - "/org/freedesktop/resolve1", - "org.freedesktop.resolve1.Manager"}; - // This passing address by bytes and using two separate calls for ipv4/ipv6 is gross, but - // the alternative is to build up a bunch of crap with va_args, which is slightly more - // gross. - const bool isStandardDNSPort = dns.getPort() == 53; - if (dns.isIPv6()) - { - auto ipv6 = dns.getIPv6(); - static_assert(sizeof(ipv6) == 16); - auto* a = reinterpret_cast(&ipv6); - if (isStandardDNSPort) - { - _dbus( - "SetLinkDNS", - "ia(iay)", - (int32_t)if_ndx, - (int)1, // number of "iayqs"s we are passing - (int32_t)AF_INET6, // network address type - (int)16, // network addr byte size - // clang-format off - a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], - a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15] // yuck - // clang-format on - ); - } - else - { - _dbus( - "SetLinkDNSEx", - "ia(iayqs)", - (int32_t)if_ndx, - (int)1, // number of "iayqs"s we are passing - (int32_t)AF_INET6, // network address type - (int)16, // network addr byte size - // clang-format off - a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], - a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], // yuck - // clang-format on - (uint16_t)dns.getPort(), - nullptr // dns server name (for TLS SNI which we don't care about) - ); - } - } - else - { - auto ipv4 = dns.getIPv4(); - static_assert(sizeof(ipv4) == 4); - auto* a = reinterpret_cast(&ipv4); - if (isStandardDNSPort) - { - _dbus( - "SetLinkDNS", - "ia(iay)", - (int32_t)if_ndx, - (int)1, // number of "iayqs"s we are passing - (int32_t)AF_INET, // network address type - (int)4, // network addr byte size - // clang-format off - a[0], a[1], a[2], a[3] // yuck - // clang-format on - ); - } - else - { - _dbus( - "SetLinkDNSEx", - "ia(iayqs)", - (int32_t)if_ndx, - (int)1, // number of "iayqs"s we are passing - (int32_t)AF_INET, // network address type - (int)4, // network addr byte size - // clang-format off - a[0], a[1], a[2], a[3], // yuck - // clang-format on - (uint16_t)dns.getPort(), - nullptr // dns server name (for TLS SNI which we don't care about) - ); - } - } - - if (global) - // Setting "." as a routing domain gives this DNS server higher priority in resolution - // compared to dns servers that are set without a domain (e.g. the default for a - // DHCP-configured DNS server) - _dbus( - "SetLinkDomains", - "ia(sb)", - (int32_t)if_ndx, - (int)1, // array size - "." // global DNS root - ); - else - // Only resolve .loki and .snode through lokinet (so you keep using your local DNS - // server for everything else, which is nicer than forcing everything though lokinet's - // upstream DNS). - _dbus( - "SetLinkDomains", - "ia(sb)", - (int32_t)if_ndx, - (int)2, // array size - "loki", // domain - (int)1, // routing domain = true - "snode", // domain - (int)1 // routing domain = true - ); - } - }; - - /// network manager dns setter - class NM_SystemSettings : public I_SystemSettings - { - public: - void - set_resolver(std::string ifname, llarp::SockAddr dns, bool global) override - { - unsigned int if_ndx = if_nametoindex(ifname.c_str()); - if (if_ndx == 0) - { - throw std::runtime_error{"No such interface '" + ifname + "'"}; - } - (void)dns; - (void)global; - // TODO: implement network manager shit - } - }; - -} // namespace llarp::dns - -#endif // WITH_SYSTEMD - -namespace llarp::dns -{ - class MultiSettings : public I_SystemSettings - { - std::vector> m_Impls; - - public: - void - add_impl(std::unique_ptr impl) - { - m_Impls.emplace_back(std::move(impl)); - } - - void - set_resolver(std::string ifname, llarp::SockAddr dns, bool global) override - { - size_t fails{0}; - for (const auto& ptr : m_Impls) - { - try - { - ptr->set_resolver(ifname, dns, global); - } - catch (std::exception& ex) - { - LogWarn(ex.what()); - fails++; - } - } - if (fails == m_Impls.size()) - throw std::runtime_error{"tried all ways to set resolver and failed"}; - } - }; - - std::shared_ptr - MakeSystemSettings() - { - auto settings = std::make_shared(); - settings->add_impl(std::make_unique()); - if constexpr (llarp::platform::has_systemd) - { - settings->add_impl(std::make_unique()); - settings->add_impl(std::make_unique()); - } - return settings; - } -} // namespace llarp::dns diff --git a/llarp/dns/sd_platform.cpp b/llarp/dns/sd_platform.cpp new file mode 100644 index 000000000..f867441f1 --- /dev/null +++ b/llarp/dns/sd_platform.cpp @@ -0,0 +1,134 @@ +#ifdef WITH_SYSTEMD +#include "sd_platform.hpp" + +extern "C" +{ +#include +} + +#include + +using namespace std::literals; + +namespace llarp::dns::sd +{ + void + Platform::set_resolver(std::string ifname, llarp::SockAddr dns, bool global) + { + unsigned int if_ndx = if_nametoindex(ifname.c_str()); + if (if_ndx == 0) + { + throw std::runtime_error{"No such interface '" + ifname + "'"}; + } + + linux::DBUS _dbus{ + "org.freedesktop.resolve1", + "/org/freedesktop/resolve1", + "org.freedesktop.resolve1.Manager"}; + // This passing address by bytes and using two separate calls for ipv4/ipv6 is gross, but + // the alternative is to build up a bunch of crap with va_args, which is slightly more + // gross. + const bool isStandardDNSPort = dns.getPort() == 53; + if (dns.isIPv6()) + { + auto ipv6 = dns.getIPv6(); + static_assert(sizeof(ipv6) == 16); + auto* a = reinterpret_cast(&ipv6); + if (isStandardDNSPort) + { + _dbus( + "SetLinkDNS", + "ia(iay)", + (int32_t)if_ndx, + (int)1, // number of "iayqs"s we are passing + (int32_t)AF_INET6, // network address type + (int)16, // network addr byte size + // clang-format off + a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], + a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15] // yuck + // clang-format on + ); + } + else + { + _dbus( + "SetLinkDNSEx", + "ia(iayqs)", + (int32_t)if_ndx, + (int)1, // number of "iayqs"s we are passing + (int32_t)AF_INET6, // network address type + (int)16, // network addr byte size + // clang-format off + a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], + a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], // yuck + // clang-format on + (uint16_t)dns.getPort(), + nullptr // dns server name (for TLS SNI which we don't care about) + ); + } + } + else + { + auto ipv4 = dns.getIPv4(); + static_assert(sizeof(ipv4) == 4); + auto* a = reinterpret_cast(&ipv4); + if (isStandardDNSPort) + { + _dbus( + "SetLinkDNS", + "ia(iay)", + (int32_t)if_ndx, + (int)1, // number of "iayqs"s we are passing + (int32_t)AF_INET, // network address type + (int)4, // network addr byte size + // clang-format off + a[0], a[1], a[2], a[3] // yuck + // clang-format on + ); + } + else + { + _dbus( + "SetLinkDNSEx", + "ia(iayqs)", + (int32_t)if_ndx, + (int)1, // number of "iayqs"s we are passing + (int32_t)AF_INET, // network address type + (int)4, // network addr byte size + // clang-format off + a[0], a[1], a[2], a[3], // yuck + // clang-format on + (uint16_t)dns.getPort(), + nullptr // dns server name (for TLS SNI which we don't care about) + ); + } + } + + if (global) + // Setting "." as a routing domain gives this DNS server higher priority in resolution + // compared to dns servers that are set without a domain (e.g. the default for a + // DHCP-configured DNS server) + _dbus( + "SetLinkDomains", + "ia(sb)", + (int32_t)if_ndx, + (int)1, // array size + "." // global DNS root + ); + else + // Only resolve .loki and .snode through lokinet (so you keep using your local DNS + // server for everything else, which is nicer than forcing everything though lokinet's + // upstream DNS). + _dbus( + "SetLinkDomains", + "ia(sb)", + (int32_t)if_ndx, + (int)2, // array size + "loki", // domain + (int)1, // routing domain = true + "snode", // domain + (int)1 // routing domain = true + ); + } +} // namespace llarp::dns::sd +#endif diff --git a/llarp/dns/sd_platform.hpp b/llarp/dns/sd_platform.hpp new file mode 100644 index 000000000..0c83c2557 --- /dev/null +++ b/llarp/dns/sd_platform.hpp @@ -0,0 +1,24 @@ +#pragma once +#include "platform.hpp" +#include "null_platform.hpp" + +#include +#include + +namespace llarp::dns +{ + namespace sd + { + /// a dns platform that sets dns via systemd resolved + class Platform : public I_Platform + { + public: + virtual ~Platform() = default; + + void + set_resolver(std::string ifname, llarp::SockAddr dns, bool global) override; + }; + } // namespace sd + using SD_Platform_t = + std::conditional_t; +} // namespace llarp::dns diff --git a/llarp/dns/server.cpp b/llarp/dns/server.cpp index 3d91eab3d..0d652074f 100644 --- a/llarp/dns/server.cpp +++ b/llarp/dns/server.cpp @@ -9,6 +9,10 @@ #include #include +#include "multi_platform.hpp" +#include "sd_platform.hpp" +#include "nm_platform.hpp" + namespace llarp::dns { void @@ -398,8 +402,11 @@ namespace llarp::dns } } // namespace libunbound - Server::Server(EventLoop_ptr loop, llarp::DnsConfig conf) - : m_Loop{std::move(loop)}, m_Config{std::move(conf)} + Server::Server(EventLoop_ptr loop, llarp::DnsConfig conf, std::string netif) + : m_Loop{std::move(loop)} + , m_Config{std::move(conf)} + , m_Platform{CreatePlatform()} + , m_NetifName{std::move(netif)} {} void @@ -417,6 +424,18 @@ namespace llarp::dns AddResolver(ptr); } + std::shared_ptr + Server::CreatePlatform() const + { + auto plat = std::make_shared(); + if constexpr (llarp::platform::has_systemd) + { + plat->add_impl(std::make_unique()); + plat->add_impl(std::make_unique()); + } + return plat; + } + std::shared_ptr Server::MakePacketSourceOn(const llarp::SockAddr& addr, const llarp::DnsConfig&) { @@ -508,6 +527,13 @@ namespace llarp::dns } } + void + Server::SetDNSMode(bool all_queries) + { + if (auto maybe_addr = FirstBoundPacketSourceAddr()) + m_Platform->set_resolver(m_NetifName, *maybe_addr, all_queries); + } + bool Server::MaybeHandlePacket( std::weak_ptr src, diff --git a/llarp/dns/server.hpp b/llarp/dns/server.hpp index c101581af..88ca86385 100644 --- a/llarp/dns/server.hpp +++ b/llarp/dns/server.hpp @@ -1,6 +1,7 @@ #pragma once #include "message.hpp" +#include "platform.hpp" #include #include #include @@ -160,9 +161,13 @@ namespace llarp::dns void AddResolver(std::shared_ptr resolver); + /// create the platform dependant dns stuff + virtual std::shared_ptr + CreatePlatform() const; + public: virtual ~Server() = default; - explicit Server(EventLoop_ptr loop, llarp::DnsConfig conf); + explicit Server(EventLoop_ptr loop, llarp::DnsConfig conf, std::string netif_name); /// returns all sockaddr we have from all of our PacketSources std::vector @@ -210,11 +215,18 @@ namespace llarp::dns const SockAddr& from, llarp::OwnedBuffer buf); + /// set which dns mode we are in. + /// true for intercepting all queries. false for just .loki and .snode + void + SetDNSMode(bool all_queries); + protected: EventLoop_ptr m_Loop; llarp::DnsConfig m_Config; + std::shared_ptr m_Platform; private: + const std::string m_NetifName; std::set, ComparePtr>> m_OwnedResolvers; std::set, CompareWeakPtr> m_Resolvers; diff --git a/llarp/handlers/exit.cpp b/llarp/handlers/exit.cpp index 972dfeecc..c14245bbc 100644 --- a/llarp/handlers/exit.cpp +++ b/llarp/handlers/exit.cpp @@ -713,8 +713,6 @@ namespace llarp m_ShouldInitTun = false; } - m_Resolver = std::make_shared(m_Router->loop(), dnsConfig); - m_OurRange = networkConfig.m_ifaddr; if (!m_OurRange.addr.h) { @@ -745,8 +743,7 @@ namespace llarp return llarp::SockAddr{ifaddr, huint16_t{port}}; }); } - // TODO: "exit-whitelist" and "exit-blacklist" - // (which weren't originally implemented) + m_Resolver = std::make_shared(m_Router->loop(), dnsConfig, m_ifname); } huint128_t diff --git a/llarp/handlers/tun.cpp b/llarp/handlers/tun.cpp index d25c8d361..2d1ab4b8f 100644 --- a/llarp/handlers/tun.cpp +++ b/llarp/handlers/tun.cpp @@ -123,7 +123,7 @@ namespace llarp virtual ~TunDNS() = default; explicit TunDNS(TunEndpoint* ep, const llarp::DnsConfig& conf) - : dns::Server{ep->Router()->loop(), conf}, m_Endpoint{ep} + : dns::Server{ep->Router()->loop(), conf, ep->GetIfName()}, m_Endpoint{ep} {} std::shared_ptr @@ -144,7 +144,7 @@ namespace llarp #endif TunEndpoint::TunEndpoint(AbstractRouter* r, service::Context* parent) - : service::Endpoint(r, parent) + : service::Endpoint{r, parent} { m_PacketRouter = std::make_unique( [this](net::IPPacket pkt) { HandleGotUserPacket(std::move(pkt)); }); @@ -174,7 +174,7 @@ namespace llarp HandleGotUserPacket(std::move(pkt)); }); #else - m_DNS = std::make_shared(Loop(), m_DnsConfig); + m_DNS = std::make_shared(Loop(), m_DnsConfig, GetIfName()); #endif m_DNS->AddResolver(weak_from_this()); m_DNS->Start(); diff --git a/llarp/router/abstractrouter.hpp b/llarp/router/abstractrouter.hpp index 243f0a47b..69b4ccf4a 100644 --- a/llarp/router/abstractrouter.hpp +++ b/llarp/router/abstractrouter.hpp @@ -45,6 +45,11 @@ namespace llarp struct I_RCLookupHandler; struct RoutePoker; + namespace dns + { + class I_SystemSettings; + } + namespace net { class Platform; @@ -355,7 +360,10 @@ namespace llarp } virtual int - OutboundUDPSocket() const = 0; + OutboundUDPSocket() const + { + return -1; + } protected: /// Virtual function to handle RouterEvent. HiveRouter overrides this in diff --git a/llarp/router/route_poker.cpp b/llarp/router/route_poker.cpp index c92aa741f..352ac1625 100644 --- a/llarp/router/route_poker.cpp +++ b/llarp/router/route_poker.cpp @@ -2,7 +2,7 @@ #include "abstractrouter.hpp" #include "net/sock_addr.hpp" #include -#include +#include #include namespace llarp @@ -163,22 +163,8 @@ namespace llarp void RoutePoker::SetDNSMode(bool exit_mode_on) const { - if (auto dns = m_Router->hiddenServiceContext().GetDefault()->DNS()) - { - if (auto maybe_addr = dns->FirstBoundPacketSourceAddr()) - { - if (dns::set_resolver( - m_Router->hiddenServiceContext().GetDefault()->GetIfName(), - *maybe_addr, - exit_mode_on)) - { - LogInfo( - "DNS set to ", - *maybe_addr, - exit_mode_on ? " for all traffic" : " for just lokinet traffic"); - } - } - } + if (auto dns_server = m_Router->hiddenServiceContext().GetDefault()->DNS()) + dns_server->SetDNSMode(exit_mode_on); } void diff --git a/llarp/router/router.hpp b/llarp/router/router.hpp index dc4b901a1..2b280a4c2 100644 --- a/llarp/router/router.hpp +++ b/llarp/router/router.hpp @@ -355,6 +355,12 @@ namespace llarp return m_peerDb; } + inline int + OutboundUDPSocket() const override + { + return m_OutboundUDPSocket; + } + void GossipRCIfNeeded(const RouterContact rc) override;