diff --git a/Makefile.in b/Makefile.in index 63216493..f6d7acab 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,7 +44,7 @@ libdir = @libdir@ srcdir = @srcdir@ INSTALL = @INSTALL@ -all : default @GETDNS_QUERY@ +all : default @GETDNS_QUERY@ @GETDNS_SERVER_MON@ everything: default cd src/test && $(MAKE) @@ -55,7 +55,7 @@ default: install-lib: cd src && $(MAKE) install -install: getdns.pc getdns_ext_event.pc install-lib @INSTALL_GETDNS_QUERY@ +install: getdns.pc getdns_ext_event.pc install-lib @INSTALL_GETDNS_QUERY@ @INSTALL_GETDNS_SERVER_MON@ $(INSTALL) -m 755 -d $(DESTDIR)$(docdir) $(INSTALL) -m 644 $(srcdir)/AUTHORS $(DESTDIR)$(docdir) $(INSTALL) -m 644 $(srcdir)/ChangeLog $(DESTDIR)$(docdir) @@ -93,7 +93,7 @@ install: getdns.pc getdns_ext_event.pc install-lib @INSTALL_GETDNS_QUERY@ @echo "*** trust anchor management keeping it up-to-date." @echo "***" -uninstall: @UNINSTALL_GETDNS_QUERY@ +uninstall: @UNINSTALL_GETDNS_QUERY@ @UNINSTALL_GETDNS_SERVER_MON@ rm -rf $(DESTDIR)$(docdir) cd doc && $(MAKE) $@ cd src && $(MAKE) $@ @@ -110,6 +110,9 @@ test: default getdns_query: default cd src/tools && $(MAKE) $@ +getdns_server_mon: default + cd src/tools && $(MAKE) $@ + stubby: cd src && $(MAKE) $@ @@ -125,6 +128,12 @@ install-getdns_query: install-lib uninstall-getdns_query: cd src/tools && $(MAKE) $@ +install-getdns_server_mon: install-lib + cd src/tools && $(MAKE) $@ + +uninstall-getdns_server_mon: + cd src/tools && $(MAKE) $@ + install-stubby: cd src && $(MAKE) $@ diff --git a/README.md b/README.md index eb662b18..cada3b41 100644 --- a/README.md +++ b/README.md @@ -87,10 +87,11 @@ If you are building from git, you need to do the following before building: # autoreconf -fi -As well as building the getdns library two other tools may be installed: +As well as building the getdns library three other tools may be installed: * getdns_query: a command line test script wrapper for getdns * stubby: an experimental DNS Privacy enabled client +* getdns_server_mon: test DNS server function and capabilities Note: If you only want to build stubby, then use the `--with-stubby` option when running 'configure'. diff --git a/configure.ac b/configure.ac index 4e7f3f62..66676222 100644 --- a/configure.ac +++ b/configure.ac @@ -1227,6 +1227,22 @@ AC_SUBST(GETDNS_QUERY) AC_SUBST(INSTALL_GETDNS_QUERY) AC_SUBST(UNINSTALL_GETDNS_QUERY) +AC_ARG_WITH(getdns_server_mon, AS_HELP_STRING([--without-getdns_server_mon], + [Do not compile and install the getdns_server_mon tool]), + [], [withval="yes"]) +if test x_$withval = x_no; then + GETDNS_SERVER_MON="" + INSTALL_GETDNS_SERVER_MON="" + UNINSTALL_GETDNS_SERVER_MON="" +else + GETDNS_SERVER_MON="getdns_server_mon" + INSTALL_GETDNS_SERVER_MON="install-getdns_server_mon" + UNINSTALL_GETDNS_SERVER_MON="uninstall-getdns_server_mon" +fi +AC_SUBST(GETDNS_SERVER_MON) +AC_SUBST(INSTALL_GETDNS_SERVER_MON) +AC_SUBST(UNINSTALL_GETDNS_SERVER_MON) + stubby_with_yaml=0 AC_ARG_WITH(stubby, AS_HELP_STRING([--with-stubby], [Compile and install stubby, the (stub) resolver daemon]), diff --git a/src/Makefile.in b/src/Makefile.in index 983f4fc8..59cbfb9b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -202,6 +202,9 @@ test: default getdns_query: default cd tools && $(MAKE) $@ +getdns_server_mon: default + cd tools && $(MAKE) $@ + stubby.lo: $(stubbysrcdir)/src/stubby.c $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -DSTUBBYCONFDIR=\"$(sysconfdir)/stubby\" -DRUNSTATEDIR=\"$(runstatedir)\" -c $< -o $@ diff --git a/src/context.c b/src/context.c index aa1d79d5..21c896f9 100644 --- a/src/context.c +++ b/src/context.c @@ -1049,6 +1049,7 @@ upstream_init(getdns_upstream *upstream, upstream->responses_timeouts = 0; upstream->keepalive_shutdown = 0; upstream->keepalive_timeout = 0; + upstream->server_keepalive_received = 0; /* How is this upstream doing on UDP? */ upstream->to_retry = 1; upstream->back_off = 1; diff --git a/src/context.h b/src/context.h index b4319403..73e6e519 100644 --- a/src/context.h +++ b/src/context.h @@ -193,6 +193,7 @@ typedef struct getdns_upstream { size_t responses_timeouts; size_t keepalive_shutdown; uint64_t keepalive_timeout; + int server_keepalive_received; /* Management of outstanding requests on stateful transports */ getdns_network_req *write_queue; diff --git a/src/request-internal.c b/src/request-internal.c index cc082039..8b5dafdb 100644 --- a/src/request-internal.c +++ b/src/request-internal.c @@ -211,6 +211,7 @@ network_req_init(getdns_network_req *net_req, getdns_dns_req *owner, net_req->debug_tls_auth_status = GETDNS_AUTH_NONE; net_req->debug_tls_peer_cert.size = 0; net_req->debug_tls_peer_cert.data = NULL; + net_req->debug_tls_version = NULL; net_req->debug_udp = 0; /* Scheduling, touch only via _getdns_netreq_change_state! diff --git a/src/stub.c b/src/stub.c index 1bee5760..44a5e422 100644 --- a/src/stub.c +++ b/src/stub.c @@ -344,6 +344,7 @@ process_keepalive( } return; } + upstream->server_keepalive_received = 1; /* Use server sent value unless the client specified a shorter one. Convert to ms first (wire value has units of 100ms) */ uint64_t server_keepalive = ((uint64_t)gldns_read_uint16(position))*100; @@ -1864,12 +1865,14 @@ upstream_write_cb(void *userarg) remove_from_write_queue(upstream, netreq); if (netreq->owner->return_call_reporting && - netreq->upstream->tls_obj && - netreq->debug_tls_peer_cert.data == NULL && - (cert = SSL_get_peer_certificate(netreq->upstream->tls_obj))) { - netreq->debug_tls_peer_cert.size = i2d_X509( - cert, &netreq->debug_tls_peer_cert.data); - X509_free(cert); + netreq->upstream->tls_obj) { + if (netreq->debug_tls_peer_cert.data == NULL && + (cert = SSL_get_peer_certificate(netreq->upstream->tls_obj))) { + netreq->debug_tls_peer_cert.size = i2d_X509( + cert, &netreq->debug_tls_peer_cert.data); + X509_free(cert); + } + netreq->debug_tls_version = SSL_get_version(netreq->upstream->tls_obj); } /* Need this because auth status is reset on connection close */ netreq->debug_tls_auth_status = netreq->upstream->tls_auth_state; diff --git a/src/tools/Makefile.in b/src/tools/Makefile.in index 3cba9659..88d5f21d 100644 --- a/src/tools/Makefile.in +++ b/src/tools/Makefile.in @@ -45,9 +45,9 @@ CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ @CPPFLAGS@ $(WPEDANTIC LDFLAGS=-L.. @LDFLAGS@ LDLIBS=../libgetdns.la @LIBS@ -ALL_OBJS=getdns_query.lo +ALL_OBJS=getdns_query.lo getdns_server_mon.lo -PROGRAMS=getdns_query +PROGRAMS=getdns_query getdns_server_mon .SUFFIXES: .c .o .a .lo .h @@ -68,6 +68,9 @@ $(ALL_OBJS): getdns_query: getdns_query.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ getdns_query.lo $(LDFLAGS) $(LDLIBS) +getdns_server_mon: getdns_server_mon.lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ getdns_server_mon.lo $(LDFLAGS) $(LDLIBS) + stubby: cd .. && $(MAKE) $@ @@ -78,6 +81,13 @@ install-getdns_query: getdns_query uninstall-getdns_query: $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/getdns_query +install-getdns_server_mon: getdns_server_mon + $(INSTALL) -m 755 -d $(DESTDIR)$(bindir) + $(LIBTOOL) --mode=install cp getdns_server_mon $(DESTDIR)$(bindir) + +uninstall-getdns_server_mon: + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/getdns_server_mon + install-stubby: cd .. && $(MAKE) $@ @@ -117,3 +127,10 @@ getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c \ $(srcdir)/../debug.h \ ../getdns/getdns.h \ ../getdns/getdns_extra.h + +# Dependencies for getdns_server_mon +getdns_server_mon.lo getdns_server_mon.o: $(srcdir)/getdns_server_mon.c \ + ../config.h \ + $(srcdir)/../debug.h \ + ../getdns/getdns.h \ + ../getdns/getdns_extra.h diff --git a/src/tools/README.adoc b/src/tools/README.adoc new file mode 100644 index 00000000..2f2389eb --- /dev/null +++ b/src/tools/README.adoc @@ -0,0 +1,263 @@ += getdns tools + +This directory contains some tools based on `getdns`. + +* `getdns_query` - a command line wrapper for `getdns`. +* `getdns_server_mon` - test DNS server function and capabilities. + +== `getdns_query` + +`getdns_query` is a command line wrapper for `getdns` exposing the +features of this implementation (both in the official API and the +additional API functions). + +=== Usage + +---- +usage: getdns_query [