From e6be1266cfe01d8153efd40ca6ccc63e2bae0bbe Mon Sep 17 00:00:00 2001 From: bert hubert Date: Mon, 18 May 2020 23:40:48 +0200 Subject: [PATCH] split up tauth main, add a report hook --- tdns/Makefile | 2 +- tdns/contents.cc | 4 +++ tdns/tauth-main.cc | 21 ++++++++++++++++ tdns/tauth.cc | 61 ++++++++++++++++++++++------------------------ tdns/tdig.cc | 13 +++++----- 5 files changed, 62 insertions(+), 39 deletions(-) create mode 100644 tdns/tauth-main.cc diff --git a/tdns/Makefile b/tdns/Makefile index 90a8f8f..c495d50 100644 --- a/tdns/Makefile +++ b/tdns/Makefile @@ -16,7 +16,7 @@ check: testrunner tauth tdig SIMPLESOCKET = ext/simplesocket/comboaddress.o ext/simplesocket/sclasses.o ext/simplesocket/swrappers.o ext/simplesocket/ext/fmt-5.2.1/src/format.o -tauth: tauth.o record-types.o dns-storage.o dnsmessages.o contents.o tdnssec.o $(SIMPLESOCKET) +tauth: tauth.o tauth-main.o record-types.o dns-storage.o dnsmessages.o contents.o tdnssec.o $(SIMPLESOCKET) $(CXX) -std=gnu++14 $^ -o $@ -pthread tdig: tdig.o record-types.o dns-storage.o dnsmessages.o $(SIMPLESOCKET) diff --git a/tdns/contents.cc b/tdns/contents.cc index caa65bc..3fad1d6 100644 --- a/tdns/contents.cc +++ b/tdns/contents.cc @@ -87,3 +87,7 @@ void loadZones(DNSNode& zones) zones.add({"ds9a", "nl"})->zone=retrieveZone(ComboAddress("52.48.64.3", 53), {"ds9a", "nl"}); zones.add({"powerdns", "org"})->zone=retrieveZone(ComboAddress("52.48.64.3", 53), {"powerdns", "org"}); } + +void reportQuery(DNSName qname, DNSClass qclass, DNSType qtype, const ComboAddress& remote) +{ +} diff --git a/tdns/tauth-main.cc b/tdns/tauth-main.cc new file mode 100644 index 0000000..3026030 --- /dev/null +++ b/tdns/tauth-main.cc @@ -0,0 +1,21 @@ +#include +#include "record-types.hh" +#include "dns-storage.hh" + +using namespace std; + +void launchDNSServer(vector locals); + +int main(int argc, char** argv) +{ + if(argc < 2) { + cerr<<"Syntax: tdns ipaddress:port [ipaddress:port] .. [[ipv6address]:port]] .."< locals; + for(int n= 1; n < argc; ++n) + locals.emplace_back(argv[n], 53); + + launchDNSServer(locals); +} diff --git a/tdns/tauth.cc b/tdns/tauth.cc index 1259cd8..56d0e47 100644 --- a/tdns/tauth.cc +++ b/tdns/tauth.cc @@ -55,6 +55,8 @@ using namespace std; void addAdditional(const DNSNode* bestzone, const DNSName& zone, const vector& toresolve, DNSMessageWriter& response); +void reportQuery(DNSName qname, DNSClass qclass, DNSType qtype, const ComboAddress& remote); + /** \brief This is the main DNS logic function This is the main 'DNS logic' function. It receives a set of zones, @@ -82,6 +84,8 @@ bool processQuestion(const DNSNode& zones, DNSMessageReader& dm, const ComboAddr DNSName origname=qname; // we need this for error reporting, we munch the original name cout<<"Received a query from "< retrieveZone(const ComboAddress& remote, const DNSName& } //! This is the main tdns function -int main(int argc, char** argv) +void launchDNSServer(vector locals) try { - if(argc < 2) { - cerr<<"Syntax: tdns ipaddress:port"< rr; while(dmr.getRR(rrsection, dn, dt, ttl, rr)) { cout << rrsection<<" "<toString()<