From: Remi Gacogne Date: Tue, 26 Mar 2019 10:22:03 +0000 (+0100) Subject: dnsdist: Display (and export via API) the frontend type (DoT, ..) X-Git-Tag: dnsdist-1.4.0-alpha1~25^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba7ec3409c4b5d5a2f1f900452287d80fc82693c;p=thirdparty%2Fpdns.git dnsdist: Display (and export via API) the frontend type (DoT, ..) --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index c7e03da7b3..dea393d3b3 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1268,13 +1268,13 @@ void setupLuaConfig(bool client) setLuaNoSideEffect(); try { ostringstream ret; - boost::format fmt("%1$-3d %2$-20.20s %|25t|%3$-8.8s %|35t|%4%" ); + boost::format fmt("%1$-3d %2$-20.20s %|35t|%3$-20.20s %|57t|%4%" ); // 1 2 3 4 ret << (fmt % "#" % "Address" % "Protocol" % "Queries" ) << endl; size_t counter = 0; for (const auto& front : g_frontends) { - ret << (fmt % counter % front->local.toStringWithPort() % (front->udpFD != -1 ? "UDP" : "TCP") % front->queries) << endl; + ret << (fmt % counter % front->local.toStringWithPort() % front->getType() % front->queries) << endl; counter++; } g_outputBuffer=ret.str(); diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 1ee60dccd5..745a798f02 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -603,6 +603,7 @@ static void connectionThread(int sock, ComboAddress remote) { "address", front->local.toStringWithPort() }, { "udp", front->udpFD >= 0 }, { "tcp", front->tcpFD >= 0 }, + { "type", front->getType() }, { "queries", (double) front->queries.load() }, { "tcpDiedReadingQuery", (double) front->tcpDiedReadingQuery.load() }, { "tcpDiedSendingResponse", (double) front->tcpDiedSendingResponse.load() }, diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 9b35daaa62..0a3eb01f0b 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -600,6 +600,20 @@ struct ClientState return udpFD != -1 ? udpFD : tcpFD; } + std::string getType() const + { + std::string result = udpFD != -1 ? "UDP" : "TCP"; + + if (tlsFrontend) { + result += " (DNS over TLS)"; + } + else if (dnscryptCtx) { + result += " (DNSCrypt)"; + } + + return result; + } + #ifdef HAVE_EBPF shared_ptr d_filter; diff --git a/regression-tests.dnsdist/test_API.py b/regression-tests.dnsdist/test_API.py index 05e1391287..3d751cfe8c 100644 --- a/regression-tests.dnsdist/test_API.py +++ b/regression-tests.dnsdist/test_API.py @@ -114,7 +114,7 @@ class TestAPIBasics(DNSDistTest): self.assertTrue(server['state'] in ['up', 'down', 'UP', 'DOWN']) for frontend in content['frontends']: - for key in ['id', 'address', 'udp', 'tcp', 'queries']: + for key in ['id', 'address', 'udp', 'tcp', 'type', 'queries']: self.assertIn(key, frontend) for key in ['id', 'queries']: