mirror of https://github.com/getdnsapi/getdns.git
Merge branch 'develop' into features/conversion_functions
This commit is contained in:
commit
5bbcbb97a1
|
@ -14,8 +14,6 @@ addons:
|
|||
- libev-dev
|
||||
- bc
|
||||
script:
|
||||
- libtoolize -fic
|
||||
- autoreconf -fi
|
||||
- mkdir tests
|
||||
- cd tests
|
||||
- ../src/test/tpkg/run-all.sh
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
*
|
||||
* Remove STARTTLS implementation (no change to SPEC)
|
||||
* Enable TCP Fast Open when possible. Add OSX support for TFO.
|
||||
* Rename return_call_debugging to return_call_reporting
|
||||
|
||||
* 2015-11-18: Version 0.5.1
|
||||
* Bugfix: growing upstreams arrow.
|
||||
* Bugfix: Segfault on timeout in specific conditions
|
||||
|
|
|
@ -58,7 +58,7 @@ install: all getdns.pc @INSTALL_GETDNS_QUERY@
|
|||
$(INSTALL) -m 644 $(srcdir)/LICENSE $(DESTDIR)$(docdir)
|
||||
$(INSTALL) -m 644 $(srcdir)/NEWS $(DESTDIR)$(docdir)
|
||||
$(INSTALL) -m 644 $(srcdir)/README.md $(DESTDIR)$(docdir)
|
||||
$(INSTALL) -m 644 -d $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(INSTALL) -m 644 getdns.pc $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(docdir)/spec
|
||||
$(INSTALL) -m 644 $(srcdir)/spec/index.html $(DESTDIR)$(docdir)/spec
|
||||
|
@ -235,7 +235,7 @@ distcheck: $(distdir).tar.gz
|
|||
rm -rf $(distdir)
|
||||
@echo "*** Package $(distdir).tar.gz is ready for distribution"
|
||||
|
||||
getdns.pc: getdns.pc.in
|
||||
getdns.pc: $(srcdir)/getdns.pc.in
|
||||
./config.status $@
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in config.status
|
||||
|
|
15
configure.ac
15
configure.ac
|
@ -206,7 +206,7 @@ else
|
|||
fi
|
||||
AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
|
||||
AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
|
||||
AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode])
|
||||
AC_CHECK_FUNCS([OPENSSL_config EVP_md5 EVP_sha1 EVP_sha224 EVP_sha256 EVP_sha384 EVP_sha512 FIPS_mode])
|
||||
AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free,SSL_CTX_set_ecdh_auto], [], [], [
|
||||
AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_OPENSSL_ERR_H
|
||||
|
@ -387,7 +387,18 @@ case "$enable_ecdsa" in
|
|||
;;
|
||||
esac
|
||||
|
||||
|
||||
AC_ARG_ENABLE(draft-dnssec-roadblock-avoidance, AC_HELP_STRING([--enable-draft-dnssec-roadblock-avoidance], [Enable experimental dnssec roadblock avoidance]))
|
||||
AC_ARG_ENABLE(draft-edns-cookies, AC_HELP_STRING([--enable-draft-edns-cookies], [Enable experimental edns cookies]))
|
||||
AC_ARG_ENABLE(all-drafts, AC_HELP_STRING([--enable-all-drafts], [Enable cookies and roadblock avoidance]))
|
||||
case "$enable_all_drafts" in
|
||||
yes)
|
||||
enable_draft_dnssec_roadblock_avoidance=yes
|
||||
enable_draft_edns_cookies=yes
|
||||
;;
|
||||
no|*)
|
||||
;;
|
||||
esac
|
||||
case "$enable_draft_dnssec_roadblock_avoidance" in
|
||||
yes)
|
||||
AC_DEFINE_UNQUOTED([DNSSEC_ROADBLOCK_AVOIDANCE], [1], [Define this to enable the experimental draft dnssec roadblock avoidance.])
|
||||
|
@ -395,8 +406,6 @@ case "$enable_draft_dnssec_roadblock_avoidance" in
|
|||
no|*)
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_ARG_ENABLE(draft-edns-cookies, AC_HELP_STRING([--enable-draft-edns-cookies], [Enable experimental edns cookies]))
|
||||
case "$enable_draft_edns_cookies" in
|
||||
yes)
|
||||
if test "x_$HAVE_SSL" != "x_yes"; then
|
||||
|
|
|
@ -275,10 +275,10 @@ GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE: query type for other than CNAME re
|
|||
Set to the DNS class number (other than Internet (IN) class desired in query.
|
||||
|
||||
.HP 3
|
||||
"return_call_debugging" (int)
|
||||
"return_call_reporting" (int)
|
||||
|
||||
Set to GETDNS_EXTENSION_TRUE to add the name
|
||||
.I call_debugging
|
||||
.I call_reporting
|
||||
(list) to the top level of the response object that includes a dict for each call made to the API. TBD: more detail
|
||||
|
||||
.LP
|
||||
|
|
|
@ -668,7 +668,7 @@ getdns_dict_destroy(extensions);
|
|||
|
||||
<li><code>specify_class</code></li>
|
||||
|
||||
<li><code>return_call_debugging</code></li>
|
||||
<li><code>return_call_reporting</code></li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
@ -865,9 +865,9 @@ contains the class number. Few applications will ever use this extension.</p>
|
|||
<h2>3.6 Extensions Relating to the API</h2>
|
||||
|
||||
<p>An application might want to see debugging information for queries such as the length of time it
|
||||
takes for each query to return to the API. Use the <code>return_call_debugging</code> extension. The
|
||||
takes for each query to return to the API. Use the <code>return_call_reporting</code> extension. The
|
||||
extension's value (an int) is set to <code>GETDNS_EXTENSION_TRUE</code> to add the name
|
||||
<code>call_debugging</code> (a list) to the top level of the response object. Each member of the
|
||||
<code>call_reporting</code> (a list) to the top level of the response object. Each member of the
|
||||
list is a dict that represents one call made for the call to the API. Each member has the following
|
||||
names:</p>
|
||||
|
||||
|
@ -875,10 +875,10 @@ names:</p>
|
|||
<li><code>query_name</code> (a bindata) is the name that was sent</li>
|
||||
<li><code>query_type</code> (an int) is the type that was queried for</li>
|
||||
<li><code>query_to</code> (a bindata) is the address to which the query was sent</li>
|
||||
<li><code>start_time</code> (a bindata) is the time the query started in milliseconds since the epoch,
|
||||
represented as a uint64_t</li>
|
||||
<li><code>end_time</code> (a bindata) is the time the query was received in milliseconds since the epoch,
|
||||
represented as a uint64_t</li>
|
||||
<li><code>run_time</code> (a bindata) is the difference between the time the successful
|
||||
query started and ended in milliseconds, represented
|
||||
as a uint32_t (this does not include time taken for connection set up
|
||||
or transport fallback)</li>
|
||||
<li><code>entire_reply</code> (a bindata) is the entire response received</li>
|
||||
<li><code>dnssec_result</code> (an int) is the DNSSEC status, or <code>GETDNS_DNSSEC_NOT_PERFORMED</code>
|
||||
if DNSSEC validation was not performed</li>
|
||||
|
|
261
src/Makefile.in
261
src/Makefile.in
|
@ -203,8 +203,9 @@ configure.status: configure
|
|||
|
||||
depend:
|
||||
(cd $(srcdir) ; awk 'BEGIN{P=1}{if(P)print}/^# Dependencies/{P=0}' Makefile.in > Makefile.in.new )
|
||||
(cd $(srcdir) ; gcc -MM -I. *.c gldns/*.c compat/*.c util/*.c extension/*.c| \
|
||||
sed -e 's?gldns/?$$(srcdir)/gldns/?g' \
|
||||
(blddir=`pwd`; cd $(srcdir) ; gcc -MM -I. -I"$$blddir" *.c gldns/*.c compat/*.c util/*.c extension/*.c| \
|
||||
sed -e "s? $$blddir/? ?g" \
|
||||
-e 's?gldns/?$$(srcdir)/gldns/?g' \
|
||||
-e 's?compat/?$$(srcdir)/compat/?g' \
|
||||
-e 's?util/?$$(srcdir)/util/?g' \
|
||||
-e 's?extension/?$$(srcdir)/extension/?g' \
|
||||
|
@ -224,118 +225,182 @@ depend:
|
|||
FORCE:
|
||||
|
||||
# Dependencies for gldns, utils, the extensions and compat functions
|
||||
const-info.lo const-info.o: $(srcdir)/const-info.c getdns/getdns.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/const-info.h
|
||||
context.lo context.o: $(srcdir)/context.c config.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \
|
||||
$(srcdir)/gldns/wire2str.h $(srcdir)/context.h getdns/getdns.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \
|
||||
config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h \
|
||||
$(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
|
||||
$(srcdir)/dnssec.h $(srcdir)/stub.h $(srcdir)/list.h
|
||||
convert.lo convert.o: $(srcdir)/convert.c config.h getdns/getdns.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
const-info.lo const-info.o: $(srcdir)/const-info.c \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/const-info.h
|
||||
context.lo context.o: $(srcdir)/context.c \
|
||||
config.h $(srcdir)/debug.h \
|
||||
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/context.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/util-internal.h \
|
||||
$(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/stub.h \
|
||||
$(srcdir)/list.h
|
||||
convert.lo convert.o: $(srcdir)/convert.c \
|
||||
config.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
|
||||
$(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h
|
||||
dict.lo dict.o: $(srcdir)/dict.c $(srcdir)/types-internal.h getdns/getdns.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h config.h $(srcdir)/context.h \
|
||||
$(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
dict.lo dict.o: $(srcdir)/dict.c $(srcdir)/types-internal.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/util-internal.h \
|
||||
config.h $(srcdir)/context.h \
|
||||
$(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
|
||||
$(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/const-info.h $(srcdir)/gldns/wire2str.h
|
||||
dnssec.lo dnssec.o: $(srcdir)/dnssec.c getdns/getdns.h config.h $(srcdir)/context.h \
|
||||
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
|
||||
$(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h \
|
||||
$(srcdir)/gldns/keyraw.h $(srcdir)/gldns/parseutil.h $(srcdir)/general.h $(srcdir)/dict.h $(srcdir)/list.h \
|
||||
$(srcdir)/util/val_secalgo.h
|
||||
general.lo general.o: $(srcdir)/general.c config.h $(srcdir)/gldns/wire2str.h $(srcdir)/context.h getdns/getdns.h \
|
||||
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
|
||||
$(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/stub.h
|
||||
list.lo list.o: $(srcdir)/list.c $(srcdir)/types-internal.h getdns/getdns.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h config.h $(srcdir)/context.h \
|
||||
$(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
dnssec.lo dnssec.o: $(srcdir)/dnssec.c \
|
||||
config.h $(srcdir)/debug.h \
|
||||
getdns/getdns.h \
|
||||
$(srcdir)/context.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/util-internal.h \
|
||||
$(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h \
|
||||
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/keyraw.h \
|
||||
$(srcdir)/gldns/parseutil.h $(srcdir)/general.h $(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/util/val_secalgo.h
|
||||
general.lo general.o: $(srcdir)/general.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/wire2str.h $(srcdir)/context.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/util-internal.h \
|
||||
$(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/stub.h
|
||||
list.lo list.o: $(srcdir)/list.c $(srcdir)/types-internal.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/util-internal.h \
|
||||
config.h $(srcdir)/context.h \
|
||||
$(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
|
||||
$(srcdir)/list.h $(srcdir)/dict.h
|
||||
request-internal.lo request-internal.o: $(srcdir)/request-internal.c config.h $(srcdir)/types-internal.h \
|
||||
getdns/getdns.h getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/libmini_event.h config.h \
|
||||
request-internal.lo request-internal.o: $(srcdir)/request-internal.c \
|
||||
config.h \
|
||||
$(srcdir)/types-internal.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
|
||||
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h \
|
||||
$(srcdir)/gldns/rrdef.h $(srcdir)/dict.h
|
||||
rr-dict.lo rr-dict.o: $(srcdir)/rr-dict.c $(srcdir)/rr-dict.h config.h getdns/getdns.h $(srcdir)/gldns/gbuffer.h \
|
||||
$(srcdir)/util-internal.h $(srcdir)/context.h getdns/getdns_extra.h getdns/getdns.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h config.h \
|
||||
rr-dict.lo rr-dict.o: $(srcdir)/rr-dict.c $(srcdir)/rr-dict.h \
|
||||
config.h \
|
||||
getdns/getdns.h \
|
||||
$(srcdir)/gldns/gbuffer.h $(srcdir)/util-internal.h $(srcdir)/context.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/rr-iter.h \
|
||||
$(srcdir)/gldns/pkthdr.h $(srcdir)/dict.h
|
||||
rr-iter.lo rr-iter.o: $(srcdir)/rr-iter.c $(srcdir)/rr-iter.h getdns/getdns.h $(srcdir)/rr-dict.h config.h \
|
||||
rr-iter.lo rr-iter.o: $(srcdir)/rr-iter.c $(srcdir)/rr-iter.h \
|
||||
getdns/getdns.h \
|
||||
$(srcdir)/rr-dict.h config.h \
|
||||
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h
|
||||
stub.lo stub.o: $(srcdir)/stub.c config.h $(srcdir)/stub.h getdns/getdns.h $(srcdir)/types-internal.h \
|
||||
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/gldns/gbuffer.h \
|
||||
$(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/rr-iter.h \
|
||||
$(srcdir)/rr-dict.h $(srcdir)/context.h $(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/util-internal.h $(srcdir)/general.h
|
||||
sync.lo sync.o: $(srcdir)/sync.c getdns/getdns.h config.h $(srcdir)/context.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \
|
||||
config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/general.h \
|
||||
stub.lo stub.o: $(srcdir)/stub.c \
|
||||
config.h $(srcdir)/debug.h \
|
||||
$(srcdir)/stub.h \
|
||||
getdns/getdns.h \
|
||||
$(srcdir)/types-internal.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h \
|
||||
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/context.h \
|
||||
$(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util-internal.h $(srcdir)/general.h
|
||||
sync.lo sync.o: $(srcdir)/sync.c \
|
||||
getdns/getdns.h \
|
||||
config.h $(srcdir)/context.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/general.h \
|
||||
$(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
|
||||
$(srcdir)/dnssec.h $(srcdir)/stub.h $(srcdir)/gldns/wire2str.h
|
||||
util-internal.lo util-internal.o: $(srcdir)/util-internal.c getdns/getdns.h $(srcdir)/dict.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/types-internal.h getdns/getdns_extra.h getdns/getdns.h $(srcdir)/list.h \
|
||||
$(srcdir)/util-internal.h config.h $(srcdir)/context.h $(srcdir)/extension/libmini_event.h config.h \
|
||||
util-internal.lo util-internal.o: $(srcdir)/util-internal.c \
|
||||
config.h \
|
||||
getdns/getdns.h \
|
||||
$(srcdir)/dict.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/list.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
|
||||
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h
|
||||
version.lo version.o: version.c
|
||||
gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c config.h $(srcdir)/gldns/gbuffer.h
|
||||
keyraw.lo keyraw.o: $(srcdir)/gldns/keyraw.c config.h $(srcdir)/gldns/keyraw.h $(srcdir)/gldns/rrdef.h
|
||||
parse.lo parse.o: $(srcdir)/gldns/parse.c config.h $(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h \
|
||||
gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/gbuffer.h
|
||||
parseutil.lo parseutil.o: $(srcdir)/gldns/parseutil.c config.h $(srcdir)/gldns/parseutil.h
|
||||
rrdef.lo rrdef.o: $(srcdir)/gldns/rrdef.c config.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/parseutil.h
|
||||
str2wire.lo str2wire.o: $(srcdir)/gldns/str2wire.c config.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \
|
||||
$(srcdir)/gldns/wire2str.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h
|
||||
wire2str.lo wire2str.o: $(srcdir)/gldns/wire2str.c config.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h \
|
||||
$(srcdir)/gldns/rrdef.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h \
|
||||
$(srcdir)/gldns/keyraw.h
|
||||
arc4_lock.lo arc4_lock.o: $(srcdir)/compat/arc4_lock.c config.h
|
||||
arc4random.lo arc4random.o: $(srcdir)/compat/arc4random.c config.h $(srcdir)/compat/chacha_private.h
|
||||
arc4random_uniform.lo arc4random_uniform.o: $(srcdir)/compat/arc4random_uniform.c config.h
|
||||
explicit_bzero.lo explicit_bzero.o: $(srcdir)/compat/explicit_bzero.c config.h
|
||||
getentropy_linux.lo getentropy_linux.o: $(srcdir)/compat/getentropy_linux.c config.h
|
||||
getentropy_osx.lo getentropy_osx.o: $(srcdir)/compat/getentropy_osx.c config.h
|
||||
getentropy_solaris.lo getentropy_solaris.o: $(srcdir)/compat/getentropy_solaris.c config.h
|
||||
keyraw.lo keyraw.o: $(srcdir)/gldns/keyraw.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/keyraw.h $(srcdir)/gldns/rrdef.h
|
||||
parse.lo parse.o: $(srcdir)/gldns/parse.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h
|
||||
parseutil.lo parseutil.o: $(srcdir)/gldns/parseutil.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/parseutil.h
|
||||
rrdef.lo rrdef.o: $(srcdir)/gldns/rrdef.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/rrdef.h $(srcdir)/gldns/parseutil.h
|
||||
str2wire.lo str2wire.o: $(srcdir)/gldns/str2wire.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/gbuffer.h \
|
||||
$(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h
|
||||
wire2str.lo wire2str.o: $(srcdir)/gldns/wire2str.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/pkthdr.h \
|
||||
$(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/keyraw.h
|
||||
arc4_lock.lo arc4_lock.o: $(srcdir)/compat/arc4_lock.c \
|
||||
config.h
|
||||
arc4random.lo arc4random.o: $(srcdir)/compat/arc4random.c \
|
||||
config.h \
|
||||
$(srcdir)/compat/chacha_private.h
|
||||
arc4random_uniform.lo arc4random_uniform.o: $(srcdir)/compat/arc4random_uniform.c \
|
||||
config.h
|
||||
explicit_bzero.lo explicit_bzero.o: $(srcdir)/compat/explicit_bzero.c \
|
||||
config.h
|
||||
getentropy_linux.lo getentropy_linux.o: $(srcdir)/compat/getentropy_linux.c \
|
||||
config.h
|
||||
getentropy_osx.lo getentropy_osx.o: $(srcdir)/compat/getentropy_osx.c \
|
||||
config.h
|
||||
getentropy_solaris.lo getentropy_solaris.o: $(srcdir)/compat/getentropy_solaris.c \
|
||||
config.h
|
||||
getentropy_win.lo getentropy_win.o: $(srcdir)/compat/getentropy_win.c
|
||||
sha512.lo sha512.o: $(srcdir)/compat/sha512.c config.h
|
||||
strlcpy.lo strlcpy.o: $(srcdir)/compat/strlcpy.c config.h
|
||||
mini_event.lo mini_event.o: $(srcdir)/util/mini_event.c config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/util/fptr_wlist.h
|
||||
rbtree.lo rbtree.o: $(srcdir)/util/rbtree.c config.h $(srcdir)/util/log.h $(srcdir)/util-internal.h config.h \
|
||||
$(srcdir)/context.h getdns/getdns.h getdns/getdns_extra.h getdns/getdns.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
|
||||
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/util/fptr_wlist.h
|
||||
val_secalgo.lo val_secalgo.o: $(srcdir)/util/val_secalgo.c config.h $(srcdir)/util/val_secalgo.h $(srcdir)/util/log.h \
|
||||
$(srcdir)/util-internal.h config.h $(srcdir)/context.h getdns/getdns.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
|
||||
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/keyraw.h \
|
||||
sha512.lo sha512.o: $(srcdir)/compat/sha512.c \
|
||||
config.h
|
||||
strlcpy.lo strlcpy.o: $(srcdir)/compat/strlcpy.c \
|
||||
config.h
|
||||
mini_event.lo mini_event.o: $(srcdir)/util/mini_event.c \
|
||||
config.h \
|
||||
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/util/fptr_wlist.h
|
||||
rbtree.lo rbtree.o: $(srcdir)/util/rbtree.c \
|
||||
config.h \
|
||||
$(srcdir)/util/log.h $(srcdir)/debug.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/rbtree.h
|
||||
val_secalgo.lo val_secalgo.o: $(srcdir)/util/val_secalgo.c \
|
||||
config.h \
|
||||
$(srcdir)/util/val_secalgo.h $(srcdir)/util/log.h $(srcdir)/debug.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/keyraw.h \
|
||||
$(srcdir)/gldns/gbuffer.h
|
||||
libev.lo libev.o: $(srcdir)/extension/libev.c $(srcdir)/getdns/getdns_ext_libev.h getdns/getdns.h \
|
||||
getdns/getdns_extra.h $(srcdir)/types-internal.h getdns/getdns.h \
|
||||
getdns/getdns_extra.h $(srcdir)/util/rbtree.h config.h
|
||||
libevent.lo libevent.o: $(srcdir)/extension/libevent.c $(srcdir)/getdns/getdns_ext_libevent.h \
|
||||
getdns/getdns.h getdns/getdns_extra.h $(srcdir)/types-internal.h getdns/getdns.h \
|
||||
getdns/getdns_extra.h $(srcdir)/util/rbtree.h config.h
|
||||
libmini_event.lo libmini_event.o: $(srcdir)/extension/libmini_event.c $(srcdir)/extension/libmini_event.h \
|
||||
config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h \
|
||||
getdns/getdns.h getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/context.h config.h $(srcdir)/types-internal.h $(srcdir)/extension/libmini_event.h \
|
||||
$(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
|
||||
$(srcdir)/gldns/pkthdr.h
|
||||
libuv.lo libuv.o: $(srcdir)/extension/libuv.c config.h $(srcdir)/getdns/getdns_ext_libuv.h \
|
||||
getdns/getdns.h getdns/getdns_extra.h $(srcdir)/util-internal.h config.h $(srcdir)/context.h \
|
||||
getdns/getdns.h getdns/getdns_extra.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h
|
||||
libev.lo libev.o: $(srcdir)/extension/libev.c \
|
||||
config.h \
|
||||
$(srcdir)/types-internal.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libev.h
|
||||
libevent.lo libevent.o: $(srcdir)/extension/libevent.c \
|
||||
config.h \
|
||||
$(srcdir)/types-internal.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libevent.h
|
||||
libmini_event.lo libmini_event.o: $(srcdir)/extension/libmini_event.c \
|
||||
config.h $(srcdir)/debug.h \
|
||||
$(srcdir)/types-internal.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h
|
||||
libuv.lo libuv.o: $(srcdir)/extension/libuv.c \
|
||||
config.h $(srcdir)/debug.h \
|
||||
$(srcdir)/types-internal.h \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libuv.h
|
||||
|
|
143
src/const-info.c
143
src/const-info.c
|
@ -7,76 +7,78 @@
|
|||
#include "const-info.h"
|
||||
|
||||
static struct const_info consts_info[] = {
|
||||
{ -1, NULL, "/* <unknown getdns value> */" },
|
||||
{ 0, "GETDNS_RETURN_GOOD", GETDNS_RETURN_GOOD_TEXT },
|
||||
{ 1, "GETDNS_RETURN_GENERIC_ERROR", GETDNS_RETURN_GENERIC_ERROR_TEXT },
|
||||
{ 300, "GETDNS_RETURN_BAD_DOMAIN_NAME", GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT },
|
||||
{ 301, "GETDNS_RETURN_BAD_CONTEXT", GETDNS_RETURN_BAD_CONTEXT_TEXT },
|
||||
{ 302, "GETDNS_RETURN_CONTEXT_UPDATE_FAIL", GETDNS_RETURN_CONTEXT_UPDATE_FAIL_TEXT },
|
||||
{ 303, "GETDNS_RETURN_UNKNOWN_TRANSACTION", GETDNS_RETURN_UNKNOWN_TRANSACTION_TEXT },
|
||||
{ 304, "GETDNS_RETURN_NO_SUCH_LIST_ITEM", GETDNS_RETURN_NO_SUCH_LIST_ITEM_TEXT },
|
||||
{ 305, "GETDNS_RETURN_NO_SUCH_DICT_NAME", GETDNS_RETURN_NO_SUCH_DICT_NAME_TEXT },
|
||||
{ 306, "GETDNS_RETURN_WRONG_TYPE_REQUESTED", GETDNS_RETURN_WRONG_TYPE_REQUESTED_TEXT },
|
||||
{ 307, "GETDNS_RETURN_NO_SUCH_EXTENSION", GETDNS_RETURN_NO_SUCH_EXTENSION_TEXT },
|
||||
{ 308, "GETDNS_RETURN_EXTENSION_MISFORMAT", GETDNS_RETURN_EXTENSION_MISFORMAT_TEXT },
|
||||
{ 309, "GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED", GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT },
|
||||
{ 310, "GETDNS_RETURN_MEMORY_ERROR", GETDNS_RETURN_MEMORY_ERROR_TEXT },
|
||||
{ 311, "GETDNS_RETURN_INVALID_PARAMETER", GETDNS_RETURN_INVALID_PARAMETER_TEXT },
|
||||
{ 400, "GETDNS_DNSSEC_SECURE", GETDNS_DNSSEC_SECURE_TEXT },
|
||||
{ 401, "GETDNS_DNSSEC_BOGUS", GETDNS_DNSSEC_BOGUS_TEXT },
|
||||
{ 402, "GETDNS_DNSSEC_INDETERMINATE", GETDNS_DNSSEC_INDETERMINATE_TEXT },
|
||||
{ 403, "GETDNS_DNSSEC_INSECURE", GETDNS_DNSSEC_INSECURE_TEXT },
|
||||
{ 404, "GETDNS_DNSSEC_NOT_PERFORMED", GETDNS_DNSSEC_NOT_PERFORMED_TEXT },
|
||||
{ 500, "GETDNS_NAMESPACE_DNS", GETDNS_NAMESPACE_DNS_TEXT },
|
||||
{ 501, "GETDNS_NAMESPACE_LOCALNAMES", GETDNS_NAMESPACE_LOCALNAMES_TEXT },
|
||||
{ 502, "GETDNS_NAMESPACE_NETBIOS", GETDNS_NAMESPACE_NETBIOS_TEXT },
|
||||
{ 503, "GETDNS_NAMESPACE_MDNS", GETDNS_NAMESPACE_MDNS_TEXT },
|
||||
{ 504, "GETDNS_NAMESPACE_NIS", GETDNS_NAMESPACE_NIS_TEXT },
|
||||
{ 520, "GETDNS_RESOLUTION_STUB", GETDNS_RESOLUTION_STUB_TEXT },
|
||||
{ 521, "GETDNS_RESOLUTION_RECURSING", GETDNS_RESOLUTION_RECURSING_TEXT },
|
||||
{ 530, "GETDNS_REDIRECTS_FOLLOW", GETDNS_REDIRECTS_FOLLOW_TEXT },
|
||||
{ 531, "GETDNS_REDIRECTS_DO_NOT_FOLLOW", GETDNS_REDIRECTS_DO_NOT_FOLLOW_TEXT },
|
||||
{ 540, "GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP", GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP_TEXT },
|
||||
{ 541, "GETDNS_TRANSPORT_UDP_ONLY", GETDNS_TRANSPORT_UDP_ONLY_TEXT },
|
||||
{ 542, "GETDNS_TRANSPORT_TCP_ONLY", GETDNS_TRANSPORT_TCP_ONLY_TEXT },
|
||||
{ 543, "GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN_TEXT },
|
||||
{ 544, "GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN_TEXT },
|
||||
{ 545, "GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT },
|
||||
{ 546, "GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT },
|
||||
{ 550, "GETDNS_APPEND_NAME_ALWAYS", GETDNS_APPEND_NAME_ALWAYS_TEXT },
|
||||
{ 551, "GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE_TEXT },
|
||||
{ 552, "GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE_TEXT },
|
||||
{ 553, "GETDNS_APPEND_NAME_NEVER", GETDNS_APPEND_NAME_NEVER_TEXT },
|
||||
{ 600, "GETDNS_CONTEXT_CODE_NAMESPACES", GETDNS_CONTEXT_CODE_NAMESPACES_TEXT },
|
||||
{ 601, "GETDNS_CONTEXT_CODE_RESOLUTION_TYPE", GETDNS_CONTEXT_CODE_RESOLUTION_TYPE_TEXT },
|
||||
{ 602, "GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS", GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS_TEXT },
|
||||
{ 603, "GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS", GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS_TEXT },
|
||||
{ 604, "GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS", GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS_TEXT },
|
||||
{ 605, "GETDNS_CONTEXT_CODE_DNS_TRANSPORT", GETDNS_CONTEXT_CODE_DNS_TRANSPORT_TEXT },
|
||||
{ 606, "GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES", GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES_TEXT },
|
||||
{ 607, "GETDNS_CONTEXT_CODE_APPEND_NAME", GETDNS_CONTEXT_CODE_APPEND_NAME_TEXT },
|
||||
{ 608, "GETDNS_CONTEXT_CODE_SUFFIX", GETDNS_CONTEXT_CODE_SUFFIX_TEXT },
|
||||
{ 609, "GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS", GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS_TEXT },
|
||||
{ 610, "GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE", GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE_TEXT },
|
||||
{ 611, "GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE", GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE_TEXT },
|
||||
{ 612, "GETDNS_CONTEXT_CODE_EDNS_VERSION", GETDNS_CONTEXT_CODE_EDNS_VERSION_TEXT },
|
||||
{ 613, "GETDNS_CONTEXT_CODE_EDNS_DO_BIT", GETDNS_CONTEXT_CODE_EDNS_DO_BIT_TEXT },
|
||||
{ 614, "GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW", GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW_TEXT },
|
||||
{ 615, "GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS", GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS_TEXT },
|
||||
{ 616, "GETDNS_CONTEXT_CODE_TIMEOUT", GETDNS_CONTEXT_CODE_TIMEOUT_TEXT },
|
||||
{ 617, "GETDNS_CONTEXT_CODE_IDLE_TIMEOUT", GETDNS_CONTEXT_CODE_IDLE_TIMEOUT_TEXT },
|
||||
{ 618, "GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION", GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION_TEXT },
|
||||
{ 700, "GETDNS_CALLBACK_COMPLETE", GETDNS_CALLBACK_COMPLETE_TEXT },
|
||||
{ 701, "GETDNS_CALLBACK_CANCEL", GETDNS_CALLBACK_CANCEL_TEXT },
|
||||
{ 702, "GETDNS_CALLBACK_TIMEOUT", GETDNS_CALLBACK_TIMEOUT_TEXT },
|
||||
{ 703, "GETDNS_CALLBACK_ERROR", GETDNS_CALLBACK_ERROR_TEXT },
|
||||
{ 800, "GETDNS_NAMETYPE_DNS", GETDNS_NAMETYPE_DNS_TEXT },
|
||||
{ 801, "GETDNS_NAMETYPE_WINS", GETDNS_NAMETYPE_WINS_TEXT },
|
||||
{ 900, "GETDNS_RESPSTATUS_GOOD", GETDNS_RESPSTATUS_GOOD_TEXT },
|
||||
{ 901, "GETDNS_RESPSTATUS_NO_NAME", GETDNS_RESPSTATUS_NO_NAME_TEXT },
|
||||
{ 902, "GETDNS_RESPSTATUS_ALL_TIMEOUT", GETDNS_RESPSTATUS_ALL_TIMEOUT_TEXT },
|
||||
{ 903, "GETDNS_RESPSTATUS_NO_SECURE_ANSWERS", GETDNS_RESPSTATUS_NO_SECURE_ANSWERS_TEXT },
|
||||
{ 904, "GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS", GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS_TEXT },
|
||||
{ -1, NULL, "/* <unknown getdns value> */" },
|
||||
{ 0, "GETDNS_RETURN_GOOD", GETDNS_RETURN_GOOD_TEXT },
|
||||
{ 1, "GETDNS_RETURN_GENERIC_ERROR", GETDNS_RETURN_GENERIC_ERROR_TEXT },
|
||||
{ 300, "GETDNS_RETURN_BAD_DOMAIN_NAME", GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT },
|
||||
{ 301, "GETDNS_RETURN_BAD_CONTEXT", GETDNS_RETURN_BAD_CONTEXT_TEXT },
|
||||
{ 302, "GETDNS_RETURN_CONTEXT_UPDATE_FAIL", GETDNS_RETURN_CONTEXT_UPDATE_FAIL_TEXT },
|
||||
{ 303, "GETDNS_RETURN_UNKNOWN_TRANSACTION", GETDNS_RETURN_UNKNOWN_TRANSACTION_TEXT },
|
||||
{ 304, "GETDNS_RETURN_NO_SUCH_LIST_ITEM", GETDNS_RETURN_NO_SUCH_LIST_ITEM_TEXT },
|
||||
{ 305, "GETDNS_RETURN_NO_SUCH_DICT_NAME", GETDNS_RETURN_NO_SUCH_DICT_NAME_TEXT },
|
||||
{ 306, "GETDNS_RETURN_WRONG_TYPE_REQUESTED", GETDNS_RETURN_WRONG_TYPE_REQUESTED_TEXT },
|
||||
{ 307, "GETDNS_RETURN_NO_SUCH_EXTENSION", GETDNS_RETURN_NO_SUCH_EXTENSION_TEXT },
|
||||
{ 308, "GETDNS_RETURN_EXTENSION_MISFORMAT", GETDNS_RETURN_EXTENSION_MISFORMAT_TEXT },
|
||||
{ 309, "GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED", GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT },
|
||||
{ 310, "GETDNS_RETURN_MEMORY_ERROR", GETDNS_RETURN_MEMORY_ERROR_TEXT },
|
||||
{ 311, "GETDNS_RETURN_INVALID_PARAMETER", GETDNS_RETURN_INVALID_PARAMETER_TEXT },
|
||||
{ 312, "GETDNS_RETURN_NOT_IMPLEMENTED", GETDNS_RETURN_NOT_IMPLEMENTED_TEXT },
|
||||
{ 400, "GETDNS_DNSSEC_SECURE", GETDNS_DNSSEC_SECURE_TEXT },
|
||||
{ 401, "GETDNS_DNSSEC_BOGUS", GETDNS_DNSSEC_BOGUS_TEXT },
|
||||
{ 402, "GETDNS_DNSSEC_INDETERMINATE", GETDNS_DNSSEC_INDETERMINATE_TEXT },
|
||||
{ 403, "GETDNS_DNSSEC_INSECURE", GETDNS_DNSSEC_INSECURE_TEXT },
|
||||
{ 404, "GETDNS_DNSSEC_NOT_PERFORMED", GETDNS_DNSSEC_NOT_PERFORMED_TEXT },
|
||||
{ 500, "GETDNS_NAMESPACE_DNS", GETDNS_NAMESPACE_DNS_TEXT },
|
||||
{ 501, "GETDNS_NAMESPACE_LOCALNAMES", GETDNS_NAMESPACE_LOCALNAMES_TEXT },
|
||||
{ 502, "GETDNS_NAMESPACE_NETBIOS", GETDNS_NAMESPACE_NETBIOS_TEXT },
|
||||
{ 503, "GETDNS_NAMESPACE_MDNS", GETDNS_NAMESPACE_MDNS_TEXT },
|
||||
{ 504, "GETDNS_NAMESPACE_NIS", GETDNS_NAMESPACE_NIS_TEXT },
|
||||
{ 520, "GETDNS_RESOLUTION_STUB", GETDNS_RESOLUTION_STUB_TEXT },
|
||||
{ 521, "GETDNS_RESOLUTION_RECURSING", GETDNS_RESOLUTION_RECURSING_TEXT },
|
||||
{ 530, "GETDNS_REDIRECTS_FOLLOW", GETDNS_REDIRECTS_FOLLOW_TEXT },
|
||||
{ 531, "GETDNS_REDIRECTS_DO_NOT_FOLLOW", GETDNS_REDIRECTS_DO_NOT_FOLLOW_TEXT },
|
||||
{ 540, "GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP", GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP_TEXT },
|
||||
{ 541, "GETDNS_TRANSPORT_UDP_ONLY", GETDNS_TRANSPORT_UDP_ONLY_TEXT },
|
||||
{ 542, "GETDNS_TRANSPORT_TCP_ONLY", GETDNS_TRANSPORT_TCP_ONLY_TEXT },
|
||||
{ 543, "GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN_TEXT },
|
||||
{ 544, "GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN_TEXT },
|
||||
{ 545, "GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT },
|
||||
{ 550, "GETDNS_APPEND_NAME_ALWAYS", GETDNS_APPEND_NAME_ALWAYS_TEXT },
|
||||
{ 551, "GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE_TEXT },
|
||||
{ 552, "GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE_TEXT },
|
||||
{ 553, "GETDNS_APPEND_NAME_NEVER", GETDNS_APPEND_NAME_NEVER_TEXT },
|
||||
{ 600, "GETDNS_CONTEXT_CODE_NAMESPACES", GETDNS_CONTEXT_CODE_NAMESPACES_TEXT },
|
||||
{ 601, "GETDNS_CONTEXT_CODE_RESOLUTION_TYPE", GETDNS_CONTEXT_CODE_RESOLUTION_TYPE_TEXT },
|
||||
{ 602, "GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS", GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS_TEXT },
|
||||
{ 603, "GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS", GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS_TEXT },
|
||||
{ 604, "GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS", GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS_TEXT },
|
||||
{ 605, "GETDNS_CONTEXT_CODE_DNS_TRANSPORT", GETDNS_CONTEXT_CODE_DNS_TRANSPORT_TEXT },
|
||||
{ 606, "GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES", GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES_TEXT },
|
||||
{ 607, "GETDNS_CONTEXT_CODE_APPEND_NAME", GETDNS_CONTEXT_CODE_APPEND_NAME_TEXT },
|
||||
{ 608, "GETDNS_CONTEXT_CODE_SUFFIX", GETDNS_CONTEXT_CODE_SUFFIX_TEXT },
|
||||
{ 609, "GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS", GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS_TEXT },
|
||||
{ 610, "GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE", GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE_TEXT },
|
||||
{ 611, "GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE", GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE_TEXT },
|
||||
{ 612, "GETDNS_CONTEXT_CODE_EDNS_VERSION", GETDNS_CONTEXT_CODE_EDNS_VERSION_TEXT },
|
||||
{ 613, "GETDNS_CONTEXT_CODE_EDNS_DO_BIT", GETDNS_CONTEXT_CODE_EDNS_DO_BIT_TEXT },
|
||||
{ 614, "GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW", GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW_TEXT },
|
||||
{ 615, "GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS", GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS_TEXT },
|
||||
{ 616, "GETDNS_CONTEXT_CODE_TIMEOUT", GETDNS_CONTEXT_CODE_TIMEOUT_TEXT },
|
||||
{ 617, "GETDNS_CONTEXT_CODE_IDLE_TIMEOUT", GETDNS_CONTEXT_CODE_IDLE_TIMEOUT_TEXT },
|
||||
{ 618, "GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION", GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION_TEXT },
|
||||
{ 619, "GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE", GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE_TEXT },
|
||||
{ 620, "GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE", GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE_TEXT },
|
||||
{ 700, "GETDNS_CALLBACK_COMPLETE", GETDNS_CALLBACK_COMPLETE_TEXT },
|
||||
{ 701, "GETDNS_CALLBACK_CANCEL", GETDNS_CALLBACK_CANCEL_TEXT },
|
||||
{ 702, "GETDNS_CALLBACK_TIMEOUT", GETDNS_CALLBACK_TIMEOUT_TEXT },
|
||||
{ 703, "GETDNS_CALLBACK_ERROR", GETDNS_CALLBACK_ERROR_TEXT },
|
||||
{ 800, "GETDNS_NAMETYPE_DNS", GETDNS_NAMETYPE_DNS_TEXT },
|
||||
{ 801, "GETDNS_NAMETYPE_WINS", GETDNS_NAMETYPE_WINS_TEXT },
|
||||
{ 900, "GETDNS_RESPSTATUS_GOOD", GETDNS_RESPSTATUS_GOOD_TEXT },
|
||||
{ 901, "GETDNS_RESPSTATUS_NO_NAME", GETDNS_RESPSTATUS_NO_NAME_TEXT },
|
||||
{ 902, "GETDNS_RESPSTATUS_ALL_TIMEOUT", GETDNS_RESPSTATUS_ALL_TIMEOUT_TEXT },
|
||||
{ 903, "GETDNS_RESPSTATUS_NO_SECURE_ANSWERS", GETDNS_RESPSTATUS_NO_SECURE_ANSWERS_TEXT },
|
||||
{ 904, "GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS", GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS_TEXT },
|
||||
{ 1000, "GETDNS_EXTENSION_TRUE", GETDNS_EXTENSION_TRUE_TEXT },
|
||||
{ 1001, "GETDNS_EXTENSION_FALSE", GETDNS_EXTENSION_FALSE_TEXT },
|
||||
{ 1100, "GETDNS_BAD_DNS_CNAME_IN_TARGET", GETDNS_BAD_DNS_CNAME_IN_TARGET_TEXT },
|
||||
|
@ -85,7 +87,6 @@ static struct const_info consts_info[] = {
|
|||
{ 1200, "GETDNS_TRANSPORT_UDP", GETDNS_TRANSPORT_UDP_TEXT },
|
||||
{ 1201, "GETDNS_TRANSPORT_TCP", GETDNS_TRANSPORT_TCP_TEXT },
|
||||
{ 1202, "GETDNS_TRANSPORT_TLS", GETDNS_TRANSPORT_TLS_TEXT },
|
||||
{ 1203, "GETDNS_TRANSPORT_STARTTLS", GETDNS_TRANSPORT_STARTTLS_TEXT },
|
||||
{ 1300, "GETDNS_AUTHENTICATION_NONE", GETDNS_AUTHENTICATION_NONE_TEXT },
|
||||
{ 1301, "GETDNS_AUTHENTICATION_HOSTNAME", GETDNS_AUTHENTICATION_HOSTNAME_TEXT },
|
||||
};
|
||||
|
|
339
src/context.c
339
src/context.c
|
@ -45,6 +45,7 @@
|
|||
#include <ctype.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "debug.h"
|
||||
#include "gldns/str2wire.h"
|
||||
#include "gldns/wire2str.h"
|
||||
#include "context.h"
|
||||
|
@ -53,6 +54,7 @@
|
|||
#include "dnssec.h"
|
||||
#include "stub.h"
|
||||
#include "list.h"
|
||||
#include "dict.h"
|
||||
|
||||
#define GETDNS_PORT_ZERO 0
|
||||
#define GETDNS_PORT_DNS 53
|
||||
|
@ -70,23 +72,23 @@ typedef struct host_name_addrs {
|
|||
uint8_t host_name[];
|
||||
} host_name_addrs;
|
||||
|
||||
|
||||
/* If changing these lists also remember to
|
||||
change the value of GETDNS_UPSTREAM_TRANSPORTS */
|
||||
static getdns_transport_list_t
|
||||
getdns_upstream_transports[GETDNS_UPSTREAM_TRANSPORTS] = {
|
||||
GETDNS_TRANSPORT_STARTTLS, // Define before TCP to ease fallback
|
||||
GETDNS_TRANSPORT_TCP,
|
||||
GETDNS_TRANSPORT_TLS,
|
||||
};
|
||||
|
||||
static in_port_t
|
||||
getdns_port_array[GETDNS_UPSTREAM_TRANSPORTS] = {
|
||||
GETDNS_PORT_DNS,
|
||||
GETDNS_PORT_DNS,
|
||||
GETDNS_PORT_DNS_OVER_TLS
|
||||
};
|
||||
|
||||
char*
|
||||
getdns_port_str_array[] = {
|
||||
GETDNS_STR_PORT_DNS,
|
||||
GETDNS_STR_PORT_DNS,
|
||||
GETDNS_STR_PORT_DNS_OVER_TLS
|
||||
};
|
||||
|
@ -166,7 +168,7 @@ static inline void canonicalize_dname(uint8_t *dname)
|
|||
{
|
||||
uint8_t *next_label;
|
||||
|
||||
while (*dname) {
|
||||
while (*dname && !(*dname & 0xC0)) {
|
||||
next_label = dname + *dname + 1;
|
||||
dname += 1;
|
||||
while (dname < next_label) {
|
||||
|
@ -557,6 +559,7 @@ _getdns_upstream_shutdown(getdns_upstream *upstream)
|
|||
upstream->tcp.write_error = 0;
|
||||
upstream->writes_done = 0;
|
||||
upstream->responses_received = 0;
|
||||
upstream->keepalive_timeout = 0;
|
||||
if (upstream->tls_hs_state != GETDNS_HS_FAILED) {
|
||||
upstream->tls_hs_state = GETDNS_HS_NONE;
|
||||
upstream->tls_auth_failed = 0;
|
||||
|
@ -574,8 +577,7 @@ _getdns_upstream_shutdown(getdns_upstream *upstream)
|
|||
static int
|
||||
tls_is_in_transports_list(getdns_context *context) {
|
||||
for (int i=0; i< context->dns_transport_count;i++) {
|
||||
if (context->dns_transports[i] == GETDNS_TRANSPORT_TLS ||
|
||||
context->dns_transports[i] == GETDNS_TRANSPORT_STARTTLS)
|
||||
if (context->dns_transports[i] == GETDNS_TRANSPORT_TLS)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -585,8 +587,7 @@ static int
|
|||
tls_only_is_in_transports_list(getdns_context *context) {
|
||||
if (context->dns_transport_count != 1)
|
||||
return 0;
|
||||
if (context->dns_transports[0] == GETDNS_TRANSPORT_TLS ||
|
||||
context->dns_transports[0] == GETDNS_TRANSPORT_STARTTLS)
|
||||
if (context->dns_transports[0] == GETDNS_TRANSPORT_TLS)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -598,6 +599,64 @@ net_req_query_id_cmp(const void *id1, const void *id2)
|
|||
return (intptr_t)id1 - (intptr_t)id2;
|
||||
}
|
||||
|
||||
static getdns_tsig_info tsig_info[] = {
|
||||
{ GETDNS_NO_TSIG, NULL, 0, NULL, 0, 0, 0 }
|
||||
, { GETDNS_HMAC_MD5 , "hmac-md5.sig-alg.reg.int", 24
|
||||
, (uint8_t *)"\x08hmac-md5\x07sig-alg\x03reg\x03int", 26, 10, 16 }
|
||||
, { GETDNS_NO_TSIG, NULL, 0, NULL, 0, 0, 0 }
|
||||
, { GETDNS_HMAC_SHA1 , "hmac-sha1" , 9
|
||||
, (uint8_t *)"\x09hmac-sha1" , 11, 10, 20 }
|
||||
, { GETDNS_HMAC_SHA224, "hmac-sha224", 11
|
||||
, (uint8_t *)"\x0bhmac-sha224", 13, 14, 28 }
|
||||
, { GETDNS_HMAC_SHA224, "hmac-sha256", 11
|
||||
, (uint8_t *)"\x0bhmac-sha256", 13, 16, 32 }
|
||||
, { GETDNS_HMAC_SHA224, "hmac-sha384", 11
|
||||
, (uint8_t *)"\x0bhmac-sha383", 13, 24, 48 }
|
||||
, { GETDNS_HMAC_SHA224, "hmac-sha512", 11
|
||||
, (uint8_t *)"\x0bhmac-sha512", 13, 32, 64 }
|
||||
, { GETDNS_HMAC_MD5 , "hmac-md5" , 8
|
||||
, (uint8_t *)"\x08hmac-md5" , 10, 10, 16 }
|
||||
};
|
||||
|
||||
const getdns_tsig_info *_getdns_get_tsig_info(getdns_tsig_algo tsig_alg)
|
||||
{
|
||||
return tsig_alg > sizeof(tsig_info) - 1
|
||||
|| tsig_info[tsig_alg].alg == GETDNS_NO_TSIG ? NULL
|
||||
: &tsig_info[tsig_alg];
|
||||
}
|
||||
|
||||
static const getdns_tsig_algo _getdns_get_tsig_algo(getdns_bindata *algo)
|
||||
{
|
||||
getdns_tsig_info *i;
|
||||
|
||||
if (!algo || algo->size == 0)
|
||||
return GETDNS_NO_TSIG;
|
||||
|
||||
if (algo->data[algo->size-1] != 0) {
|
||||
/* Unterminated string */
|
||||
for (i = tsig_info; i < tsig_info + sizeof(tsig_info); i++)
|
||||
if (algo->size == i->strlen_name &&
|
||||
strncasecmp((const char *)algo->data, i->name,
|
||||
i->strlen_name) == 0)
|
||||
return i->alg;
|
||||
|
||||
} else if (!_getdns_bindata_is_dname(algo)) {
|
||||
/* Terminated string */
|
||||
for (i = tsig_info; i < tsig_info + sizeof(tsig_info); i++)
|
||||
if (algo->size - 1 == i->strlen_name &&
|
||||
strncasecmp((const char *)algo->data, i->name,
|
||||
i->strlen_name) == 0)
|
||||
return i->alg;
|
||||
|
||||
} else {
|
||||
/* fqdn, canonical_dname_compare is now safe to use! */
|
||||
for (i = tsig_info; i < tsig_info + sizeof(tsig_info); i++)
|
||||
if (canonical_dname_compare(algo->data, i->dname) == 0)
|
||||
return i->alg;
|
||||
}
|
||||
return GETDNS_NO_TSIG;
|
||||
}
|
||||
|
||||
static void
|
||||
upstream_init(getdns_upstream *upstream,
|
||||
getdns_upstreams *parent, struct addrinfo *ai)
|
||||
|
@ -610,13 +669,13 @@ upstream_init(getdns_upstream *upstream,
|
|||
/* How is this upstream doing? */
|
||||
upstream->writes_done = 0;
|
||||
upstream->responses_received = 0;
|
||||
upstream->keepalive_timeout = 0;
|
||||
upstream->to_retry = 2;
|
||||
upstream->back_off = 1;
|
||||
|
||||
/* For sharing a socket to this upstream with TCP */
|
||||
upstream->fd = -1;
|
||||
upstream->tls_obj = NULL;
|
||||
upstream->starttls_req = NULL;
|
||||
upstream->transport = GETDNS_TRANSPORT_TCP;
|
||||
upstream->tls_hs_state = GETDNS_HS_NONE;
|
||||
upstream->tls_auth_failed = 0;
|
||||
|
@ -634,6 +693,10 @@ upstream_init(getdns_upstream *upstream,
|
|||
upstream->has_prev_client_cookie = 0;
|
||||
upstream->has_server_cookie = 0;
|
||||
|
||||
upstream->tsig_alg = GETDNS_NO_TSIG;
|
||||
upstream->tsig_dname_len = 0;
|
||||
upstream->tsig_size = 0;
|
||||
|
||||
/* Tracking of network requests on this socket */
|
||||
_getdns_rbtree_init(&upstream->netreq_by_query_id,
|
||||
net_req_query_id_cmp);
|
||||
|
@ -1249,18 +1312,17 @@ getdns_set_base_dns_transports(
|
|||
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
|
||||
/* Check for valid transports and that they are used only once*/
|
||||
int u=0,t=0,l=0,s=0;
|
||||
int u=0,t=0,l=0;
|
||||
for(i=0; i<transport_count; i++)
|
||||
{
|
||||
switch (transports[i]) {
|
||||
case GETDNS_TRANSPORT_UDP: u++; break;
|
||||
case GETDNS_TRANSPORT_TCP: t++; break;
|
||||
case GETDNS_TRANSPORT_TLS: l++; break;
|
||||
case GETDNS_TRANSPORT_STARTTLS: s++; break;
|
||||
default: return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
if ( u>1 || t>1 || l>1 || s>1)
|
||||
if ( u>1 || t>1 || l>1)
|
||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
|
||||
if (!(new_transports = GETDNS_XMALLOC(context->my_mf,
|
||||
|
@ -1297,7 +1359,6 @@ set_ub_dns_transport(struct getdns_context* context) {
|
|||
set_ub_string_opt(context, "do-tcp:", "yes");
|
||||
break;
|
||||
case GETDNS_TRANSPORT_TLS:
|
||||
case GETDNS_TRANSPORT_STARTTLS:
|
||||
set_ub_string_opt(context, "do-udp:", "no");
|
||||
set_ub_string_opt(context, "do-tcp:", "yes");
|
||||
/* Find out if there is a fallback available. */
|
||||
|
@ -1314,15 +1375,9 @@ set_ub_dns_transport(struct getdns_context* context) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (context->dns_transports[0] == GETDNS_TRANSPORT_TLS) {
|
||||
if (fallback == 0)
|
||||
/* Use TLS if it is the only thing.*/
|
||||
set_ub_string_opt(context, "ssl-upstream:", "yes");
|
||||
break;
|
||||
} else if (fallback == 0)
|
||||
/* Can't support STARTTLS with no fallback. This leads to
|
||||
* timeouts with un stub validation.... */
|
||||
set_ub_string_opt(context, "do-tcp:", "no");
|
||||
if (fallback == 0)
|
||||
/* Use TLS if it is the only thing.*/
|
||||
set_ub_string_opt(context, "ssl-upstream:", "yes");
|
||||
break;
|
||||
default:
|
||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
|
@ -1379,10 +1434,6 @@ getdns_context_set_dns_transport(
|
|||
context->dns_transports[0] = GETDNS_TRANSPORT_TLS;
|
||||
context->dns_transports[1] = GETDNS_TRANSPORT_TCP;
|
||||
break;
|
||||
case GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN:
|
||||
context->dns_transports[0] = GETDNS_TRANSPORT_STARTTLS;
|
||||
context->dns_transports[1] = GETDNS_TRANSPORT_TCP;
|
||||
break;
|
||||
default:
|
||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
}
|
||||
|
@ -1496,9 +1547,8 @@ getdns_context_set_idle_timeout(struct getdns_context *context, uint64_t timeout
|
|||
{
|
||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
|
||||
if (timeout == 0) {
|
||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
/* Shuold we enforce maximum based on edns-tcp-keepalive spec? */
|
||||
/* 0 should be allowed as that is the default.*/
|
||||
|
||||
context->idle_timeout = timeout;
|
||||
|
||||
|
@ -1714,15 +1764,21 @@ getdns_context_set_upstream_recursive_servers(struct getdns_context *context,
|
|||
upstreams = upstreams_create(
|
||||
context, count * GETDNS_UPSTREAM_TRANSPORTS);
|
||||
for (i = 0; i < count; i++) {
|
||||
getdns_dict *dict;
|
||||
getdns_dict *dict;
|
||||
getdns_bindata *address_type;
|
||||
getdns_bindata *address_data;
|
||||
getdns_bindata *tls_auth_name;
|
||||
struct sockaddr_storage addr;
|
||||
|
||||
getdns_bindata *scope_id;
|
||||
getdns_bindata *scope_id;
|
||||
getdns_upstream *upstream;
|
||||
|
||||
getdns_bindata *tsig_alg_name, *tsig_name, *tsig_key;
|
||||
getdns_tsig_algo tsig_alg;
|
||||
char tsig_name_str[1024];
|
||||
uint8_t tsig_dname_spc[256], *tsig_dname;
|
||||
size_t tsig_dname_len;
|
||||
|
||||
if ((r = getdns_list_get_dict(upstream_list, i, &dict)))
|
||||
goto error;
|
||||
|
||||
|
@ -1759,6 +1815,63 @@ getdns_context_set_upstream_recursive_servers(struct getdns_context *context,
|
|||
eos[scope_id->size] = 0;
|
||||
}
|
||||
|
||||
tsig_alg_name = tsig_name = tsig_key = NULL;
|
||||
tsig_dname = NULL;
|
||||
tsig_dname_len = 0;
|
||||
|
||||
if (getdns_dict_get_bindata(dict,
|
||||
"tsig_algorithm", &tsig_alg_name) == GETDNS_RETURN_GOOD)
|
||||
tsig_alg = _getdns_get_tsig_algo(tsig_alg_name);
|
||||
else
|
||||
tsig_alg = GETDNS_HMAC_MD5;
|
||||
|
||||
if (getdns_dict_get_bindata(dict, "tsig_name", &tsig_name))
|
||||
tsig_alg = GETDNS_NO_TSIG; /* No name, no TSIG */
|
||||
|
||||
else if (tsig_name->size == 0)
|
||||
tsig_alg = GETDNS_NO_TSIG;
|
||||
|
||||
else if (tsig_name->data[tsig_name->size - 1] != 0) {
|
||||
/* Unterminated string */
|
||||
if (tsig_name->size >= sizeof(tsig_name_str) - 1)
|
||||
tsig_alg = GETDNS_NO_TSIG;
|
||||
else {
|
||||
(void) memcpy(tsig_name_str, tsig_name->data
|
||||
, tsig_name->size);
|
||||
tsig_name_str[tsig_name->size] = 0;
|
||||
|
||||
tsig_dname_len = sizeof(tsig_dname_spc);
|
||||
if (gldns_str2wire_dname_buf(tsig_name_str,
|
||||
tsig_dname_spc, &tsig_dname_len))
|
||||
tsig_alg = GETDNS_NO_TSIG;
|
||||
else
|
||||
tsig_dname = tsig_dname_spc;
|
||||
}
|
||||
} else if (!_getdns_bindata_is_dname(tsig_name)) {
|
||||
/* Terminated string */
|
||||
tsig_dname_len = sizeof(tsig_dname_spc);
|
||||
if (gldns_str2wire_dname_buf(tsig_name_str,
|
||||
tsig_dname_spc, &tsig_dname_len))
|
||||
tsig_alg = GETDNS_NO_TSIG;
|
||||
else
|
||||
tsig_dname = tsig_dname_spc;
|
||||
|
||||
} else if (tsig_name->size > sizeof(tsig_dname_spc))
|
||||
tsig_alg = GETDNS_NO_TSIG;
|
||||
|
||||
else {
|
||||
/* fqdn */
|
||||
tsig_dname = memcpy(tsig_dname_spc, tsig_name->data
|
||||
, tsig_name->size);
|
||||
tsig_dname_len = tsig_name->size;
|
||||
}
|
||||
if (getdns_dict_get_bindata(dict, "tsig_secret", &tsig_key))
|
||||
tsig_alg = GETDNS_NO_TSIG; /* No key, no TSIG */
|
||||
|
||||
/* Don't check TSIG length contraints here.
|
||||
* Let the upstream decide what is secure enough.
|
||||
*/
|
||||
|
||||
/* Loop to create upstreams as needed*/
|
||||
for (size_t j = 0; j < GETDNS_UPSTREAM_TRANSPORTS; j++) {
|
||||
uint32_t port;
|
||||
|
@ -1786,8 +1899,7 @@ getdns_context_set_upstream_recursive_servers(struct getdns_context *context,
|
|||
upstream->addr.ss_family = addr.ss_family;
|
||||
upstream_init(upstream, upstreams, ai);
|
||||
upstream->transport = getdns_upstream_transports[j];
|
||||
if (getdns_upstream_transports[j] == GETDNS_TRANSPORT_TLS ||
|
||||
getdns_upstream_transports[j] == GETDNS_TRANSPORT_STARTTLS) {
|
||||
if (getdns_upstream_transports[j] == GETDNS_TRANSPORT_TLS) {
|
||||
if ((r = getdns_dict_get_bindata(
|
||||
dict, "tls_auth_name", &tls_auth_name)) == GETDNS_RETURN_GOOD) {
|
||||
/*TODO: VALIDATE THIS STRING!*/
|
||||
|
@ -1797,6 +1909,25 @@ getdns_context_set_upstream_recursive_servers(struct getdns_context *context,
|
|||
upstream->tls_auth_name[tls_auth_name->size] = '\0';
|
||||
}
|
||||
}
|
||||
if ((upstream->tsig_alg = tsig_alg)) {
|
||||
if (tsig_name) {
|
||||
(void) memcpy(upstream->tsig_dname,
|
||||
tsig_dname, tsig_dname_len);
|
||||
upstream->tsig_dname_len =
|
||||
tsig_dname_len;
|
||||
} else
|
||||
upstream->tsig_dname_len = 0;
|
||||
|
||||
if (tsig_key) {
|
||||
(void) memcpy(upstream->tsig_key,
|
||||
tsig_key->data, tsig_key->size);
|
||||
upstream->tsig_size = tsig_key->size;
|
||||
} else
|
||||
upstream->tsig_size = 0;
|
||||
} else {
|
||||
upstream->tsig_dname_len = 0;
|
||||
upstream->tsig_size = 0;
|
||||
}
|
||||
upstreams->count++;
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
|
@ -2275,9 +2406,9 @@ _getdns_context_prepare_for_resolution(struct getdns_context *context,
|
|||
}
|
||||
}
|
||||
|
||||
/* Block use of STARTTLS/TLS ONLY in recursive mode as it won't work */
|
||||
/* Block use of TLS ONLY in recursive mode as it won't work */
|
||||
/* Note: If TLS is used in recursive mode this will try TLS on port
|
||||
* 53 so it is blocked here. So is 'STARTTLS only' at the moment. */
|
||||
* 53 so it is blocked here. */
|
||||
if (context->resolution_type == GETDNS_RESOLUTION_RECURSING &&
|
||||
tls_only_is_in_transports_list(context) == 1)
|
||||
return GETDNS_RETURN_BAD_CONTEXT;
|
||||
|
@ -2536,9 +2667,12 @@ upstream_port(getdns_upstream *upstream)
|
|||
}
|
||||
|
||||
static getdns_dict*
|
||||
_get_context_settings(getdns_context* context) {
|
||||
_get_context_settings(getdns_context* context)
|
||||
{
|
||||
getdns_return_t r = GETDNS_RETURN_GOOD;
|
||||
getdns_dict* result = getdns_dict_create_with_context(context);
|
||||
getdns_list *upstreams;
|
||||
|
||||
if (!result) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2556,34 +2690,8 @@ _get_context_settings(getdns_context* context) {
|
|||
r |= getdns_dict_set_int(result, "append_name", context->append_name);
|
||||
/* list fields */
|
||||
if (context->suffix) r |= getdns_dict_set_list(result, "suffix", context->suffix);
|
||||
if (context->upstreams && context->upstreams->count > 0) {
|
||||
size_t i;
|
||||
getdns_upstream *upstream;
|
||||
getdns_list *upstreams =
|
||||
getdns_list_create_with_context(context);
|
||||
|
||||
for (i = 0; i < context->upstreams->count;) {
|
||||
size_t j;
|
||||
getdns_dict *d;
|
||||
upstream = &context->upstreams->upstreams[i];
|
||||
d = sockaddr_dict(context,
|
||||
(struct sockaddr *)&upstream->addr);
|
||||
for ( j = 1, i++
|
||||
; j < GETDNS_UPSTREAM_TRANSPORTS &&
|
||||
i < context->upstreams->count
|
||||
; j++, i++) {
|
||||
|
||||
upstream = &context->upstreams->upstreams[i];
|
||||
if (upstream->transport != GETDNS_TRANSPORT_TLS)
|
||||
continue;
|
||||
if (upstream_port(upstream) != getdns_port_array[j])
|
||||
continue;
|
||||
(void) getdns_dict_set_int(d, "tls_port",
|
||||
(uint32_t) upstream_port(upstream));
|
||||
}
|
||||
r |= _getdns_list_append_dict(upstreams, d);
|
||||
getdns_dict_destroy(d);
|
||||
}
|
||||
|
||||
if (!getdns_context_get_upstream_recursive_servers(context, &upstreams)) {
|
||||
r |= getdns_dict_set_list(result, "upstream_recursive_servers",
|
||||
upstreams);
|
||||
getdns_list_destroy(upstreams);
|
||||
|
@ -2817,12 +2925,6 @@ getdns_context_get_dns_transport(getdns_context *context,
|
|||
else
|
||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||
}
|
||||
if (transports[0] == GETDNS_TRANSPORT_STARTTLS) {
|
||||
if (count == 2 && transports[1] == GETDNS_TRANSPORT_TCP)
|
||||
*value = GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN;
|
||||
else
|
||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||
}
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
|
@ -2950,43 +3052,88 @@ getdns_context_get_dnssec_allowed_skew(getdns_context *context,
|
|||
|
||||
getdns_return_t
|
||||
getdns_context_get_upstream_recursive_servers(getdns_context *context,
|
||||
getdns_list **upstream_list) {
|
||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
RETURN_IF_NULL(upstream_list, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
*upstream_list = NULL;
|
||||
if (context->upstreams && context->upstreams->count > 0) {
|
||||
getdns_return_t r = GETDNS_RETURN_GOOD;
|
||||
size_t i;
|
||||
getdns_upstream *upstream;
|
||||
getdns_list *upstreams = getdns_list_create();
|
||||
for (i = 0; i < context->upstreams->count;) {
|
||||
getdns_list **upstreams_r)
|
||||
{
|
||||
size_t i;
|
||||
getdns_list *upstreams;
|
||||
getdns_return_t r;
|
||||
|
||||
if (!context || !upstreams_r)
|
||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
|
||||
if (!(upstreams = getdns_list_create_with_context(context)))
|
||||
return GETDNS_RETURN_MEMORY_ERROR;
|
||||
|
||||
if (!context->upstreams || context->upstreams->count == 0) {
|
||||
*upstreams_r = upstreams;
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
r = GETDNS_RETURN_GOOD;
|
||||
i = 0;
|
||||
while (!r && i < context->upstreams->count) {
|
||||
size_t j;
|
||||
getdns_dict *d;
|
||||
upstream = &context->upstreams->upstreams[i];
|
||||
d = sockaddr_dict(context, (struct sockaddr *)&upstream->addr);
|
||||
getdns_upstream *upstream = &context->upstreams->upstreams[i];
|
||||
getdns_bindata bindata;
|
||||
const getdns_tsig_info *tsig_info;
|
||||
|
||||
if (!(d =
|
||||
sockaddr_dict(context, (struct sockaddr*)&upstream->addr))) {
|
||||
r = GETDNS_RETURN_MEMORY_ERROR;
|
||||
break;
|
||||
}
|
||||
if (upstream->tsig_alg) {
|
||||
tsig_info = _getdns_get_tsig_info(upstream->tsig_alg);
|
||||
|
||||
bindata.data = tsig_info->dname;
|
||||
bindata.size = tsig_info->dname_len;
|
||||
if ((r = getdns_dict_set_bindata(
|
||||
d, "tsig_algorithm", &bindata)))
|
||||
break;
|
||||
|
||||
if (upstream->tsig_dname_len) {
|
||||
bindata.data = upstream->tsig_dname;
|
||||
bindata.size = upstream->tsig_dname_len;
|
||||
if ((r = getdns_dict_set_bindata(
|
||||
d, "tsig_name", &bindata)))
|
||||
break;
|
||||
}
|
||||
if (upstream->tsig_size) {
|
||||
bindata.data = upstream->tsig_key;
|
||||
bindata.size = upstream->tsig_size;
|
||||
if ((r = getdns_dict_set_bindata(
|
||||
d, "tsig_secret", &bindata)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ( j = 1, i++
|
||||
; j < GETDNS_UPSTREAM_TRANSPORTS &&
|
||||
i < context->upstreams->count
|
||||
; j++, i++) {
|
||||
|
||||
upstream = &context->upstreams->upstreams[i];
|
||||
if (upstream->transport != GETDNS_TRANSPORT_TLS)
|
||||
continue;
|
||||
if (upstream_port(upstream) != getdns_port_array[j])
|
||||
continue;
|
||||
(void) getdns_dict_set_int(d, "tls_port",
|
||||
(uint32_t) upstream_port(upstream));
|
||||
|
||||
if (upstream->transport == GETDNS_TRANSPORT_UDP &&
|
||||
upstream_port(upstream) != getdns_port_array[j] &&
|
||||
(r = getdns_dict_set_int(d, "port",
|
||||
(uint32_t)upstream_port(upstream))))
|
||||
break;
|
||||
|
||||
if (upstream->transport == GETDNS_TRANSPORT_TLS &&
|
||||
upstream_port(upstream) != getdns_port_array[j] &&
|
||||
(r = getdns_dict_set_int(d, "tls_port",
|
||||
(uint32_t)upstream_port(upstream))))
|
||||
break;
|
||||
}
|
||||
r |= _getdns_list_append_dict(upstreams, d);
|
||||
if (!r)
|
||||
r = _getdns_list_append_dict(upstreams, d);
|
||||
getdns_dict_destroy(d);
|
||||
}
|
||||
if (r != GETDNS_RETURN_GOOD) {
|
||||
getdns_list_destroy(upstreams);
|
||||
return GETDNS_RETURN_MEMORY_ERROR;
|
||||
}
|
||||
*upstream_list = upstreams;
|
||||
}
|
||||
return GETDNS_RETURN_GOOD;
|
||||
if (r)
|
||||
getdns_list_destroy(upstreams);
|
||||
else
|
||||
*upstreams_r = upstreams;
|
||||
return r;
|
||||
}
|
||||
|
||||
getdns_return_t
|
||||
|
|
|
@ -79,6 +79,29 @@ typedef enum getdns_tls_hs_state {
|
|||
GETDNS_HS_FAILED
|
||||
} getdns_tls_hs_state_t;
|
||||
|
||||
typedef enum getdns_tsig_algo {
|
||||
GETDNS_NO_TSIG = 0, /* Do not use tsig */
|
||||
GETDNS_HMAC_MD5 = 1, /* 128 bits */
|
||||
GETDNS_GSS_TSIG = 2, /* Not supported */
|
||||
GETDNS_HMAC_SHA1 = 3, /* 160 bits */
|
||||
GETDNS_HMAC_SHA224 = 4,
|
||||
GETDNS_HMAC_SHA256 = 5,
|
||||
GETDNS_HMAC_SHA384 = 6,
|
||||
GETDNS_HMAC_SHA512 = 7
|
||||
} getdns_tsig_algo;
|
||||
|
||||
typedef struct getdns_tsig_info {
|
||||
getdns_tsig_algo alg;
|
||||
const char *name;
|
||||
size_t strlen_name;
|
||||
const uint8_t *dname;
|
||||
size_t dname_len;
|
||||
size_t min_size; /* in # octets */
|
||||
size_t max_size; /* Actual size in # octets */
|
||||
} getdns_tsig_info;
|
||||
|
||||
const getdns_tsig_info *_getdns_get_tsig_info(getdns_tsig_algo tsig_alg);
|
||||
|
||||
typedef struct getdns_upstream {
|
||||
/* backpointer to containing upstreams structure */
|
||||
struct getdns_upstreams *upstreams;
|
||||
|
@ -89,6 +112,7 @@ typedef struct getdns_upstream {
|
|||
/* How is this upstream doing? */
|
||||
size_t writes_done;
|
||||
size_t responses_received;
|
||||
uint64_t keepalive_timeout;
|
||||
int to_retry;
|
||||
int back_off;
|
||||
|
||||
|
@ -97,7 +121,6 @@ typedef struct getdns_upstream {
|
|||
getdns_transport_list_t transport;
|
||||
SSL* tls_obj;
|
||||
getdns_tls_hs_state_t tls_hs_state;
|
||||
getdns_dns_req * starttls_req;
|
||||
getdns_eventloop_event event;
|
||||
getdns_eventloop *loop;
|
||||
getdns_tcp_state tcp;
|
||||
|
@ -120,6 +143,13 @@ typedef struct getdns_upstream {
|
|||
unsigned has_server_cookie : 1;
|
||||
unsigned server_cookie_len : 5;
|
||||
|
||||
/* TSIG */
|
||||
uint8_t tsig_dname[256];
|
||||
size_t tsig_dname_len;
|
||||
size_t tsig_size;
|
||||
uint8_t tsig_key[256];
|
||||
getdns_tsig_algo tsig_alg;
|
||||
|
||||
} getdns_upstream;
|
||||
|
||||
typedef struct getdns_upstreams {
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
*
|
||||
* \file debug.h
|
||||
* /brief Macro's for debugging
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015, NLnet Labs, Verisign, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names of the copyright holders nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define DEBUG_ON(...) do { \
|
||||
struct timeval tv; \
|
||||
struct tm tm; \
|
||||
char buf[10]; \
|
||||
\
|
||||
gettimeofday(&tv, NULL); \
|
||||
gmtime_r(&tv.tv_sec, &tm); \
|
||||
strftime(buf, 10, "%T", &tm); \
|
||||
fprintf(stderr, "[%s.%.6d] ", buf, (int)tv.tv_usec); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_NL(...) do { \
|
||||
struct timeval tv; \
|
||||
struct tm tm; \
|
||||
char buf[10]; \
|
||||
\
|
||||
gettimeofday(&tv, NULL); \
|
||||
gmtime_r(&tv.tv_sec, &tm); \
|
||||
strftime(buf, 10, "%T", &tm); \
|
||||
fprintf(stderr, "[%s.%.6d] ", buf, (int)tv.tv_usec); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define DEBUG_OFF(...) do {} while (0)
|
||||
|
||||
#if defined(SCHED_DEBUG) && SCHED_DEBUG
|
||||
#include <time.h>
|
||||
#define DEBUG_SCHED(...) DEBUG_ON(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_SCHED(...) DEBUG_OFF(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if defined(STUB_DEBUG) && STUB_DEBUG
|
||||
#include <time.h>
|
||||
#define DEBUG_STUB(...) DEBUG_ON(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_STUB(...) DEBUG_OFF(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if defined(SEC_DEBUG) && SEC_DEBUG
|
||||
#include <time.h>
|
||||
#define DEBUG_SEC(...) DEBUG_ON(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_SEC(...) DEBUG_OFF(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* debug.h */
|
|
@ -665,12 +665,15 @@ getdns_indent(size_t indent)
|
|||
return spaces + 80 - (indent < 80 ? indent : 0);
|
||||
} /* getdns_indent */
|
||||
|
||||
static int
|
||||
int
|
||||
_getdns_bindata_is_dname(getdns_bindata *bindata)
|
||||
{
|
||||
size_t i = 0, n_labels = 0;
|
||||
|
||||
while (i < bindata->size && bindata->data[i]) {
|
||||
if (bindata->data[i] & 0xC0) /* Compression pointer! */
|
||||
return 0;
|
||||
|
||||
i += ((size_t)bindata->data[i]) + 1;
|
||||
n_labels++;
|
||||
}
|
||||
|
@ -1001,6 +1004,7 @@ getdns_pp_dict(gldns_buffer * buf, size_t indent,
|
|||
if (!json &&
|
||||
(strcmp(item->node.key, "answer_type") == 0 ||
|
||||
strcmp(item->node.key, "dnssec_status") == 0 ||
|
||||
strcmp(item->node.key, "tsig_status") == 0 ||
|
||||
strcmp(item->node.key, "status") == 0 ||
|
||||
strcmp(item->node.key, "append_name") == 0 ||
|
||||
strcmp(item->node.key, "follow_redirects") == 0 ||
|
||||
|
|
|
@ -71,6 +71,11 @@ getdns_return_t _getdns_dict_find(
|
|||
getdns_return_t _getdns_dict_find_and_add(
|
||||
getdns_dict *dict, const char *key, getdns_item **item);
|
||||
|
||||
/* Return 1 (true) if bindata can be interpreted as an
|
||||
* uncompressed dname.
|
||||
*/
|
||||
int _getdns_bindata_is_dname(getdns_bindata *bindata);
|
||||
|
||||
#endif
|
||||
|
||||
/* dict.h */
|
||||
|
|
|
@ -188,13 +188,14 @@
|
|||
* "dnssec_return_validation_chain Extension".
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "debug.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <openssl/sha.h>
|
||||
#include "getdns/getdns.h"
|
||||
#include "config.h"
|
||||
#include "context.h"
|
||||
#include "util-internal.h"
|
||||
#include "types-internal.h"
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "getdns/getdns_ext_libev.h"
|
||||
#include "types-internal.h"
|
||||
#include "config.h"
|
||||
#include "types-internal.h"
|
||||
#include "getdns/getdns_ext_libev.h"
|
||||
|
||||
#ifdef HAVE_LIBEV_EV_H
|
||||
#include <libev/ev.h>
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "types-internal.h"
|
||||
#include <sys/time.h>
|
||||
#include "getdns/getdns_ext_libevent.h"
|
||||
#include "types-internal.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_EVENT2_EVENT_H
|
||||
# include <event2/event.h>
|
||||
|
|
|
@ -32,9 +32,10 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "debug.h"
|
||||
#include "types-internal.h"
|
||||
#include "extension/libmini_event.h"
|
||||
#include "context.h"
|
||||
#include "util-internal.h"
|
||||
#if defined(SCHED_DEBUG) && SCHED_DEBUG
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
@ -211,7 +212,7 @@ _getdns_mini_event_init(getdns_context *context, _getdns_mini_event *ext)
|
|||
if (!ext->base)
|
||||
return GETDNS_RETURN_MEMORY_ERROR;
|
||||
|
||||
ext->mf = context->mf;
|
||||
ext->mf = *priv_getdns_context_mf(context);
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
|
@ -221,6 +222,6 @@ _getdns_mini_event_create(getdns_context *context, _getdns_mini_event **ext)
|
|||
if (!context) return GETDNS_RETURN_BAD_CONTEXT;
|
||||
if (!ext) return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
|
||||
*ext = GETDNS_MALLOC(context->mf, _getdns_mini_event);
|
||||
*ext = GETDNS_MALLOC(*priv_getdns_context_mf(context), _getdns_mini_event);
|
||||
return _getdns_mini_event_init(context, *ext);
|
||||
}
|
||||
|
|
|
@ -32,9 +32,10 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "debug.h"
|
||||
#include "types-internal.h"
|
||||
#include <uv.h>
|
||||
#include "getdns/getdns_ext_libuv.h"
|
||||
#include "util-internal.h"
|
||||
|
||||
#define UV_DEBUG 0
|
||||
|
||||
|
|
|
@ -185,7 +185,6 @@ typedef enum getdns_transport_list_t {
|
|||
GETDNS_TRANSPORT_UDP = 1200,
|
||||
GETDNS_TRANSPORT_TCP = 1201,
|
||||
GETDNS_TRANSPORT_TLS = 1202,
|
||||
GETDNS_TRANSPORT_STARTTLS = 1203
|
||||
} getdns_transport_list_t;
|
||||
|
||||
/**
|
||||
|
@ -195,7 +194,6 @@ typedef enum getdns_transport_list_t {
|
|||
#define GETDNS_TRANSPORT_UDP_TEXT "See getdns_context_set_dns_transport_list()"
|
||||
#define GETDNS_TRANSPORT_TCP_TEXT "See getdns_context_set_dns_transport_list()"
|
||||
#define GETDNS_TRANSPORT_TLS_TEXT "See getdns_context_set_dns_transport_list()"
|
||||
#define GETDNS_TRANSPORT_STARTTLS_TEXT "See getdns_context_set_dns_transport_list()"
|
||||
/** @}
|
||||
*/
|
||||
|
||||
|
|
|
@ -399,8 +399,6 @@ getdns_context_get_tls_authentication(getdns_context *context,
|
|||
#define GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()"
|
||||
#define GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN 545
|
||||
#define GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()"
|
||||
#define GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN 546
|
||||
#define GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()"
|
||||
|
||||
getdns_return_t
|
||||
getdns_rr_dict2wire(
|
||||
|
|
|
@ -87,6 +87,19 @@ gldns_write_uint32(void *dst, uint32_t data)
|
|||
}
|
||||
|
||||
|
||||
INLINE void
|
||||
gldns_write_uint48(void *dst, uint64_t data)
|
||||
{
|
||||
uint8_t *p = (uint8_t *) dst;
|
||||
p[0] = (uint8_t) ((data >> 40) & 0xff);
|
||||
p[1] = (uint8_t) ((data >> 32) & 0xff);
|
||||
p[2] = (uint8_t) ((data >> 24) & 0xff);
|
||||
p[3] = (uint8_t) ((data >> 16) & 0xff);
|
||||
p[4] = (uint8_t) ((data >> 8) & 0xff);
|
||||
p[5] = (uint8_t) (data & 0xff);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \file gbuffer.h
|
||||
*
|
||||
|
@ -534,6 +547,20 @@ gldns_buffer_write_u32_at(gldns_buffer *buffer, size_t at, uint32_t data)
|
|||
gldns_write_uint32(buffer->_data + at, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* writes the given 6 byte integer at the given position in the buffer
|
||||
* \param[in] buffer the buffer
|
||||
* \param[in] at the position in the buffer
|
||||
* \param[in] data the (lower) 48 bits to write
|
||||
*/
|
||||
INLINE void
|
||||
gldns_buffer_write_u48_at(gldns_buffer *buffer, size_t at, uint64_t data)
|
||||
{
|
||||
if (buffer->_fixed && at + 6 > buffer->_limit) return;
|
||||
assert(gldns_buffer_available_at(buffer, at, 6));
|
||||
gldns_write_uint48(buffer->_data + at, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* writes the given 4 byte integer at the current position in the buffer
|
||||
* \param[in] buffer the buffer
|
||||
|
@ -546,6 +573,18 @@ gldns_buffer_write_u32(gldns_buffer *buffer, uint32_t data)
|
|||
buffer->_position += sizeof(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* writes the given 6 byte integer at the current position in the buffer
|
||||
* \param[in] buffer the buffer
|
||||
* \param[in] data the 48 bits to write
|
||||
*/
|
||||
INLINE void
|
||||
gldns_buffer_write_u48(gldns_buffer *buffer, uint64_t data)
|
||||
{
|
||||
gldns_buffer_write_u48_at(buffer, buffer->_position, data);
|
||||
buffer->_position += 6;
|
||||
}
|
||||
|
||||
/**
|
||||
* copies count bytes of data at the given position to the given data-array
|
||||
* \param[in] buffer the buffer
|
||||
|
|
|
@ -417,7 +417,8 @@ enum gldns_enum_edns_option
|
|||
GLDNS_EDNS_DAU = 5, /* RFC6975 */
|
||||
GLDNS_EDNS_DHU = 6, /* RFC6975 */
|
||||
GLDNS_EDNS_N3U = 7, /* RFC6975 */
|
||||
GLDNS_EDNS_CLIENT_SUBNET = 8 /* draft-vandergaast-edns-client-subnet */
|
||||
GLDNS_EDNS_CLIENT_SUBNET = 8, /* draft-vandergaast-edns-client-subnet */
|
||||
GLDNS_EDNS_KEEPALIVE = 11 /* draft-ietf-dnsop-edns-tcp-keepalive*/
|
||||
};
|
||||
typedef enum gldns_enum_edns_option gldns_edns_option;
|
||||
|
||||
|
|
|
@ -165,6 +165,7 @@ static gldns_lookup_table gldns_edns_options_data[] = {
|
|||
{ 6, "DHU" },
|
||||
{ 7, "N3U" },
|
||||
{ 8, "edns-client-subnet" },
|
||||
{ 11, "edns-tcp-keepalive"},
|
||||
{ 0, NULL}
|
||||
};
|
||||
gldns_lookup_table* gldns_edns_options = gldns_edns_options_data;
|
||||
|
@ -1833,6 +1834,25 @@ int gldns_wire2str_edns_subnet_print(char** s, size_t* sl, uint8_t* data,
|
|||
return w;
|
||||
}
|
||||
|
||||
int gldns_wire2str_edns_keepalive_print(char** s, size_t* sl, uint8_t* data,
|
||||
size_t len)
|
||||
{
|
||||
int w = 0;
|
||||
uint16_t timeout;
|
||||
if(!(len == 0 || len == 2)) {
|
||||
w += gldns_str_print(s, sl, "malformed keepalive ");
|
||||
w += print_hex_buf(s, sl, data, len);
|
||||
return w;
|
||||
}
|
||||
if(len == 0 ) {
|
||||
w += gldns_str_print(s, sl, "no timeout value (only valid for client option) ");
|
||||
} else {
|
||||
timeout = gldns_read_uint16(data);
|
||||
w += gldns_str_print(s, sl, "timeout value in units of 100ms %u", (int)timeout);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
int gldns_wire2str_edns_option_print(char** s, size_t* sl,
|
||||
uint16_t option_code, uint8_t* optdata, size_t optlen)
|
||||
{
|
||||
|
@ -1861,6 +1881,9 @@ int gldns_wire2str_edns_option_print(char** s, size_t* sl,
|
|||
case GLDNS_EDNS_CLIENT_SUBNET:
|
||||
w += gldns_wire2str_edns_subnet_print(s, sl, optdata, optlen);
|
||||
break;
|
||||
case GLDNS_EDNS_KEEPALIVE:
|
||||
w += gldns_wire2str_edns_keepalive_print(s, sl, optdata, optlen);
|
||||
break;
|
||||
default:
|
||||
/* unknown option code */
|
||||
w += print_hex_buf(s, sl, optdata, optlen);
|
||||
|
|
|
@ -10,9 +10,9 @@ cat > const-info.c << END_OF_HEAD
|
|||
#include "const-info.h"
|
||||
|
||||
static struct const_info consts_info[] = {
|
||||
{ -1, NULL, "/* <unknown getdns value> */" },
|
||||
{ -1, NULL, "/* <unknown getdns value> */" },
|
||||
END_OF_HEAD
|
||||
gawk '/^[ ]+GETDNS_[A-Z_]+[ ]+=[ ]+[0-9]+/{ consts[$3] = $1; }/^#define GETDNS_[A-Z_]+[ ]+[0-9]+/ && !/^#define GETDNS_RRTYPE/ && !/^#define GETDNS_RRCLASS/ && !/^#define GETDNS_OPCODE/ && !/^#define GETDNS_RCODE/ && !/_TEXT/{ consts[$3] = $2; }END{ n = asorti(consts, const_vals, "@ind_num_asc"); for ( i = 1; i <= n; i++) { val = const_vals[i]; name = consts[val]; print "\t{ "val", \""name"\", "name"_TEXT },"}}' getdns/getdns.h.in getdns/getdns_extra.h.in | sed 's/,,/,/g' >> const-info.c
|
||||
gawk '/^[ ]+GETDNS_[A-Z_]+[ ]+=[ ]+[0-9]+/{ key = sprintf("%4d", $3); consts[key] = $1; }/^#define GETDNS_[A-Z_]+[ ]+[0-9]+/ && !/^#define GETDNS_RRTYPE/ && !/^#define GETDNS_RRCLASS/ && !/^#define GETDNS_OPCODE/ && !/^#define GETDNS_RCODE/ && !/_TEXT/{ key = sprintf("%4d", $3); consts[key] = $2; }END{ n = asorti(consts, const_vals); for ( i = 1; i <= n; i++) { val = const_vals[i]; name = consts[val]; print "\t{ "val", \""name"\", "name"_TEXT },"}}' getdns/getdns.h.in getdns/getdns_extra.h.in | sed 's/,,/,/g' >> const-info.c
|
||||
cat >> const-info.c << END_OF_TAIL
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ write_symbols() {
|
|||
| sed -e 's/(.*$//g' -e 's/^.*getdns_/getdns_/g' | sort | uniq > $OUTPUT
|
||||
}
|
||||
|
||||
write_symbols libgetdns.symbols getdns/getdns.h.in getdns/getdns_extra.h
|
||||
write_symbols libgetdns.symbols getdns/getdns.h.in getdns/getdns_extra.h.in
|
||||
echo plain_mem_funcs_user_arg >> libgetdns.symbols
|
||||
echo priv_getdns_context_mf >> libgetdns.symbols
|
||||
write_symbols extension/libevent.symbols getdns/getdns_ext_libevent.h
|
||||
|
|
|
@ -41,6 +41,26 @@
|
|||
#include "gldns/gbuffer.h"
|
||||
#include "gldns/pkthdr.h"
|
||||
#include "dict.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* MAXIMUM_TSIG_SPACE = TSIG name (dname) : 256
|
||||
* TSIG type (uint16_t) : 2
|
||||
* TSIG class (uint16_t) : 2
|
||||
* TSIG TTL (uint32_t) : 4
|
||||
* RdLen (uint16_t) : 2
|
||||
* Algorithm name (dname) : 256
|
||||
* Time Signed (uint48_t) : 6
|
||||
* Fudge (uint16_t) : 2
|
||||
* Mac Size (uint16_t) : 2
|
||||
* Mac (variable) : EVP_MAX_MD_SIZE
|
||||
* Original Id (uint16_t) : 2
|
||||
* Error (uint16_t) : 2
|
||||
* Other Len (uint16_t) : 2
|
||||
* Other Data (nothing) : 0
|
||||
* ---- +
|
||||
* 538 + EVP_MAX_MD_SIZE
|
||||
*/
|
||||
#define MAXIMUM_TSIG_SPACE (538 + EVP_MAX_MD_SIZE)
|
||||
|
||||
getdns_dict dnssec_ok_checking_disabled_spc = {
|
||||
{ RBTREE_NULL, 0, (int (*)(const void *, const void *)) strcmp },
|
||||
|
@ -114,6 +134,7 @@ network_req_init(getdns_network_req *net_req, getdns_dns_req *owner,
|
|||
net_req->owner = owner;
|
||||
|
||||
net_req->dnssec_status = GETDNS_DNSSEC_INDETERMINATE;
|
||||
net_req->tsig_status = GETDNS_DNSSEC_INDETERMINATE;
|
||||
|
||||
net_req->upstream = NULL;
|
||||
net_req->fd = -1;
|
||||
|
@ -128,11 +149,12 @@ network_req_init(getdns_network_req *net_req, getdns_dns_req *owner,
|
|||
net_req->edns_maximum_udp_payload_size = edns_maximum_udp_payload_size;
|
||||
net_req->max_udp_payload_size = edns_maximum_udp_payload_size != -1
|
||||
? edns_maximum_udp_payload_size : 1432;
|
||||
net_req->keepalive_sent = 0;
|
||||
net_req->write_queue_tail = NULL;
|
||||
net_req->response_len = 0;
|
||||
net_req->base_query_option_sz = opt_options_size;
|
||||
|
||||
/* Some fields to record info for return_call_debugging */
|
||||
/* Some fields to record info for return_call_reporting */
|
||||
net_req->debug_start_time = 0;
|
||||
net_req->debug_end_time = 0;
|
||||
net_req->debug_tls_auth_status = 0;
|
||||
|
@ -249,7 +271,7 @@ _getdns_network_req_add_upstream_option(getdns_network_req * req, uint16_t code,
|
|||
|
||||
/* no overflow allowed for OPT size either (maybe this is overkill
|
||||
given the above check?) */
|
||||
oldlen = gldns_read_uint16(req->opt + 9);
|
||||
oldlen = gldns_read_uint16(req->opt + 9);
|
||||
newlen = oldlen + 4 + sz;
|
||||
if (newlen > UINT16_MAX)
|
||||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
|
@ -277,6 +299,267 @@ _getdns_network_req_add_upstream_option(getdns_network_req * req, uint16_t code,
|
|||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
size_t
|
||||
_getdns_network_req_add_tsig(getdns_network_req *req)
|
||||
{
|
||||
getdns_upstream *upstream = req->upstream;
|
||||
gldns_buffer gbuf;
|
||||
uint16_t arcount;
|
||||
const getdns_tsig_info *tsig_info;
|
||||
uint8_t md_buf[EVP_MAX_MD_SIZE];
|
||||
unsigned int md_len = EVP_MAX_MD_SIZE;
|
||||
const EVP_MD *digester;
|
||||
|
||||
/* Should only be called when in stub mode */
|
||||
assert(req->query);
|
||||
|
||||
if (upstream->tsig_alg == GETDNS_NO_TSIG || !upstream->tsig_dname_len)
|
||||
return req->response - req->query;
|
||||
|
||||
arcount = gldns_read_uint16(req->query + 10);
|
||||
|
||||
#if defined(STUB_DEBUG) && STUB_DEBUG
|
||||
/* TSIG should not have been written yet. */
|
||||
if (req->opt) {
|
||||
assert(arcount == 1);
|
||||
assert(req->opt + 11 + gldns_read_uint16(req->opt + 9)
|
||||
== req->response);
|
||||
} else
|
||||
assert(arcount == 0);
|
||||
#endif
|
||||
tsig_info = _getdns_get_tsig_info(upstream->tsig_alg);
|
||||
|
||||
gldns_buffer_init_frm_data(&gbuf, req->response, MAXIMUM_TSIG_SPACE);
|
||||
gldns_buffer_write(&gbuf,
|
||||
upstream->tsig_dname, upstream->tsig_dname_len); /* Name */
|
||||
gldns_buffer_write_u16(&gbuf, GETDNS_RRCLASS_ANY); /* Class */
|
||||
gldns_buffer_write_u32(&gbuf, 0); /* TTL */
|
||||
gldns_buffer_write(&gbuf,
|
||||
tsig_info->dname, tsig_info->dname_len); /* Algorithm Name */
|
||||
gldns_buffer_write_u48(&gbuf, time(NULL)); /* Time Signed */
|
||||
gldns_buffer_write_u16(&gbuf, 300); /* Fudge */
|
||||
gldns_buffer_write_u16(&gbuf, 0); /* Error */
|
||||
gldns_buffer_write_u16(&gbuf, 0); /* Other len */
|
||||
|
||||
switch (upstream->tsig_alg) {
|
||||
#ifdef HAVE_EVP_MD5
|
||||
case GETDNS_HMAC_MD5 : digester = EVP_md5() ; break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA1
|
||||
case GETDNS_HMAC_SHA1 : digester = EVP_sha1() ; break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA224
|
||||
case GETDNS_HMAC_SHA224: digester = EVP_sha224(); break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA256
|
||||
case GETDNS_HMAC_SHA256: digester = EVP_sha256(); break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA384
|
||||
case GETDNS_HMAC_SHA384: digester = EVP_sha384(); break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA512
|
||||
case GETDNS_HMAC_SHA512: digester = EVP_sha512(); break;
|
||||
#endif
|
||||
default : return req->response - req->query;
|
||||
}
|
||||
|
||||
(void) HMAC(digester, upstream->tsig_key, upstream->tsig_size,
|
||||
(void *)req->query, gldns_buffer_current(&gbuf) - req->query,
|
||||
md_buf, &md_len);
|
||||
|
||||
gldns_buffer_rewind(&gbuf);
|
||||
gldns_buffer_write(&gbuf,
|
||||
upstream->tsig_dname, upstream->tsig_dname_len); /* Name */
|
||||
gldns_buffer_write_u16(&gbuf, GETDNS_RRTYPE_TSIG); /* Type*/
|
||||
gldns_buffer_write_u16(&gbuf, GETDNS_RRCLASS_ANY); /* Class */
|
||||
gldns_buffer_write_u32(&gbuf, 0); /* TTL */
|
||||
gldns_buffer_write_u16(&gbuf,
|
||||
tsig_info->dname_len + 10 + md_len + 6); /* RdLen */
|
||||
gldns_buffer_write(&gbuf,
|
||||
tsig_info->dname, tsig_info->dname_len); /* Algorithm Name */
|
||||
gldns_buffer_write_u48(&gbuf, time(NULL)); /* Time Signed */
|
||||
gldns_buffer_write_u16(&gbuf, 300); /* Fudge */
|
||||
gldns_buffer_write_u16(&gbuf, md_len); /* MAC Size */
|
||||
gldns_buffer_write(&gbuf, md_buf, md_len); /* MAC*/
|
||||
gldns_buffer_write(&gbuf, req->query, 2); /* Original ID */
|
||||
gldns_buffer_write_u16(&gbuf, 0); /* Error */
|
||||
gldns_buffer_write_u16(&gbuf, 0); /* Other len */
|
||||
|
||||
if (gldns_buffer_position(&gbuf) > gldns_buffer_limit(&gbuf))
|
||||
return req->response - req->query;
|
||||
|
||||
DEBUG_STUB("Sending with TSIG, mac length: %d\n", (int)md_len);
|
||||
req->tsig_status = GETDNS_DNSSEC_INSECURE;
|
||||
gldns_write_uint16(req->query + 10, arcount + 1);
|
||||
req->response = gldns_buffer_current(&gbuf);
|
||||
return req->response - req->query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_getdns_network_validate_tsig(getdns_network_req *req)
|
||||
{
|
||||
_getdns_rr_iter rr_spc, *rr;
|
||||
_getdns_rdf_iter rdf_spc, *rdf;
|
||||
uint8_t *request_mac;
|
||||
uint16_t request_mac_len;
|
||||
uint8_t tsig_vars[MAXIMUM_TSIG_SPACE];
|
||||
gldns_buffer gbuf;
|
||||
uint8_t *dname;
|
||||
size_t dname_len;
|
||||
uint8_t *response_mac;
|
||||
uint16_t response_mac_len;
|
||||
uint8_t other_len;
|
||||
uint8_t result_mac[EVP_MAX_MD_SIZE];
|
||||
unsigned int result_mac_len = EVP_MAX_MD_SIZE;
|
||||
uint16_t original_id;
|
||||
const EVP_MD *digester;
|
||||
HMAC_CTX ctx;
|
||||
|
||||
DEBUG_STUB("Validate TSIG\n");
|
||||
for ( rr = _getdns_rr_iter_init(&rr_spc, req->query,
|
||||
(req->response - req->query))
|
||||
; rr
|
||||
; rr = _getdns_rr_iter_next(rr)) {
|
||||
|
||||
if (_getdns_rr_iter_section(rr) == GLDNS_SECTION_ADDITIONAL &&
|
||||
gldns_read_uint16(rr->rr_type) == GETDNS_RRTYPE_TSIG)
|
||||
break;
|
||||
}
|
||||
if (!rr || !(rdf = _getdns_rdf_iter_init_at(&rdf_spc, rr, 3)))
|
||||
return; /* No good TSIG sent, so nothing expected on reply */
|
||||
|
||||
request_mac_len = gldns_read_uint16(rdf->pos);
|
||||
if (request_mac_len != rdf->nxt - rdf->pos - 2)
|
||||
return;
|
||||
DEBUG_STUB("Request MAC found length: %d\n", (int)(request_mac_len));
|
||||
request_mac = rdf->pos + 2;
|
||||
|
||||
/* Now we expect a TSIG on the response! */
|
||||
req->tsig_status = GETDNS_DNSSEC_BOGUS;
|
||||
|
||||
for ( rr = _getdns_rr_iter_init(
|
||||
&rr_spc, req->response, req->response_len)
|
||||
; rr
|
||||
; rr = _getdns_rr_iter_next(rr)) {
|
||||
|
||||
if (_getdns_rr_iter_section(rr) == GLDNS_SECTION_ADDITIONAL &&
|
||||
gldns_read_uint16(rr->rr_type) == GETDNS_RRTYPE_TSIG)
|
||||
break;
|
||||
}
|
||||
if (!rr || !(rdf = _getdns_rdf_iter_init(&rdf_spc, rr)))
|
||||
return;
|
||||
gldns_buffer_init_frm_data(&gbuf, tsig_vars, MAXIMUM_TSIG_SPACE);
|
||||
|
||||
dname_len = gldns_buffer_remaining(&gbuf);
|
||||
if (!(dname = _getdns_owner_if_or_as_decompressed(
|
||||
rr, gldns_buffer_current(&gbuf), &dname_len)))
|
||||
return;
|
||||
if (dname == gldns_buffer_current(&gbuf))
|
||||
gldns_buffer_skip(&gbuf, dname_len);
|
||||
else
|
||||
gldns_buffer_write(&gbuf, dname, dname_len);
|
||||
|
||||
gldns_buffer_write(&gbuf, rr->rr_type + 2, 2); /* Class */
|
||||
gldns_buffer_write(&gbuf, rr->rr_type + 4, 4); /* TTL */
|
||||
|
||||
dname_len = gldns_buffer_remaining(&gbuf);
|
||||
if (!(dname = _getdns_rdf_if_or_as_decompressed(
|
||||
rdf, gldns_buffer_current(&gbuf), &dname_len)))
|
||||
return;
|
||||
if (dname == gldns_buffer_current(&gbuf))
|
||||
gldns_buffer_skip(&gbuf, dname_len);
|
||||
else
|
||||
gldns_buffer_write(&gbuf, dname, dname_len);
|
||||
|
||||
if (!(rdf = _getdns_rdf_iter_next(rdf)) ||
|
||||
rdf->nxt - rdf->pos != 6)
|
||||
return;
|
||||
gldns_buffer_write(&gbuf, rdf->pos, 6); /* Time Signed */
|
||||
|
||||
if (!(rdf = _getdns_rdf_iter_next(rdf)) ||
|
||||
rdf->nxt - rdf->pos != 2)
|
||||
return;
|
||||
gldns_buffer_write(&gbuf, rdf->pos, 2); /* Fudge */
|
||||
|
||||
if (!(rdf = _getdns_rdf_iter_next(rdf))) /* mac */
|
||||
return;
|
||||
response_mac_len = gldns_read_uint16(rdf->pos);
|
||||
if (response_mac_len != rdf->nxt - rdf->pos - 2)
|
||||
return;
|
||||
DEBUG_STUB("Response MAC found length: %d\n", (int)(response_mac_len));
|
||||
response_mac = rdf->pos + 2;
|
||||
|
||||
if (!(rdf = _getdns_rdf_iter_next(rdf)) ||
|
||||
rdf->nxt -rdf->pos != 2) /* Original ID */
|
||||
return;
|
||||
original_id = gldns_read_uint16(rdf->pos);
|
||||
|
||||
if (!(rdf = _getdns_rdf_iter_next(rdf)) ||
|
||||
rdf->nxt - rdf->pos != 2)
|
||||
return;
|
||||
gldns_buffer_write(&gbuf, rdf->pos, 2); /* Error */
|
||||
|
||||
if (!(rdf = _getdns_rdf_iter_next(rdf))) /* Other */
|
||||
return;
|
||||
|
||||
gldns_buffer_write_u16(&gbuf, 0); /* Other len */
|
||||
other_len = gldns_read_uint16(rdf->pos);
|
||||
if (other_len != rdf->nxt - rdf->pos - 2)
|
||||
return;
|
||||
if (other_len)
|
||||
gldns_buffer_write(&gbuf, rdf->pos, other_len);
|
||||
|
||||
/* TSIG found */
|
||||
DEBUG_STUB("TSIG found, original ID: %d\n", (int)original_id);
|
||||
|
||||
gldns_write_uint16(req->response + 10,
|
||||
gldns_read_uint16(req->response + 10) - 1);
|
||||
gldns_write_uint16(req->response, original_id);
|
||||
|
||||
switch (req->upstream->tsig_alg) {
|
||||
#ifdef HAVE_EVP_MD5
|
||||
case GETDNS_HMAC_MD5 : digester = EVP_md5() ; break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA1
|
||||
case GETDNS_HMAC_SHA1 : digester = EVP_sha1() ; break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA224
|
||||
case GETDNS_HMAC_SHA224: digester = EVP_sha224(); break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA256
|
||||
case GETDNS_HMAC_SHA256: digester = EVP_sha256(); break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA384
|
||||
case GETDNS_HMAC_SHA384: digester = EVP_sha384(); break;
|
||||
#endif
|
||||
#ifdef HAVE_EVP_SHA512
|
||||
case GETDNS_HMAC_SHA512: digester = EVP_sha512(); break;
|
||||
#endif
|
||||
default : return;
|
||||
}
|
||||
|
||||
HMAC_CTX_init(&ctx);
|
||||
(void) HMAC_Init_ex(&ctx, req->upstream->tsig_key,
|
||||
req->upstream->tsig_size, digester, NULL);
|
||||
(void) HMAC_Update(&ctx, request_mac - 2, request_mac_len + 2);
|
||||
(void) HMAC_Update(&ctx, req->response, rr->pos - req->response);
|
||||
(void) HMAC_Update(&ctx, tsig_vars, gldns_buffer_position(&gbuf));
|
||||
HMAC_Final(&ctx, result_mac, &result_mac_len);
|
||||
|
||||
DEBUG_STUB("Result MAC length: %d\n", (int)(result_mac_len));
|
||||
if (result_mac_len == response_mac_len &&
|
||||
memcmp(result_mac, response_mac, result_mac_len) == 0)
|
||||
req->tsig_status = GETDNS_DNSSEC_SECURE;
|
||||
|
||||
HMAC_CTX_cleanup(&ctx);
|
||||
|
||||
gldns_write_uint16(req->response, gldns_read_uint16(req->query));
|
||||
gldns_write_uint16(req->response + 10,
|
||||
gldns_read_uint16(req->response + 10) + 1);
|
||||
}
|
||||
|
||||
void
|
||||
_getdns_dns_req_free(getdns_dns_req * req)
|
||||
{
|
||||
|
@ -439,7 +722,7 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
|
|||
+ strlen(name) + 1 + 4 /* dname always smaller then strlen(name) + 1 */
|
||||
+ 12 + opt_options_size /* space needed for OPT (if needed) */
|
||||
+ MAXIMUM_UPSTREAM_OPTION_SPACE
|
||||
/* TODO: TSIG */
|
||||
+ MAXIMUM_TSIG_SPACE
|
||||
+ 7) / 8 * 8;
|
||||
}
|
||||
max_response_sz = (( edns_maximum_udp_payload_size != -1
|
||||
|
@ -488,8 +771,8 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
|
|||
#endif
|
||||
result->edns_client_subnet_private = context->edns_client_subnet_private;
|
||||
result->tls_query_padding_blocksize = context->tls_query_padding_blocksize;
|
||||
result->return_call_debugging
|
||||
= is_extension_set(extensions, "return_call_debugging");
|
||||
result->return_call_reporting
|
||||
= is_extension_set(extensions, "return_call_reporting");
|
||||
|
||||
/* will be set by caller */
|
||||
result->user_pointer = NULL;
|
||||
|
|
391
src/stub.c
391
src/stub.c
|
@ -31,16 +31,18 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "debug.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include "config.h"
|
||||
#include <fcntl.h>
|
||||
#include "stub.h"
|
||||
#include "gldns/gbuffer.h"
|
||||
#include "gldns/pkthdr.h"
|
||||
#include "gldns/rrdef.h"
|
||||
#include "gldns/str2wire.h"
|
||||
#include "gldns/wire2str.h"
|
||||
#include "rr-iter.h"
|
||||
#include "context.h"
|
||||
#include "util-internal.h"
|
||||
|
@ -53,6 +55,8 @@
|
|||
|
||||
/* Don't currently have access to the context whilst doing handshake */
|
||||
#define TIMEOUT_TLS 2500
|
||||
/* Arbritray number of message for EDNS keepalive resend*/
|
||||
#define EDNS_KEEPALIVE_RESEND 5
|
||||
|
||||
static time_t secret_rollover_time = 0;
|
||||
static uint32_t secret = 0;
|
||||
|
@ -74,7 +78,6 @@ static void netreq_upstream_read_cb(void *userarg);
|
|||
static void netreq_upstream_write_cb(void *userarg);
|
||||
static int fallback_on_write(getdns_network_req *netreq);
|
||||
|
||||
static void stub_tcp_write_cb(void *userarg);
|
||||
static void stub_timeout_cb(void *userarg);
|
||||
/*****************************/
|
||||
/* General utility functions */
|
||||
|
@ -144,6 +147,15 @@ attach_edns_client_subnet_private(getdns_network_req *req)
|
|||
4, NULL);
|
||||
}
|
||||
|
||||
static getdns_return_t
|
||||
attach_edns_keepalive(getdns_network_req *req)
|
||||
{
|
||||
/* Client always sends length 0, omits the timeout */
|
||||
return _getdns_network_req_add_upstream_option(req,
|
||||
GLDNS_EDNS_KEEPALIVE,
|
||||
0, NULL);
|
||||
}
|
||||
|
||||
static getdns_return_t
|
||||
attach_edns_cookie(getdns_network_req *req)
|
||||
{
|
||||
|
@ -182,9 +194,10 @@ attach_edns_cookie(getdns_network_req *req)
|
|||
|
||||
}
|
||||
|
||||
/* Will find a matching OPT RR, but leaves the caller to validate it*/
|
||||
static int
|
||||
match_and_process_server_cookie(
|
||||
getdns_upstream *upstream, uint8_t *response, size_t response_len)
|
||||
match_edns_opt_rr(uint16_t code, uint8_t *response, size_t response_len,
|
||||
uint8_t **position, uint16_t *option_len)
|
||||
{
|
||||
_getdns_rr_iter rr_iter_storage, *rr_iter;
|
||||
const uint8_t *pos;
|
||||
|
@ -210,7 +223,17 @@ match_and_process_server_cookie(
|
|||
|
||||
pos = rr_iter->rr_type + 8;
|
||||
|
||||
/* OPT found, now search for the cookie option */
|
||||
#if defined(STUB_DEBUG) && STUB_DEBUG
|
||||
char str_spc[8192], *str = str_spc;
|
||||
size_t str_len = sizeof(str_spc);
|
||||
uint8_t *data = rr_iter->pos;
|
||||
size_t data_len = rr_iter->nxt - rr_iter->pos;
|
||||
(void) gldns_wire2str_rr_scan(
|
||||
&data, &data_len, &str, &str_len, rr_iter->pkt, rr_iter->pkt_end - rr_iter->pkt);
|
||||
DEBUG_STUB("OPT RR: %s", str_spc);
|
||||
#endif
|
||||
|
||||
/* OPT found, now search for the specified option */
|
||||
if (pos + 2 > rr_iter->nxt)
|
||||
return 1; /* FORMERR */
|
||||
|
||||
|
@ -223,23 +246,39 @@ match_and_process_server_cookie(
|
|||
opt_len = gldns_read_uint16(pos); pos += 2;
|
||||
if (pos + opt_len > rr_iter->nxt)
|
||||
return 1; /* FORMERR */
|
||||
if (opt_code == EDNS_COOKIE_OPCODE)
|
||||
if (opt_code == code)
|
||||
break;
|
||||
pos += opt_len; /* Skip unknown options */
|
||||
}
|
||||
if (pos >= rr_iter->nxt || opt_code != EDNS_COOKIE_OPCODE)
|
||||
if (pos >= rr_iter->nxt || opt_code != code)
|
||||
return 0; /* Everything OK, just no cookie found. */
|
||||
*position = pos;
|
||||
*option_len = opt_len;
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (opt_len < 16 || opt_len > 40)
|
||||
/* TODO: Test combinations of EDNS0 options*/
|
||||
static int
|
||||
match_and_process_server_cookie(
|
||||
getdns_upstream *upstream, uint8_t *response, size_t response_len)
|
||||
{
|
||||
uint8_t *position = NULL;
|
||||
uint16_t option_len = 0;
|
||||
int found = match_edns_opt_rr(EDNS_COOKIE_OPCODE, response,
|
||||
response_len, &position, &option_len);
|
||||
if (found != 2)
|
||||
return found;
|
||||
|
||||
if (option_len < 16 || option_len > 40)
|
||||
return 1; /* FORMERR */
|
||||
|
||||
if (!upstream->has_client_cookie)
|
||||
return 1; /* Cookie reply, but we didn't sent one */
|
||||
|
||||
if (memcmp(upstream->client_cookie, pos, 8) != 0) {
|
||||
if (memcmp(upstream->client_cookie, position, 8) != 0) {
|
||||
if (!upstream->has_prev_client_cookie)
|
||||
return 1; /* Cookie didn't match */
|
||||
if (memcmp(upstream->prev_client_cookie, pos, 8) != 0)
|
||||
if (memcmp(upstream->prev_client_cookie, position, 8) != 0)
|
||||
return 1; /* Previous cookie didn't match either */
|
||||
|
||||
upstream->has_server_cookie = 0;
|
||||
|
@ -247,85 +286,41 @@ match_and_process_server_cookie(
|
|||
* is for our previous client cookie
|
||||
*/
|
||||
}
|
||||
pos += 8;
|
||||
opt_len -= 8;
|
||||
position += 8;
|
||||
option_len -= 8;
|
||||
upstream->has_server_cookie = 1;
|
||||
upstream->server_cookie_len = opt_len;
|
||||
(void) memcpy(upstream->server_cookie, pos, opt_len);
|
||||
upstream->server_cookie_len = option_len;
|
||||
(void) memcpy(upstream->server_cookie, position, option_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
create_starttls_request(getdns_dns_req *dnsreq, getdns_upstream *upstream,
|
||||
getdns_eventloop *loop)
|
||||
process_keepalive(
|
||||
getdns_upstream *upstream, getdns_network_req *netreq,
|
||||
uint8_t *response, size_t response_len)
|
||||
{
|
||||
getdns_return_t r = GETDNS_RETURN_GOOD;
|
||||
getdns_dict* extensions = getdns_dict_create_with_context(dnsreq->context);
|
||||
if (!extensions) {
|
||||
return 0;
|
||||
uint8_t *position = NULL;
|
||||
uint16_t option_len = 0;
|
||||
int found = match_edns_opt_rr(GLDNS_EDNS_KEEPALIVE, response,
|
||||
response_len, &position, &option_len);
|
||||
if (found != 2) {
|
||||
if (netreq->keepalive_sent == 1)
|
||||
/* If no keepalive sent back, then we must use 0 idle timeout
|
||||
as server does not support it.*/
|
||||
upstream->keepalive_timeout = 0;
|
||||
return found;
|
||||
}
|
||||
r = getdns_dict_set_int(extensions, "specify_class", GLDNS_RR_CLASS_CH);
|
||||
if (r != GETDNS_RETURN_GOOD) {
|
||||
getdns_dict_destroy(extensions);
|
||||
return 0;
|
||||
}
|
||||
upstream->starttls_req = _getdns_dns_req_new(dnsreq->context, loop,
|
||||
"STARTTLS", GETDNS_RRTYPE_TXT, extensions);
|
||||
/*TODO[TLS]: TO BIT*/
|
||||
if (upstream->starttls_req == NULL)
|
||||
return 0;
|
||||
getdns_dict_destroy(extensions);
|
||||
|
||||
upstream->starttls_req->netreqs[0]->upstream = upstream;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
is_starttls_response(getdns_network_req *netreq)
|
||||
{
|
||||
_getdns_rr_iter rr_iter_storage, *rr_iter;
|
||||
_getdns_rdf_iter rdf_iter_storage, *rdf_iter;
|
||||
uint16_t rr_type;
|
||||
gldns_pkt_section section;
|
||||
uint8_t starttls_name_space[256], owner_name_space[256];
|
||||
const uint8_t *owner_name, *starttls_name;
|
||||
size_t starttls_name_len = sizeof(starttls_name_space);
|
||||
size_t owner_name_len = sizeof(owner_name_space);;
|
||||
|
||||
/* Servers that are not STARTTLS aware will refuse the CH query*/
|
||||
if (GLDNS_RCODE_NOERROR != GLDNS_RCODE_WIRE(netreq->response))
|
||||
return 0;
|
||||
|
||||
if (GLDNS_ANCOUNT(netreq->response) != 1)
|
||||
return 0;
|
||||
|
||||
for ( rr_iter = _getdns_rr_iter_init(&rr_iter_storage
|
||||
, netreq->response
|
||||
, netreq->response_len)
|
||||
; rr_iter
|
||||
; rr_iter = _getdns_rr_iter_next(rr_iter)) {
|
||||
|
||||
section = _getdns_rr_iter_section(rr_iter);
|
||||
rr_type = gldns_read_uint16(rr_iter->rr_type);
|
||||
if (section != GLDNS_SECTION_ANSWER
|
||||
|| rr_type != GETDNS_RRTYPE_TXT)
|
||||
continue;
|
||||
|
||||
owner_name = _getdns_owner_if_or_as_decompressed(
|
||||
rr_iter, owner_name_space, &owner_name_len);
|
||||
if (!_getdns_dname_equal(netreq->owner->name, owner_name))
|
||||
continue;
|
||||
|
||||
if (!(rdf_iter = _getdns_rdf_iter_init(
|
||||
&rdf_iter_storage, rr_iter)))
|
||||
continue;
|
||||
|
||||
if ((starttls_name = _getdns_rdf_if_or_as_decompressed(
|
||||
rdf_iter, starttls_name_space, &starttls_name_len)) &&
|
||||
_getdns_dname_equal(starttls_name, owner_name))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
if (option_len != 2)
|
||||
return 1; /* FORMERR */
|
||||
/* 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;
|
||||
if (netreq->owner->context->idle_timeout < server_keepalive)
|
||||
upstream->keepalive_timeout = netreq->owner->context->idle_timeout;
|
||||
else {
|
||||
upstream->keepalive_timeout = server_keepalive;
|
||||
DEBUG_STUB("*** %s: SERVER KEEPALIVE USED : %d ms\n",
|
||||
__FUNCTION__, (int)server_keepalive);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -360,8 +355,7 @@ tcp_connect(getdns_upstream *upstream, getdns_transport_list_t transport)
|
|||
getdns_sock_nonblock(fd);
|
||||
#ifdef USE_TCP_FASTOPEN
|
||||
/* Leave the connect to the later call to sendto() if using TCP*/
|
||||
if (transport == GETDNS_TRANSPORT_TCP ||
|
||||
transport == GETDNS_TRANSPORT_STARTTLS)
|
||||
if (transport == GETDNS_TRANSPORT_TCP)
|
||||
return fd;
|
||||
#elif USE_OSX_TCP_FASTOPEN
|
||||
sa_endpoints_t endpoints;
|
||||
|
@ -465,7 +459,7 @@ stub_cleanup(getdns_network_req *netreq)
|
|||
netreq->write_queue_tail = NULL;
|
||||
break;
|
||||
}
|
||||
upstream_reschedule_events(upstream, netreq->owner->context->idle_timeout);
|
||||
upstream_reschedule_events(upstream, upstream->keepalive_timeout);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -521,33 +515,23 @@ _getdns_cancel_stub_request(getdns_network_req *netreq)
|
|||
if (netreq->fd >= 0) close(netreq->fd);
|
||||
}
|
||||
|
||||
static void
|
||||
/* May be needed in future for better UDP error handling?*/
|
||||
/*static void
|
||||
stub_erred(getdns_network_req *netreq)
|
||||
{
|
||||
DEBUG_STUB("*** %s\n", __FUNCTION__);
|
||||
stub_next_upstream(netreq);
|
||||
stub_cleanup(netreq);
|
||||
/* TODO[TLS]: When we get an error (which is probably a timeout) and are
|
||||
* using to keep connections open should we leave the connection up here? */
|
||||
if (netreq->fd >= 0) close(netreq->fd);
|
||||
netreq->state = NET_REQ_FINISHED;
|
||||
_getdns_check_dns_req_complete(netreq->owner);
|
||||
}
|
||||
}*/
|
||||
|
||||
static void
|
||||
stub_timeout_cb(void *userarg)
|
||||
{
|
||||
DEBUG_STUB("*** %s(%p)\n", __FUNCTION__, userarg);
|
||||
getdns_network_req *netreq = (getdns_network_req *)userarg;
|
||||
|
||||
/* For now, mark a STARTTLS timeout as a failured negotiation and allow
|
||||
* fallback but don't close the connection. */
|
||||
if (netreq->owner == netreq->upstream->starttls_req) {
|
||||
netreq->upstream->tls_hs_state = GETDNS_HS_FAILED;
|
||||
stub_next_upstream(netreq);
|
||||
stub_cleanup(netreq);
|
||||
return;
|
||||
}
|
||||
|
||||
stub_next_upstream(netreq);
|
||||
stub_cleanup(netreq);
|
||||
|
@ -735,8 +719,16 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
|
|||
if (netreq->owner->edns_client_subnet_private)
|
||||
if (attach_edns_client_subnet_private(netreq))
|
||||
return STUB_OUT_OF_OPTIONS;
|
||||
if (netreq->upstream->writes_done == 0 &&
|
||||
netreq->owner->context->idle_timeout != 0) {
|
||||
/* Add the keepalive option to the first query on this connection*/
|
||||
DEBUG_STUB("# %s: Requesting keepalive\n", __FUNCTION__);
|
||||
if (attach_edns_keepalive(netreq))
|
||||
return STUB_OUT_OF_OPTIONS;
|
||||
netreq->keepalive_sent = 1;
|
||||
}
|
||||
}
|
||||
pkt_len = netreq->response - netreq->query;
|
||||
pkt_len = _getdns_network_req_add_tsig(netreq);
|
||||
/* We have an initialized packet buffer.
|
||||
* Lets see how much of it we can write
|
||||
*/
|
||||
|
@ -812,27 +804,22 @@ static int
|
|||
tls_requested(getdns_network_req *netreq)
|
||||
{
|
||||
return (netreq->transports[netreq->transport_current] ==
|
||||
GETDNS_TRANSPORT_TLS ||
|
||||
netreq->transports[netreq->transport_current] ==
|
||||
GETDNS_TRANSPORT_STARTTLS) ?
|
||||
GETDNS_TRANSPORT_TLS) ?
|
||||
1 : 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tls_should_write(getdns_upstream *upstream)
|
||||
{
|
||||
/* Should messages be written on TLS upstream. Remember that for STARTTLS
|
||||
* the first message should got over TCP as the handshake isn't started yet.*/
|
||||
return ((upstream->transport == GETDNS_TRANSPORT_TLS ||
|
||||
upstream->transport == GETDNS_TRANSPORT_STARTTLS) &&
|
||||
/* Should messages be written on TLS upstream. */
|
||||
return ((upstream->transport == GETDNS_TRANSPORT_TLS) &&
|
||||
upstream->tls_hs_state != GETDNS_HS_NONE) ? 1 : 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tls_should_read(getdns_upstream *upstream)
|
||||
{
|
||||
return ((upstream->transport == GETDNS_TRANSPORT_TLS ||
|
||||
upstream->transport == GETDNS_TRANSPORT_STARTTLS) &&
|
||||
return ((upstream->transport == GETDNS_TRANSPORT_TLS) &&
|
||||
!(upstream->tls_hs_state == GETDNS_HS_FAILED ||
|
||||
upstream->tls_hs_state == GETDNS_HS_NONE)) ? 1 : 0;
|
||||
}
|
||||
|
@ -841,8 +828,7 @@ static int
|
|||
tls_failed(getdns_upstream *upstream)
|
||||
{
|
||||
/* No messages should be scheduled onto an upstream in this state */
|
||||
return ((upstream->transport == GETDNS_TRANSPORT_TLS ||
|
||||
upstream->transport == GETDNS_TRANSPORT_STARTTLS) &&
|
||||
return ((upstream->transport == GETDNS_TRANSPORT_TLS) &&
|
||||
upstream->tls_hs_state == GETDNS_HS_FAILED) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
@ -1188,6 +1174,7 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp,
|
|||
&netreq->upstream->netreq_by_query_id, &netreq->node));
|
||||
|
||||
GLDNS_ID_SET(netreq->query, query_id);
|
||||
/* TODO: Review if more EDNS0 handling can be centralised.*/
|
||||
if (netreq->opt) {
|
||||
_getdns_network_req_clear_upstream_options(netreq);
|
||||
/* no limits on the max udp payload size with tcp */
|
||||
|
@ -1198,6 +1185,15 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp,
|
|||
if (netreq->owner->edns_client_subnet_private)
|
||||
if (attach_edns_client_subnet_private(netreq))
|
||||
return STUB_OUT_OF_OPTIONS;
|
||||
if (netreq->upstream->writes_done % EDNS_KEEPALIVE_RESEND == 0 &&
|
||||
netreq->owner->context->idle_timeout != 0) {
|
||||
/* Add the keepalive option to every nth query on this
|
||||
connection */
|
||||
DEBUG_STUB("# %s: Requesting keepalive\n", __FUNCTION__);
|
||||
if (attach_edns_keepalive(netreq))
|
||||
return STUB_OUT_OF_OPTIONS;
|
||||
netreq->keepalive_sent = 1;
|
||||
}
|
||||
if (netreq->owner->tls_query_padding_blocksize > 1) {
|
||||
pkt_len = netreq->response - netreq->query;
|
||||
pkt_len += 4; /* this accounts for the OPTION-CODE and OPTION-LENGTH of the padding */
|
||||
|
@ -1211,7 +1207,7 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp,
|
|||
}
|
||||
}
|
||||
|
||||
pkt_len = netreq->response - netreq->query;
|
||||
pkt_len = _getdns_network_req_add_tsig(netreq);
|
||||
/* We have an initialized packet buffer.
|
||||
* Lets see how much of it we can write */
|
||||
|
||||
|
@ -1280,17 +1276,19 @@ stub_udp_read_cb(void *userarg)
|
|||
return; /* Client cookie didn't match? */
|
||||
|
||||
close(netreq->fd);
|
||||
if (GLDNS_TC_WIRE(netreq->response)) {
|
||||
while (GLDNS_TC_WIRE(netreq->response)) {
|
||||
DEBUG_STUB("TC bit set\n");
|
||||
if (!(netreq->transport_current < netreq->transport_count))
|
||||
goto done;
|
||||
break;
|
||||
getdns_transport_list_t next_transport =
|
||||
netreq->transports[++netreq->transport_current];
|
||||
if (next_transport != GETDNS_TRANSPORT_TCP)
|
||||
goto done;
|
||||
if (next_transport != GETDNS_TRANSPORT_TCP &&
|
||||
next_transport != GETDNS_TRANSPORT_TLS)
|
||||
break;
|
||||
/* For now, special case where fallback should be on the same upstream*/
|
||||
if ((netreq->fd = upstream_connect(upstream, next_transport,
|
||||
dnsreq)) == -1)
|
||||
goto done;
|
||||
break;
|
||||
upstream_schedule_netreq(netreq->upstream, netreq);
|
||||
GETDNS_SCHEDULE_EVENT(
|
||||
dnsreq->loop, netreq->upstream->fd, dnsreq->context->timeout,
|
||||
|
@ -1302,7 +1300,6 @@ stub_udp_read_cb(void *userarg)
|
|||
}
|
||||
netreq->response_len = read;
|
||||
dnsreq->upstreams->current = 0;
|
||||
done:
|
||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
||||
netreq->state = NET_REQ_FINISHED;
|
||||
_getdns_check_dns_req_complete(dnsreq);
|
||||
|
@ -1336,7 +1333,7 @@ stub_udp_write_cb(void *userarg)
|
|||
if (attach_edns_client_subnet_private(netreq))
|
||||
return; /* too many upstream options */
|
||||
}
|
||||
pkt_len = netreq->response - netreq->query;
|
||||
pkt_len = _getdns_network_req_add_tsig(netreq);
|
||||
if ((ssize_t)pkt_len != sendto(netreq->fd, netreq->query, pkt_len, 0,
|
||||
(struct sockaddr *)&netreq->upstream->addr,
|
||||
netreq->upstream->addr_len)) {
|
||||
|
@ -1349,76 +1346,6 @@ stub_udp_write_cb(void *userarg)
|
|||
stub_udp_read_cb, NULL, stub_timeout_cb));
|
||||
}
|
||||
|
||||
/**************************/
|
||||
/* TCP callback functions*/
|
||||
/**************************/
|
||||
|
||||
static void
|
||||
stub_tcp_read_cb(void *userarg)
|
||||
{
|
||||
getdns_network_req *netreq = (getdns_network_req *)userarg;
|
||||
getdns_dns_req *dnsreq = netreq->owner;
|
||||
int q;
|
||||
|
||||
switch ((q = stub_tcp_read(netreq->fd, &netreq->tcp,
|
||||
&dnsreq->context->mf))) {
|
||||
|
||||
case STUB_TCP_AGAIN:
|
||||
return;
|
||||
|
||||
case STUB_TCP_ERROR:
|
||||
stub_erred(netreq);
|
||||
return;
|
||||
|
||||
default:
|
||||
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
|
||||
if (q != netreq->query_id)
|
||||
return;
|
||||
if (netreq->owner->edns_cookies &&
|
||||
match_and_process_server_cookie(
|
||||
netreq->upstream, netreq->tcp.read_buf,
|
||||
netreq->tcp.read_pos - netreq->tcp.read_buf))
|
||||
return; /* Client cookie didn't match? */
|
||||
netreq->state = NET_REQ_FINISHED;
|
||||
netreq->response = netreq->tcp.read_buf;
|
||||
netreq->response_len =
|
||||
netreq->tcp.read_pos - netreq->tcp.read_buf;
|
||||
netreq->tcp.read_buf = NULL;
|
||||
dnsreq->upstreams->current = 0;
|
||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
||||
stub_cleanup(netreq);
|
||||
close(netreq->fd);
|
||||
_getdns_check_dns_req_complete(dnsreq);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
stub_tcp_write_cb(void *userarg)
|
||||
{
|
||||
getdns_network_req *netreq = (getdns_network_req *)userarg;
|
||||
getdns_dns_req *dnsreq = netreq->owner;
|
||||
int q;
|
||||
netreq->debug_start_time = _getdns_get_time_as_uintt64();
|
||||
switch ((q = stub_tcp_write(netreq->fd, &netreq->tcp, netreq))) {
|
||||
case STUB_TCP_AGAIN:
|
||||
return;
|
||||
|
||||
case STUB_TCP_ERROR:
|
||||
stub_erred(netreq);
|
||||
return;
|
||||
|
||||
default:
|
||||
netreq->debug_udp = 0;
|
||||
netreq->query_id = (uint16_t) q;
|
||||
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
|
||||
GETDNS_SCHEDULE_EVENT(
|
||||
dnsreq->loop, netreq->fd, dnsreq->context->timeout,
|
||||
getdns_eventloop_event_init(&netreq->event, netreq,
|
||||
stub_tcp_read_cb, NULL, stub_timeout_cb));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************/
|
||||
/* Upstream callback functions*/
|
||||
/**************************/
|
||||
|
@ -1429,7 +1356,6 @@ upstream_read_cb(void *userarg)
|
|||
DEBUG_STUB("--- READ: %s\n", __FUNCTION__);
|
||||
getdns_upstream *upstream = (getdns_upstream *)userarg;
|
||||
getdns_network_req *netreq;
|
||||
getdns_dns_req *dnsreq;
|
||||
int q;
|
||||
uint16_t query_id;
|
||||
intptr_t query_id_intptr;
|
||||
|
@ -1472,26 +1398,19 @@ upstream_read_cb(void *userarg)
|
|||
/* TODO[TLS]: I don't think we should do this for TCP. We should stay
|
||||
* on a working connection until we hit a problem.*/
|
||||
upstream->upstreams->current = 0;
|
||||
|
||||
/* !THIS CODE NEEDS TESTING!*/
|
||||
if (netreq->owner->edns_cookies &&
|
||||
match_and_process_server_cookie(
|
||||
netreq->upstream, netreq->tcp.read_buf,
|
||||
netreq->tcp.read_pos - netreq->tcp.read_buf))
|
||||
return; /* Client cookie didn't match? */
|
||||
|
||||
if (netreq->owner == upstream->starttls_req) {
|
||||
dnsreq = netreq->owner;
|
||||
if (is_starttls_response(netreq)) {
|
||||
upstream->tls_obj = tls_create_object(dnsreq,
|
||||
upstream->fd,
|
||||
upstream);
|
||||
if (upstream->tls_obj == NULL)
|
||||
upstream->tls_hs_state = GETDNS_HS_FAILED;
|
||||
upstream->tls_hs_state = GETDNS_HS_WRITE;
|
||||
} else
|
||||
upstream->tls_hs_state = GETDNS_HS_FAILED;
|
||||
if ((netreq->owner->context->idle_timeout != 0) &&
|
||||
process_keepalive(netreq->upstream, netreq, netreq->response,
|
||||
netreq->response_len))
|
||||
return;
|
||||
|
||||
/* Now reschedule the writes on this connection */
|
||||
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
|
||||
GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd,
|
||||
netreq->owner->context->timeout,
|
||||
getdns_eventloop_event_init(&upstream->event, upstream,
|
||||
NULL, upstream_write_cb, NULL));
|
||||
}
|
||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
||||
/* This also reschedules events for the upstream*/
|
||||
stub_cleanup(netreq);
|
||||
|
@ -1500,8 +1419,7 @@ upstream_read_cb(void *userarg)
|
|||
if (netreq->event.read_cb)
|
||||
upstream_reschedule_netreq_events(upstream, netreq);
|
||||
|
||||
if (netreq->owner != upstream->starttls_req)
|
||||
_getdns_check_dns_req_complete(netreq->owner);
|
||||
_getdns_check_dns_req_complete(netreq->owner);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1581,20 +1499,6 @@ upstream_write_cb(void *userarg)
|
|||
GETDNS_SCHEDULE_EVENT(upstream->loop,
|
||||
upstream->fd, TIMEOUT_FOREVER, &upstream->event);
|
||||
}
|
||||
if (upstream->starttls_req && netreq->owner == upstream->starttls_req) {
|
||||
/* Now deschedule any further writes on this connection until we get
|
||||
* the STARTTLS answer*/
|
||||
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
|
||||
upstream->event.write_cb = NULL;
|
||||
GETDNS_SCHEDULE_EVENT(upstream->loop,
|
||||
upstream->fd, TIMEOUT_FOREVER, &upstream->event);
|
||||
} else if (upstream->starttls_req) {
|
||||
/* Delay the cleanup of the STARTTLS req until the write of the next
|
||||
* req in the queue since for sync req, the event on a request is
|
||||
* used for the callback that writes the next req. */
|
||||
_getdns_dns_req_free(upstream->starttls_req);
|
||||
upstream->starttls_req = NULL;
|
||||
}
|
||||
/* With synchonous lookups, schedule the read locally too */
|
||||
if (netreq->event.write_cb) {
|
||||
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
|
||||
|
@ -1602,7 +1506,7 @@ upstream_write_cb(void *userarg)
|
|||
dnsreq->loop, upstream->fd, dnsreq->context->timeout,
|
||||
getdns_eventloop_event_init(&netreq->event, netreq,
|
||||
netreq_upstream_read_cb,
|
||||
(upstream->write_queue && !upstream->starttls_req ?
|
||||
(upstream->write_queue ?
|
||||
netreq_upstream_write_cb : NULL),
|
||||
stub_timeout_cb));
|
||||
}
|
||||
|
@ -1638,12 +1542,6 @@ upstream_transport_valid(getdns_upstream *upstream,
|
|||
upstream->tcp.write_error != 0) {
|
||||
return 0;
|
||||
}
|
||||
/* Allow TCP messages to be sent on a STARTTLS upstream that hasn't
|
||||
* upgraded to avoid opening a new connection if one is aleady open. */
|
||||
if (transport == GETDNS_TRANSPORT_TCP &&
|
||||
upstream->transport == GETDNS_TRANSPORT_STARTTLS &&
|
||||
upstream->tls_hs_state == GETDNS_HS_FAILED)
|
||||
return 1;
|
||||
/* Otherwise, transport must match, and not have failed */
|
||||
if (upstream->transport != transport)
|
||||
return 0;
|
||||
|
@ -1739,28 +1637,6 @@ upstream_connect(getdns_upstream *upstream, getdns_transport_list_t transport,
|
|||
upstream->loop = dnsreq->context->extension;
|
||||
upstream->fd = fd;
|
||||
break;
|
||||
case GETDNS_TRANSPORT_STARTTLS:
|
||||
/* Use existing if available. Let the fallback code handle it if
|
||||
* STARTTLS isn't availble. */
|
||||
if (upstream->fd != -1)
|
||||
return upstream->fd;
|
||||
fd = tcp_connect(upstream, transport);
|
||||
if (fd == -1) return -1;
|
||||
if (!create_starttls_request(dnsreq, upstream, dnsreq->loop))
|
||||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
getdns_network_req *starttls_netreq = upstream->starttls_req->netreqs[0];
|
||||
upstream->loop = dnsreq->context->extension;
|
||||
upstream->fd = fd;
|
||||
upstream_schedule_netreq(upstream, starttls_netreq);
|
||||
/* Schedule at least the timeout locally, but use less than half the
|
||||
* context value so by default this timeouts before the TIMEOUT_TLS.
|
||||
* And also the write if we perform a synchronous lookup */
|
||||
GETDNS_SCHEDULE_EVENT(
|
||||
dnsreq->loop, upstream->fd, dnsreq->context->timeout / 3,
|
||||
getdns_eventloop_event_init(&starttls_netreq->event,
|
||||
starttls_netreq, NULL, (dnsreq->loop != upstream->loop
|
||||
? netreq_upstream_write_cb : NULL), stub_timeout_cb));
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
/* Nothing to do*/
|
||||
|
@ -1797,6 +1673,7 @@ find_upstream_for_netreq(getdns_network_req *netreq)
|
|||
continue;
|
||||
netreq->transport_current = i;
|
||||
netreq->upstream = upstream;
|
||||
netreq->keepalive_sent = 0;
|
||||
return fd;
|
||||
}
|
||||
return -1;
|
||||
|
@ -1908,9 +1785,7 @@ upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
|
|||
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
|
||||
upstream->event.timeout_cb = NULL;
|
||||
upstream->event.write_cb = upstream_write_cb;
|
||||
if (upstream->tls_hs_state == GETDNS_HS_WRITE ||
|
||||
(upstream->starttls_req &&
|
||||
upstream->starttls_req->netreqs[0] == netreq)) {
|
||||
if (upstream->tls_hs_state == GETDNS_HS_WRITE) {
|
||||
/* Set a timeout on the upstream so we can catch failed setup*/
|
||||
/* TODO[TLS]: When generic fallback supported, we should decide how
|
||||
* to split the timeout between transports. */
|
||||
|
@ -1950,11 +1825,9 @@ _getdns_submit_stub_request(getdns_network_req *netreq)
|
|||
GETDNS_SCHEDULE_EVENT(
|
||||
dnsreq->loop, netreq->fd, dnsreq->context->timeout,
|
||||
getdns_eventloop_event_init(&netreq->event, netreq,
|
||||
NULL, (transport == GETDNS_TRANSPORT_UDP ?
|
||||
stub_udp_write_cb: stub_tcp_write_cb), stub_timeout_cb));
|
||||
NULL, stub_udp_write_cb, stub_timeout_cb));
|
||||
return GETDNS_RETURN_GOOD;
|
||||
|
||||
case GETDNS_TRANSPORT_STARTTLS:
|
||||
|
||||
case GETDNS_TRANSPORT_TLS:
|
||||
case GETDNS_TRANSPORT_TCP:
|
||||
upstream_schedule_netreq(netreq->upstream, netreq);
|
||||
|
|
|
@ -58,7 +58,7 @@ CHECK_EVENT_PROG=@CHECK_EVENT_PROG@
|
|||
CHECK_EV_PROG=@CHECK_EV_PROG@
|
||||
|
||||
CC=@CC@
|
||||
CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@
|
||||
CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ @CPPFLAGS@
|
||||
LDFLAGS=-L.. @LDFLAGS@
|
||||
LDLIBS=../libgetdns.la @LIBS@
|
||||
CHECK_LIBS=@CHECK_LIBS@
|
||||
|
@ -213,13 +213,15 @@ configure.status: configure
|
|||
|
||||
depend:
|
||||
(cd $(srcdir) ; awk 'BEGIN{P=1}{if(P)print}/^# Dependencies/{P=0}' Makefile.in > Makefile.in.new )
|
||||
(cd $(srcdir) ; gcc -MM -I. -I.. *.c | \
|
||||
sed -e 's? \([a-z_-]*\)\.\([ch]\)? $$(srcdir)/\1.\2?g' \
|
||||
(blddir=`pwd`; cd $(srcdir) ; gcc -MM -I. -I.. -I"$$blddir"/.. *.c | \
|
||||
sed -e "s? $$blddir/? ?g" \
|
||||
-e 's? \([a-z_-]*\)\.\([ch]\)? $$(srcdir)/\1.\2?g' \
|
||||
-e 's? \$$(srcdir)/config\.h? ../config.h?g' \
|
||||
-e 's? $$(srcdir)/\.\./getdns/getdns_extra\.h? ../getdns/getdns_extra.h?g' \
|
||||
-e 's? \.\./getdns/getdns_ext_libevent\.h? $$(srcdir)/../getdns/getdns_ext_libevent.h?g' \
|
||||
-e 's? \.\./getdns/getdns_ext_libev\.h? $$(srcdir)/../getdns/getdns_ext_libev.h?g' \
|
||||
-e 's? \.\./getdns/getdns_ext_libuv\.h? $$(srcdir)/../getdns/getdns_ext_libuv.h?g' \
|
||||
-e 's? \.\./debug\.h? $$(srcdir)/../debug.h?g' \
|
||||
-e 's!\(.*\)\.o[ :]*!\1.lo \1.o: !g' >> Makefile.in.new )
|
||||
(cd $(srcdir) ; diff Makefile.in.new Makefile.in && rm Makefile.in.new \
|
||||
|| mv Makefile.in.new Makefile.in )
|
||||
|
@ -229,21 +231,24 @@ depend:
|
|||
.PHONY: clean test
|
||||
|
||||
# Dependencies for the unit tests
|
||||
check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c ../getdns/getdns.h $(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns_extra.h $(srcdir)/check_getdns_general.h \
|
||||
$(srcdir)/check_getdns_general_sync.h $(srcdir)/check_getdns_address.h \
|
||||
$(srcdir)/check_getdns_address_sync.h $(srcdir)/check_getdns_hostname.h \
|
||||
$(srcdir)/check_getdns_hostname_sync.h $(srcdir)/check_getdns_context_create.h \
|
||||
$(srcdir)/check_getdns_context_destroy.h $(srcdir)/check_getdns_cancel_callback.h \
|
||||
$(srcdir)/check_getdns_list_get_length.h $(srcdir)/check_getdns_list_get_data_type.h \
|
||||
$(srcdir)/check_getdns_list_get_dict.h $(srcdir)/check_getdns_list_get_list.h \
|
||||
$(srcdir)/check_getdns_list_get_int.h $(srcdir)/check_getdns_list_get_bindata.h \
|
||||
$(srcdir)/check_getdns_dict_get_names.h $(srcdir)/check_getdns_dict_get_data_type.h \
|
||||
$(srcdir)/check_getdns_dict_get_dict.h $(srcdir)/check_getdns_dict_get_list.h \
|
||||
$(srcdir)/check_getdns_dict_get_bindata.h $(srcdir)/check_getdns_dict_get_int.h \
|
||||
$(srcdir)/check_getdns_dict_destroy.h $(srcdir)/check_getdns_dict_set_dict.h \
|
||||
$(srcdir)/check_getdns_dict_set_list.h $(srcdir)/check_getdns_dict_set_bindata.h \
|
||||
$(srcdir)/check_getdns_dict_set_int.h $(srcdir)/check_getdns_convert_ulabel_to_alabel.h \
|
||||
check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_general.h $(srcdir)/check_getdns_general_sync.h \
|
||||
$(srcdir)/check_getdns_address.h $(srcdir)/check_getdns_address_sync.h \
|
||||
$(srcdir)/check_getdns_hostname.h $(srcdir)/check_getdns_hostname_sync.h \
|
||||
$(srcdir)/check_getdns_context_create.h $(srcdir)/check_getdns_context_destroy.h \
|
||||
$(srcdir)/check_getdns_cancel_callback.h $(srcdir)/check_getdns_list_get_length.h \
|
||||
$(srcdir)/check_getdns_list_get_data_type.h $(srcdir)/check_getdns_list_get_dict.h \
|
||||
$(srcdir)/check_getdns_list_get_list.h $(srcdir)/check_getdns_list_get_int.h \
|
||||
$(srcdir)/check_getdns_list_get_bindata.h $(srcdir)/check_getdns_dict_get_names.h \
|
||||
$(srcdir)/check_getdns_dict_get_data_type.h $(srcdir)/check_getdns_dict_get_dict.h \
|
||||
$(srcdir)/check_getdns_dict_get_list.h $(srcdir)/check_getdns_dict_get_bindata.h \
|
||||
$(srcdir)/check_getdns_dict_get_int.h $(srcdir)/check_getdns_dict_destroy.h \
|
||||
$(srcdir)/check_getdns_dict_set_dict.h $(srcdir)/check_getdns_dict_set_list.h \
|
||||
$(srcdir)/check_getdns_dict_set_bindata.h $(srcdir)/check_getdns_dict_set_int.h \
|
||||
$(srcdir)/check_getdns_convert_ulabel_to_alabel.h \
|
||||
$(srcdir)/check_getdns_convert_alabel_to_ulabel.h $(srcdir)/check_getdns_pretty_print_dict.h \
|
||||
$(srcdir)/check_getdns_display_ip_address.h \
|
||||
$(srcdir)/check_getdns_context_set_context_update_callback.h \
|
||||
|
@ -251,36 +256,63 @@ check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c ../getdns/getdns.h $(sr
|
|||
$(srcdir)/check_getdns_context_set_upstream_recursive_servers.h \
|
||||
$(srcdir)/check_getdns_service.h $(srcdir)/check_getdns_service_sync.h \
|
||||
$(srcdir)/check_getdns_transport.h
|
||||
check_getdns_common.lo check_getdns_common.o: $(srcdir)/check_getdns_common.c ../getdns/getdns.h \
|
||||
../config.h $(srcdir)/check_getdns_common.h ../getdns/getdns_extra.h \
|
||||
check_getdns_common.lo check_getdns_common.o: $(srcdir)/check_getdns_common.c \
|
||||
../getdns/getdns.h \
|
||||
../config.h \
|
||||
$(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_eventloop.h
|
||||
check_getdns_context_set_timeout.lo check_getdns_context_set_timeout.o: $(srcdir)/check_getdns_context_set_timeout.c \
|
||||
$(srcdir)/check_getdns_context_set_timeout.h $(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns.h ../getdns/getdns_extra.h
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
check_getdns_libev.lo check_getdns_libev.o: $(srcdir)/check_getdns_libev.c $(srcdir)/check_getdns_eventloop.h \
|
||||
../config.h ../getdns/getdns.h $(srcdir)/../getdns/getdns_ext_libev.h \
|
||||
../getdns/getdns_extra.h $(srcdir)/check_getdns_common.h
|
||||
../config.h \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/../getdns/getdns_ext_libev.h \
|
||||
../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_common.h
|
||||
check_getdns_libevent.lo check_getdns_libevent.o: $(srcdir)/check_getdns_libevent.c $(srcdir)/check_getdns_eventloop.h \
|
||||
../config.h ../getdns/getdns.h $(srcdir)/../getdns/getdns_ext_libevent.h \
|
||||
../getdns/getdns_extra.h $(srcdir)/check_getdns_libevent.h $(srcdir)/check_getdns_common.h
|
||||
../config.h \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/../getdns/getdns_ext_libevent.h \
|
||||
../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_libevent.h $(srcdir)/check_getdns_common.h
|
||||
check_getdns_libuv.lo check_getdns_libuv.o: $(srcdir)/check_getdns_libuv.c $(srcdir)/check_getdns_eventloop.h \
|
||||
../config.h ../getdns/getdns.h $(srcdir)/../getdns/getdns_ext_libuv.h \
|
||||
../getdns/getdns_extra.h $(srcdir)/check_getdns_common.h
|
||||
../config.h \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/../getdns/getdns_ext_libuv.h \
|
||||
../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_common.h
|
||||
check_getdns_selectloop.lo check_getdns_selectloop.o: $(srcdir)/check_getdns_selectloop.c \
|
||||
$(srcdir)/check_getdns_eventloop.h ../config.h ../getdns/getdns.h \
|
||||
$(srcdir)/check_getdns_eventloop.h \
|
||||
../config.h \
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
check_getdns_transport.lo check_getdns_transport.o: $(srcdir)/check_getdns_transport.c \
|
||||
$(srcdir)/check_getdns_transport.h $(srcdir)/check_getdns_common.h ../getdns/getdns.h \
|
||||
$(srcdir)/check_getdns_transport.h $(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c ../config.h ../getdns/getdns.h \
|
||||
getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c \
|
||||
../config.h \
|
||||
$(srcdir)/../debug.h \
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
scratchpad.template.lo scratchpad.template.o: scratchpad.template.c ../getdns/getdns.h \
|
||||
scratchpad.template.lo scratchpad.template.o: scratchpad.template.c \
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
testmessages.lo testmessages.o: $(srcdir)/testmessages.c $(srcdir)/testmessages.h
|
||||
tests_dict.lo tests_dict.o: $(srcdir)/tests_dict.c $(srcdir)/testmessages.h ../getdns/getdns.h
|
||||
tests_list.lo tests_list.o: $(srcdir)/tests_list.c $(srcdir)/testmessages.h ../getdns/getdns.h
|
||||
tests_namespaces.lo tests_namespaces.o: $(srcdir)/tests_namespaces.c $(srcdir)/testmessages.h ../getdns/getdns.h
|
||||
tests_stub_async.lo tests_stub_async.o: $(srcdir)/tests_stub_async.c ../config.h $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h ../getdns/getdns_extra.h
|
||||
tests_stub_sync.lo tests_stub_sync.o: $(srcdir)/tests_stub_sync.c $(srcdir)/testmessages.h ../getdns/getdns.h \
|
||||
tests_dict.lo tests_dict.o: $(srcdir)/tests_dict.c $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h
|
||||
tests_list.lo tests_list.o: $(srcdir)/tests_list.c $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h
|
||||
tests_namespaces.lo tests_namespaces.o: $(srcdir)/tests_namespaces.c $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h
|
||||
tests_stub_async.lo tests_stub_async.o: $(srcdir)/tests_stub_async.c \
|
||||
../config.h \
|
||||
$(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
tests_stub_sync.lo tests_stub_sync.o: $(srcdir)/tests_stub_sync.c $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
|
|
|
@ -96,14 +96,14 @@ START_TEST (getdns_context_set_idle_timeout_2)
|
|||
{
|
||||
/*
|
||||
* timeout is 0
|
||||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
*/
|
||||
|
||||
struct getdns_context *context = NULL;
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
ASSERT_RC(getdns_context_set_idle_timeout(context, 0),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_timeout()");
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()");
|
||||
|
||||
CONTEXT_DESTROY;
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "debug.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <getdns/getdns.h>
|
||||
#include <getdns/getdns_extra.h>
|
||||
#include "util-internal.h"
|
||||
|
||||
#define MAX_TIMEOUTS FD_SETSIZE
|
||||
|
||||
|
@ -267,6 +267,66 @@ static enum { GENERAL, ADDRESS, HOSTNAME, SERVICE } calltype = GENERAL;
|
|||
|
||||
int get_rrtype(const char *t);
|
||||
|
||||
int gqldns_b64_pton(char const *src, uint8_t *target, size_t targsize)
|
||||
{
|
||||
const uint8_t pad64 = 64; /* is 64th in the b64 array */
|
||||
const char* s = src;
|
||||
uint8_t in[4];
|
||||
size_t o = 0, incount = 0;
|
||||
|
||||
while(*s) {
|
||||
/* skip any character that is not base64 */
|
||||
/* conceptually we do:
|
||||
const char* b64 = pad'=' is appended to array
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
const char* d = strchr(b64, *s++);
|
||||
and use d-b64;
|
||||
*/
|
||||
char d = *s++;
|
||||
if(d <= 'Z' && d >= 'A')
|
||||
d -= 'A';
|
||||
else if(d <= 'z' && d >= 'a')
|
||||
d = d - 'a' + 26;
|
||||
else if(d <= '9' && d >= '0')
|
||||
d = d - '0' + 52;
|
||||
else if(d == '+')
|
||||
d = 62;
|
||||
else if(d == '/')
|
||||
d = 63;
|
||||
else if(d == '=')
|
||||
d = 64;
|
||||
else continue;
|
||||
in[incount++] = (uint8_t)d;
|
||||
if(incount != 4)
|
||||
continue;
|
||||
/* process whole block of 4 characters into 3 output bytes */
|
||||
if(in[3] == pad64 && in[2] == pad64) { /* A B = = */
|
||||
if(o+1 > targsize)
|
||||
return -1;
|
||||
target[o] = (in[0]<<2) | ((in[1]&0x30)>>4);
|
||||
o += 1;
|
||||
break; /* we are done */
|
||||
} else if(in[3] == pad64) { /* A B C = */
|
||||
if(o+2 > targsize)
|
||||
return -1;
|
||||
target[o] = (in[0]<<2) | ((in[1]&0x30)>>4);
|
||||
target[o+1]= ((in[1]&0x0f)<<4) | ((in[2]&0x3c)>>2);
|
||||
o += 2;
|
||||
break; /* we are done */
|
||||
} else {
|
||||
if(o+3 > targsize)
|
||||
return -1;
|
||||
/* write xxxxxxyy yyyyzzzz zzwwwwww */
|
||||
target[o] = (in[0]<<2) | ((in[1]&0x30)>>4);
|
||||
target[o+1]= ((in[1]&0x0f)<<4) | ((in[2]&0x3c)>>2);
|
||||
target[o+2]= ((in[2]&0x03)<<6) | in[3];
|
||||
o += 3;
|
||||
}
|
||||
incount = 0;
|
||||
}
|
||||
return (int)o;
|
||||
}
|
||||
|
||||
getdns_dict *
|
||||
ipaddr_dict(getdns_context *context, char *ipstr)
|
||||
{
|
||||
|
@ -275,6 +335,13 @@ ipaddr_dict(getdns_context *context, char *ipstr)
|
|||
char *p = strchr(ipstr, '@'), *portstr = "";
|
||||
char *t = strchr(ipstr, '#'), *tls_portstr = "";
|
||||
char *n = strchr(ipstr, '~'), *tls_namestr = "";
|
||||
/* ^[alg:]name:key */
|
||||
char *T = strchr(ipstr, '^'), *tsig_name_str = ""
|
||||
, *tsig_secret_str = ""
|
||||
, *tsig_algorithm_str = "";
|
||||
int tsig_secret_size;
|
||||
uint8_t tsig_secret_buf[256]; /* 4 times SHA512 */
|
||||
getdns_bindata tsig_secret;
|
||||
uint8_t buf[sizeof(struct in6_addr)];
|
||||
getdns_bindata addr;
|
||||
|
||||
|
@ -297,6 +364,22 @@ ipaddr_dict(getdns_context *context, char *ipstr)
|
|||
*n = 0;
|
||||
tls_namestr = n + 1;
|
||||
}
|
||||
if (T) {
|
||||
*T = 0;
|
||||
tsig_name_str = T + 1;
|
||||
if ((T = strchr(tsig_name_str, ':'))) {
|
||||
*T = 0;
|
||||
tsig_secret_str = T + 1;
|
||||
if ((T = strchr(tsig_secret_str, ':'))) {
|
||||
*T = 0;
|
||||
tsig_algorithm_str = tsig_name_str;
|
||||
tsig_name_str = tsig_secret_str;
|
||||
tsig_secret_str = T + 1;
|
||||
}
|
||||
} else {
|
||||
tsig_name_str = "";
|
||||
}
|
||||
}
|
||||
if (strchr(ipstr, ':')) {
|
||||
getdns_dict_util_set_string(r, "address_type", "IPv6");
|
||||
addr.size = 16;
|
||||
|
@ -322,7 +405,19 @@ ipaddr_dict(getdns_context *context, char *ipstr)
|
|||
}
|
||||
if (*scope_id_str)
|
||||
getdns_dict_util_set_string(r, "scope_id", scope_id_str);
|
||||
|
||||
if (*tsig_name_str)
|
||||
getdns_dict_util_set_string(r, "tsig_name", tsig_name_str);
|
||||
if (*tsig_algorithm_str)
|
||||
getdns_dict_util_set_string(r, "tsig_algorithm", tsig_name_str);
|
||||
if (*tsig_secret_str) {
|
||||
tsig_secret_size = gqldns_b64_pton(
|
||||
tsig_secret_str, tsig_secret_buf, sizeof(tsig_secret_buf));
|
||||
if (tsig_secret_size > 0) {
|
||||
tsig_secret.size = tsig_secret_size;
|
||||
tsig_secret.data = tsig_secret_buf;
|
||||
getdns_dict_set_bindata(r, "tsig_secret", &tsig_secret);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -345,9 +440,6 @@ fill_transport_list(getdns_context *context, char *transport_list_str,
|
|||
case 'L':
|
||||
transports[i] = GETDNS_TRANSPORT_TLS;
|
||||
break;
|
||||
case 'S':
|
||||
transports[i] = GETDNS_TRANSPORT_STARTTLS;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unrecognised transport '%c' in string %s\n",
|
||||
*(transport_list_str + i), transport_list_str);
|
||||
|
@ -360,7 +452,7 @@ fill_transport_list(getdns_context *context, char *transport_list_str,
|
|||
void
|
||||
print_usage(FILE *out, const char *progname)
|
||||
{
|
||||
fprintf(out, "usage: %s [@<server>] [+extension] [<name>] [<type>]\n",
|
||||
fprintf(out, "usage: %s [@<server>][~<server_hostname>] [+extension] [<name>] [<type>]\n",
|
||||
progname);
|
||||
fprintf(out, "options:\n");
|
||||
fprintf(out, "\t-a\tPerform asynchronous resolution "
|
||||
|
@ -394,11 +486,10 @@ print_usage(FILE *out, const char *progname)
|
|||
fprintf(out, "\t-O\tSet transport to TCP only keep connections open\n");
|
||||
fprintf(out, "\t-L\tSet transport to TLS only keep connections open\n");
|
||||
fprintf(out, "\t-E\tSet transport to TLS with TCP fallback only keep connections open\n");
|
||||
fprintf(out, "\t-R\tSet transport to STARTTLS with TCP fallback only keep connections open\n");
|
||||
fprintf(out, "\t-u\tSet transport to UDP with TCP fallback\n");
|
||||
fprintf(out, "\t-U\tSet transport to UDP only\n");
|
||||
fprintf(out, "\t-l <transports>\tSet transport list. List can contain 1 of each of the characters\n");
|
||||
fprintf(out, "\t\t\t U T L S for UDP, TCP, TLS or STARTTLS e.g 'UT' or 'LST' \n");
|
||||
fprintf(out, "\t\t\t U T L S for UDP, TCP or TLS e.g 'UT' or 'LTU' \n");
|
||||
|
||||
}
|
||||
|
||||
|
@ -790,10 +881,6 @@ getdns_return_t parse_args(int argc, char **argv)
|
|||
getdns_context_set_dns_transport(context,
|
||||
GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN);
|
||||
break;
|
||||
case 'R':
|
||||
getdns_context_set_dns_transport(context,
|
||||
GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN);
|
||||
break;
|
||||
case 'u':
|
||||
getdns_context_set_dns_transport(context,
|
||||
GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP);
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#define TRANSPORT_PIPELINE "pipeline"
|
||||
#define TRANSPORT_TLS_KEEPOPEN "tls"
|
||||
#define TRANSPORT_TLS_TCP_KEEPOPEN "dns-over-tls"
|
||||
#define TRANSPORT_STARTTLS_TCP_KEEPOPEN "starttls"
|
||||
#define RESOLUTION_STUB "stub"
|
||||
#define RESOLUTION_REC "rec"
|
||||
|
||||
|
@ -111,8 +110,6 @@ main(int argc, char** argv)
|
|||
getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN);
|
||||
else if (strncmp(transport, TRANSPORT_TLS_TCP_KEEPOPEN, 12) == 0)
|
||||
getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN);
|
||||
else if (strncmp(transport, TRANSPORT_STARTTLS_TCP_KEEPOPEN, 8) == 0)
|
||||
getdns_context_set_dns_transport(this_context, GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN);
|
||||
else if (strncmp(transport, TRANSPORT_UDP_TCP, 3) != 0) {
|
||||
fprintf(stderr, "Invalid transport %s, must be one of udp, udp_tcp, tcp or pipeline\n", transport);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
@ -49,7 +49,7 @@ usage () {
|
|||
echo "it can be used to check the basic functionality for now. It is recommended that"
|
||||
echo "local or known test servers are used, but it should work with the default servers:"
|
||||
echo " - Google Open DNS for TCP and UDP only "
|
||||
echo "- the getdnsapi.net test server Open Resolver for TLS, STARTTLS, TCP and UDP"
|
||||
echo "- the getdnsapi.net test server Open Resolver for TLS, TCP and UDP"
|
||||
echo "NOTE: By default this script assumes it is located in the same directory"
|
||||
echo "as the getdns_query binary. If it is not, then the location of the binary"
|
||||
echo "can be specified via the command line option."
|
||||
|
@ -57,7 +57,7 @@ usage () {
|
|||
echo "usage: test_transport.sh"
|
||||
echo " -p path to getdns_query binary"
|
||||
echo " -s server configured for only TCP and UDP"
|
||||
echo " -t server configured for TLS, STARTTLS, TCP and UDP"
|
||||
echo " -t server configured for TLS, TCP and UDP"
|
||||
echo " (This must include the hostname e.g. 185.49.141.38~getdnsapi.net)"
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,6 @@ GOOD_QUERIES=(
|
|||
"-s -A -q getdnsapi.net -l T @${SERVER_IP} "
|
||||
"-s -A -q getdnsapi.net -l L @${TLS_SERVER_IP_NO_NAME}"
|
||||
"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP}")
|
||||
#"-s -A -q getdnsapi.net -l S @${TLS_SERVER_IP_NO_NAME}")
|
||||
|
||||
GOOD_FALLBACK_QUERIES=(
|
||||
"-s -A -q getdnsapi.net -l LT @${SERVER_IP}"
|
||||
|
@ -91,7 +90,6 @@ GOOD_FALLBACK_QUERIES=(
|
|||
|
||||
NOT_AVAILABLE_QUERIES=(
|
||||
"-s -A -q getdnsapi.net -l L @${SERVER_IP} "
|
||||
#"-s -A -q getdnsapi.net -l S @${SERVER_IP} "
|
||||
"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME} "
|
||||
"-s -G -q DNSKEY getdnsapi.net -l U @${SERVER_IP} -b 512 -D")
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
BaseName: 050-constants
|
||||
Version: 1.0
|
||||
Description: Check if all constants are in const-info.c
|
||||
CreationDate: wo dec 16 14:26:01 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends:
|
||||
Help:
|
||||
Pre: 050-constants.pre
|
||||
Post:
|
||||
Test: 050-constants.test
|
||||
AuxFiles:
|
||||
Passed:
|
||||
Failure:
|
|
@ -0,0 +1,14 @@
|
|||
# #-- 050-constants.pre--#
|
||||
# source the master var file when it's there
|
||||
if [ -f ../.tpkg.var.master ]
|
||||
then
|
||||
source ../.tpkg.var.master
|
||||
else
|
||||
(
|
||||
cd ..
|
||||
[ -f "${TPKG_SRCDIR}/setup-env.sh" ] \
|
||||
&& sh "${TPKG_SRCDIR}/setup-env.sh"
|
||||
) && source ../.tpkg.var.master
|
||||
fi
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
|
@ -0,0 +1,14 @@
|
|||
# #-- 050-constants.test --#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
cp -p ${SRCROOT}/src/const-info.c const-info.c.orig
|
||||
(
|
||||
cd ${SRCROOT}/src
|
||||
sh mk-const-info.c.sh
|
||||
)
|
||||
cp -p ${SRCROOT}/src/const-info.c const-info.c.new
|
||||
cp -p const-info.c.orig ${SRCROOT}/src/const-info.c
|
||||
diff const-info.c.orig const-info.c.new
|
|
@ -0,0 +1,16 @@
|
|||
BaseName: 060-symbols
|
||||
Version: 1.0
|
||||
Description: Check if all symbols are in libgetdns.symbols
|
||||
CreationDate: wo dec 16 15:41:23 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends:
|
||||
Help:
|
||||
Pre: 060-symbols.pre
|
||||
Post:
|
||||
Test: 060-symbols.test
|
||||
AuxFiles:
|
||||
Passed:
|
||||
Failure:
|
|
@ -0,0 +1,14 @@
|
|||
# #-- 060-symbols.pre--#
|
||||
# source the master var file when it's there
|
||||
if [ -f ../.tpkg.var.master ]
|
||||
then
|
||||
source ../.tpkg.var.master
|
||||
else
|
||||
(
|
||||
cd ..
|
||||
[ -f "${TPKG_SRCDIR}/setup-env.sh" ] \
|
||||
&& sh "${TPKG_SRCDIR}/setup-env.sh"
|
||||
) && source ../.tpkg.var.master
|
||||
fi
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
|
@ -0,0 +1,14 @@
|
|||
# #-- 060-symbols.test --#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
cp -p ${SRCROOT}/src/libgetdns.symbols libgetdns.symbols.orig
|
||||
(
|
||||
cd ${SRCROOT}/src
|
||||
sh mk-symfiles.sh
|
||||
)
|
||||
cp -p ${SRCROOT}/src/libgetdns.symbols libgetdns.symbols.new
|
||||
cp -p libgetdns.symbols.orig ${SRCROOT}/src/libgetdns.symbols
|
||||
diff libgetdns.symbols.orig libgetdns.symbols.new
|
|
@ -7,7 +7,7 @@ Category:
|
|||
Component:
|
||||
CmdDepends:
|
||||
Depends:
|
||||
Help: 100-compile.help
|
||||
Help:
|
||||
Pre: 100-compile.pre
|
||||
Post:
|
||||
Test: 100-compile.test
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
The library is compiled without eventloop extensions.
|
|
@ -16,4 +16,4 @@ fi
|
|||
rm -fr "${BUILDDIR}/build"
|
||||
mkdir "${BUILDDIR}/build"
|
||||
cd "${BUILDDIR}/build"
|
||||
"${SRCROOT}/configure"
|
||||
"${SRCROOT}/configure" --prefix "${BUILDDIR}/install"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
BaseName: 105-install
|
||||
Version: 1.0
|
||||
Description: Install the library
|
||||
CreationDate: vr dec 18 10:52:02 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends: 100-compile.tpkg
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 105-install.test
|
||||
AuxFiles:
|
||||
Passed:
|
||||
Failure:
|
|
@ -0,0 +1,8 @@
|
|||
# #-- 105-install.test --#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
cd "${BUILDDIR}/build"
|
||||
make install
|
|
@ -7,7 +7,7 @@ Category:
|
|||
Component:
|
||||
CmdDepends:
|
||||
Depends: 100-compile.tpkg
|
||||
Help: 110-link.help
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 110-link.test
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Try to link the getdns_query program
|
|
@ -0,0 +1,16 @@
|
|||
BaseName: 115-install-linked
|
||||
Version: 1.0
|
||||
Description: Install the getdns_query program
|
||||
CreationDate: vr dec 18 10:52:26 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends: 110-link.tpkg
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 115-install-linked.test
|
||||
AuxFiles:
|
||||
Passed:
|
||||
Failure:
|
|
@ -0,0 +1,8 @@
|
|||
# #-- 115-install-linked.test --#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
cd "${BUILDDIR}/build"
|
||||
make install-getdns_query
|
|
@ -7,7 +7,7 @@ Category:
|
|||
Component:
|
||||
CmdDepends:
|
||||
Depends: 110-link.tpkg
|
||||
Help: 120-run-getdns_query.help
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 120-run-getdns_query.test
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Run the getdns_query test program
|
|
@ -1,13 +1,13 @@
|
|||
BaseName: 130-run-unit-tests
|
||||
Version: 1.0
|
||||
Description: Run the getdns_query program
|
||||
Description: Run the unit tests
|
||||
CreationDate: do dec 10 11:10:29 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends: 110-link.tpkg
|
||||
Help: 130-run-unit-tests.help
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 130-run-unit-tests.test
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Run the getdns_query test program
|
|
@ -1,13 +1,13 @@
|
|||
BaseName: 200-stub-only-compile
|
||||
Version: 1.0
|
||||
Description: Create a builddir and compile simple
|
||||
Description: Create builddir and compile stub only
|
||||
CreationDate: do dec 10 11:08:24 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends:
|
||||
Help: 200-stub-only-compile.help
|
||||
Help:
|
||||
Pre: 200-stub-only-compile.pre
|
||||
Post:
|
||||
Test: 200-stub-only-compile.test
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
The library is compiled as stub only and without eventloop extensions.
|
|
@ -7,7 +7,7 @@ Category:
|
|||
Component:
|
||||
CmdDepends:
|
||||
Depends: 200-stub-only-compile.tpkg
|
||||
Help: 210-stub-only-link.help
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 210-stub-only-link.test
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Try to link the getdns_query program
|
|
@ -7,7 +7,7 @@ Category:
|
|||
Component:
|
||||
CmdDepends:
|
||||
Depends: 210-stub-only-link.tpkg
|
||||
Help: 220-stub-only-run-getdns_query.help
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 220-stub-only-run-getdns_query.test
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Run the getdns_query test program
|
|
@ -1,13 +1,13 @@
|
|||
BaseName: 230-stub-only-run-unit-tests
|
||||
Version: 1.0
|
||||
Description: Run the getdns_query program
|
||||
Description: Run the unit tests
|
||||
CreationDate: do dec 10 11:09:02 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends: 210-stub-only-link.tpkg
|
||||
Help: 230-stub-only-run-unit-tests.help
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 230-stub-only-run-unit-tests.test
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Run the getdns_query test program
|
|
@ -7,7 +7,7 @@ Category:
|
|||
Component:
|
||||
CmdDepends:
|
||||
Depends: 200-stub-only-compile.tpkg
|
||||
Help: 250-json-pointers.help
|
||||
Help:
|
||||
Pre: 250-json-pointers.pre
|
||||
Post:
|
||||
Test: 250-json-pointers.test
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
Compile a program that setups a dict with json pointers and pretty prints the dict.
|
||||
Then compare the output to the known to be good output.
|
|
@ -1,16 +0,0 @@
|
|||
BaseName: 300-event-loops-compile
|
||||
Version: 1.0
|
||||
Description: Create a builddir and compile with event loops
|
||||
CreationDate: do dec 10 11:38:35 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends:
|
||||
Help: 300-event-loops-compile.help
|
||||
Pre: 300-event-loops-compile.pre
|
||||
Post:
|
||||
Test: 300-event-loops-compile.test
|
||||
AuxFiles:
|
||||
Passed:
|
||||
Failure:
|
|
@ -1 +0,0 @@
|
|||
The library is compiled with eventloop extensions for all event loops available.
|
|
@ -1,25 +0,0 @@
|
|||
# #-- 300-event-loops-compile.pre--#
|
||||
# source the master var file when it's there
|
||||
if [ -f ../.tpkg.var.master ]
|
||||
then
|
||||
source ../.tpkg.var.master
|
||||
else
|
||||
(
|
||||
cd ..
|
||||
[ -f "${TPKG_SRCDIR}/setup-env.sh" ] \
|
||||
&& sh "${TPKG_SRCDIR}/setup-env.sh"
|
||||
) && source ../.tpkg.var.master
|
||||
fi
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
rm -fr "${BUILDDIR}/build-event-loops"
|
||||
mkdir "${BUILDDIR}/build-event-loops"
|
||||
cd "${BUILDDIR}/build-event-loops"
|
||||
"${SRCROOT}/configure" --with-libevent --with-libev --with-libuv \
|
||||
|| "${SRCROOT}/configure" --with-libevent --with-libev \
|
||||
|| "${SRCROOT}/configure" --with-libevent --with-libuv \
|
||||
|| "${SRCROOT}/configure" --with-libev --with-libuv \
|
||||
|| "${SRCROOT}/configure" --with-libevent \
|
||||
|| "${SRCROOT}/configure" --with-libev \
|
||||
|| "${SRCROOT}/configure" --with-libuv
|
|
@ -0,0 +1,16 @@
|
|||
BaseName: 300-event-loops-configure
|
||||
Version: 1.0
|
||||
Description: Configure for maximum coverage
|
||||
CreationDate: vr dec 18 11:21:07 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends:
|
||||
Help:
|
||||
Pre: 300-event-loops-configure.pre
|
||||
Post:
|
||||
Test: 300-event-loops-configure.test
|
||||
AuxFiles:
|
||||
Passed:
|
||||
Failure:
|
|
@ -0,0 +1,14 @@
|
|||
# #-- 300-event-loops-configure.pre--#
|
||||
# source the master var file when it's there
|
||||
if [ -f ../.tpkg.var.master ]
|
||||
then
|
||||
source ../.tpkg.var.master
|
||||
else
|
||||
(
|
||||
cd ..
|
||||
[ -f "${TPKG_SRCDIR}/setup-env.sh" ] \
|
||||
&& sh "${TPKG_SRCDIR}/setup-env.sh"
|
||||
) && source ../.tpkg.var.master
|
||||
fi
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
|
@ -0,0 +1,16 @@
|
|||
# #-- 300-event-loops-configure.test --#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
rm -fr "${BUILDDIR}/build-event-loops"
|
||||
mkdir "${BUILDDIR}/build-event-loops"
|
||||
cd "${BUILDDIR}/build-event-loops"
|
||||
"${SRCROOT}/configure" --enable-all-drafts --with-libevent --with-libev --with-libuv \
|
||||
|| "${SRCROOT}/configure" --enable-all-drafts --with-libevent --with-libev \
|
||||
|| "${SRCROOT}/configure" --enable-all-drafts --with-libevent --with-libuv \
|
||||
|| "${SRCROOT}/configure" --enable-all-drafts --with-libev --with-libuv \
|
||||
|| "${SRCROOT}/configure" --enable-all-drafts --with-libevent \
|
||||
|| "${SRCROOT}/configure" --enable-all-drafts --with-libev \
|
||||
|| "${SRCROOT}/configure" --enable-all-drafts --with-libuv
|
|
@ -0,0 +1,16 @@
|
|||
BaseName: 310-dependencies
|
||||
Version: 1.0
|
||||
Description: Check Makefile dependencies
|
||||
CreationDate: vr dec 18 11:25:59 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends: 300-event-loops-configure.tpkg
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 310-dependencies.test
|
||||
AuxFiles:
|
||||
Passed:
|
||||
Failure:
|
|
@ -0,0 +1,49 @@
|
|||
# #-- 310-dependencies.test --#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# use .tpkg.var.test for in test variable passing
|
||||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
export TPKG_HERE=`pwd`
|
||||
# Temporarily copy Makefile.in files
|
||||
find . -type f -name "Makefile.in" -print0 | xargs -0 rm -f && (
|
||||
cd "${SRCROOT}"
|
||||
find . -maxdepth 3 -type f -name "Makefile.in" -print0 | xargs -0 tar cf -
|
||||
) | (
|
||||
cd "${TPKG_HERE}"
|
||||
tar xf -
|
||||
)
|
||||
(
|
||||
cd "${BUILDDIR}/build-event-loops"
|
||||
if ! ./config.status --config | grep -q 'enable-all-drafts.*--with-libevent.*--with-libev.*--with-libuv'
|
||||
then
|
||||
echo Skipping because not covering enough code
|
||||
exit 0
|
||||
fi
|
||||
make depend >/dev/null 2>&1
|
||||
)
|
||||
CHANGED_DEPENDENCIES=0
|
||||
N_MAKEFILES=0
|
||||
for mf in `find . -type f -name "Makefile.in"`
|
||||
do
|
||||
N_MAKEFILES=`expr $N_MAKEFILES + 1`
|
||||
if ! diff -q "${mf}" "${SRCROOT}"/"${mf#./}"
|
||||
then
|
||||
echo "${mf}" and "${SRCROOT}"/"${mf#./}" differ
|
||||
CHANGED_DEPENDENCIES=1
|
||||
fi
|
||||
done
|
||||
if [ $N_MAKEFILES = 0 ]
|
||||
then
|
||||
echo "No Makefiles compared"
|
||||
exit 1
|
||||
fi
|
||||
# Restore Makefile.in files
|
||||
(
|
||||
cd "${TPKG_HERE}"
|
||||
find . -type f -name "Makefile.in" -print0 | xargs -0 tar cf -
|
||||
)| (
|
||||
cd "${SRCROOT}"
|
||||
tar xf -
|
||||
)
|
||||
exit ${CHANGED_DEPENDENCIES}
|
|
@ -0,0 +1,16 @@
|
|||
BaseName: 320-event-loops-compile
|
||||
Version: 1.0
|
||||
Description: Compile
|
||||
CreationDate: vr dec 18 11:20:35 CET 2015
|
||||
Maintainer: Willem Toorop
|
||||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends: 300-event-loops-configure.tpkg
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 320-event-loops-compile.test
|
||||
AuxFiles:
|
||||
Passed:
|
||||
Failure:
|
|
@ -1,4 +1,4 @@
|
|||
# #-- 300-event-loops-compile.test --#
|
||||
# #-- 320-event-loops-compile.test --#
|
||||
# source the master var file when it's there
|
||||
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
|
||||
# use .tpkg.var.test for in test variable passing
|
|
@ -6,8 +6,8 @@ Maintainer: Willem Toorop
|
|||
Category:
|
||||
Component:
|
||||
CmdDepends:
|
||||
Depends: 300-event-loops-compile.tpkg
|
||||
Help: 330-event-loops-unit-tests.help
|
||||
Depends: 320-event-loops-compile.tpkg
|
||||
Help:
|
||||
Pre:
|
||||
Post:
|
||||
Test: 330-event-loops-unit-tests.test
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Run the getdns_query test program
|
|
@ -116,8 +116,8 @@ struct getdns_upstream;
|
|||
#define TIMEOUT_FOREVER ((int64_t)-1)
|
||||
#define ASSERT_UNREACHABLE 0
|
||||
|
||||
#define GETDNS_TRANSPORTS_MAX 4
|
||||
#define GETDNS_UPSTREAM_TRANSPORTS 3
|
||||
#define GETDNS_TRANSPORTS_MAX 3
|
||||
#define GETDNS_UPSTREAM_TRANSPORTS 2
|
||||
|
||||
/** @}
|
||||
*/
|
||||
|
@ -209,6 +209,14 @@ typedef struct getdns_network_req
|
|||
/* dnssec status */
|
||||
int dnssec_status;
|
||||
|
||||
/* tsig status:
|
||||
* GETDNS_DNSSEC_INDETERMINATE means "No TSIG processing"
|
||||
* GETDNS_DNSSEC_INSECURE means "TSIG sent, validate reply"
|
||||
* GETDNS_DNSSEC_SECURE means "Validated"
|
||||
* GETDNS_DNSSEC_BOGUS means "Validation failed"
|
||||
*/
|
||||
int tsig_status;
|
||||
|
||||
/* For stub resolving */
|
||||
struct getdns_upstream *upstream;
|
||||
int fd;
|
||||
|
@ -223,10 +231,12 @@ typedef struct getdns_network_req
|
|||
int edns_maximum_udp_payload_size;
|
||||
uint16_t max_udp_payload_size;
|
||||
|
||||
size_t keepalive_sent;
|
||||
|
||||
/* Network requests scheduled to write after me */
|
||||
struct getdns_network_req *write_queue_tail;
|
||||
|
||||
/* Some fields to record info for return_call_debugging */
|
||||
/* Some fields to record info for return_call_reporting */
|
||||
uint64_t debug_start_time;
|
||||
uint64_t debug_end_time;
|
||||
size_t debug_tls_auth_status;
|
||||
|
@ -289,7 +299,7 @@ typedef struct getdns_dns_req {
|
|||
int edns_cookies;
|
||||
int edns_client_subnet_private;
|
||||
uint16_t tls_query_padding_blocksize;
|
||||
int return_call_debugging;
|
||||
int return_call_reporting;
|
||||
|
||||
/* Internally used by return_validation_chain */
|
||||
int dnssec_ok_checking_disabled;
|
||||
|
@ -379,5 +389,10 @@ getdns_return_t _getdns_network_req_add_upstream_option(getdns_network_req * req
|
|||
uint16_t code, uint16_t sz, const void* data);
|
||||
void _getdns_network_req_clear_upstream_options(getdns_network_req * req);
|
||||
|
||||
/* Adds TSIG signature (if needed) and returns query length */
|
||||
size_t _getdns_network_req_add_tsig(getdns_network_req *req);
|
||||
|
||||
void _getdns_network_validate_tsig(getdns_network_req *req);
|
||||
|
||||
#endif
|
||||
/* types-internal.h */
|
||||
|
|
|
@ -72,7 +72,7 @@ static getdns_extension_format extformats[] = {
|
|||
#endif
|
||||
{"return_api_information", t_int},
|
||||
{"return_both_v4_and_v6", t_int},
|
||||
{"return_call_debugging", t_int},
|
||||
{"return_call_reporting", t_int},
|
||||
{"specify_class", t_int},
|
||||
};
|
||||
|
||||
|
@ -679,7 +679,7 @@ success:
|
|||
}
|
||||
|
||||
getdns_dict *
|
||||
_getdns_create_call_debugging_dict(
|
||||
_getdns_create_call_reporting_dict(
|
||||
getdns_context *context, getdns_network_req *netreq)
|
||||
{
|
||||
getdns_bindata qname;
|
||||
|
@ -733,6 +733,23 @@ _getdns_create_call_debugging_dict(
|
|||
}
|
||||
getdns_dict_destroy(address_debug);
|
||||
|
||||
if (transport != GETDNS_TRANSPORT_UDP) {
|
||||
/* Report the idle timeout actually used on the connection. Must trim,
|
||||
maximum used in practice is 6553500ms, but this is stored in a uint64_t.*/
|
||||
if (netreq->upstream->keepalive_timeout > UINT32_MAX) {
|
||||
if (getdns_dict_set_int( netreq_debug, "idle timeout in ms (overflow)", UINT32_MAX)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
} else{
|
||||
uint32_t idle_timeout = netreq->upstream->keepalive_timeout;
|
||||
if (getdns_dict_set_int( netreq_debug, "idle timeout in ms", idle_timeout)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (netreq->upstream->transport != GETDNS_TRANSPORT_TLS)
|
||||
return netreq_debug;
|
||||
|
||||
|
@ -754,7 +771,7 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
|
|||
getdns_list *just_addrs = NULL;
|
||||
getdns_list *replies_full;
|
||||
getdns_list *replies_tree;
|
||||
getdns_list *call_debugging = NULL;
|
||||
getdns_list *call_reporting = NULL;
|
||||
getdns_network_req *netreq, **netreq_p;
|
||||
int rrsigs_in_answer = 0;
|
||||
getdns_dict *reply;
|
||||
|
@ -795,8 +812,8 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
|
|||
if (!(replies_tree = getdns_list_create_with_context(context)))
|
||||
goto error_free_replies_full;
|
||||
|
||||
if (completed_request->return_call_debugging &&
|
||||
!(call_debugging = getdns_list_create_with_context(context)))
|
||||
if (completed_request->return_call_reporting &&
|
||||
!(call_reporting = getdns_list_create_with_context(context)))
|
||||
goto error_free_replies_full;
|
||||
|
||||
for ( netreq_p = completed_request->netreqs
|
||||
|
@ -805,6 +822,9 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
|
|||
if (! netreq->response_len)
|
||||
continue;
|
||||
|
||||
if (netreq->tsig_status == GETDNS_DNSSEC_INSECURE)
|
||||
_getdns_network_validate_tsig(netreq);
|
||||
|
||||
nreplies++;
|
||||
if (netreq->dnssec_status == GETDNS_DNSSEC_SECURE)
|
||||
nsecure++;
|
||||
|
@ -823,6 +843,8 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
|
|||
else if (completed_request->dnssec_return_only_secure
|
||||
&& netreq->dnssec_status != GETDNS_DNSSEC_SECURE)
|
||||
continue;
|
||||
else if (netreq->tsig_status == GETDNS_DNSSEC_BOGUS)
|
||||
continue;
|
||||
}
|
||||
if (!(reply = _getdns_create_reply_dict(context,
|
||||
netreq, just_addrs, &rrsigs_in_answer)))
|
||||
|
@ -850,19 +872,23 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
|
|||
netreq->dnssec_status))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (netreq->tsig_status != GETDNS_DNSSEC_INDETERMINATE) {
|
||||
if (getdns_dict_set_int(reply, "tsig_status",
|
||||
netreq->tsig_status))
|
||||
goto error;
|
||||
}
|
||||
if (_getdns_list_append_dict(replies_tree, reply)) {
|
||||
getdns_dict_destroy(reply);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (call_debugging) {
|
||||
if (call_reporting) {
|
||||
if (!(netreq_debug =
|
||||
_getdns_create_call_debugging_dict(context,netreq)))
|
||||
_getdns_create_call_reporting_dict(context,netreq)))
|
||||
goto error;
|
||||
|
||||
if (_getdns_list_append_dict(
|
||||
call_debugging, netreq_debug)) {
|
||||
call_reporting, netreq_debug)) {
|
||||
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
goto error;
|
||||
|
@ -882,9 +908,9 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
|
|||
goto error;
|
||||
getdns_list_destroy(replies_tree);
|
||||
|
||||
if (call_debugging &&
|
||||
getdns_dict_set_list(result, "call_debugging", call_debugging))
|
||||
goto error_free_call_debugging;
|
||||
if (call_reporting &&
|
||||
getdns_dict_set_list(result, "call_reporting", call_reporting))
|
||||
goto error_free_call_reporting;
|
||||
|
||||
if (getdns_dict_set_list(result, "replies_full", replies_full))
|
||||
goto error_free_replies_full;
|
||||
|
@ -909,8 +935,8 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
|
|||
error:
|
||||
/* cleanup */
|
||||
getdns_list_destroy(replies_tree);
|
||||
error_free_call_debugging:
|
||||
getdns_list_destroy(call_debugging);
|
||||
error_free_call_reporting:
|
||||
getdns_list_destroy(call_reporting);
|
||||
error_free_replies_full:
|
||||
getdns_list_destroy(replies_full);
|
||||
error_free_result:
|
||||
|
|
|
@ -160,55 +160,6 @@ void _getdns_wire2list(uint8_t *pkt, size_t pkt_len, getdns_list *l);
|
|||
*/
|
||||
getdns_return_t _getdns_validate_extensions(struct getdns_dict * extensions);
|
||||
|
||||
#define DEBUG_ON(...) do { \
|
||||
struct timeval tv; \
|
||||
struct tm tm; \
|
||||
char buf[10]; \
|
||||
\
|
||||
gettimeofday(&tv, NULL); \
|
||||
gmtime_r(&tv.tv_sec, &tm); \
|
||||
strftime(buf, 10, "%T", &tm); \
|
||||
fprintf(stderr, "[%s.%.6d] ", buf, (int)tv.tv_usec); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_NL(...) do { \
|
||||
struct timeval tv; \
|
||||
struct tm tm; \
|
||||
char buf[10]; \
|
||||
\
|
||||
gettimeofday(&tv, NULL); \
|
||||
gmtime_r(&tv.tv_sec, &tm); \
|
||||
strftime(buf, 10, "%T", &tm); \
|
||||
fprintf(stderr, "[%s.%.6d] ", buf, (int)tv.tv_usec); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define DEBUG_OFF(...) do {} while (0)
|
||||
|
||||
#if defined(SCHED_DEBUG) && SCHED_DEBUG
|
||||
#include <time.h>
|
||||
#define DEBUG_SCHED(...) DEBUG_ON(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_SCHED(...) DEBUG_OFF(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if defined(STUB_DEBUG) && STUB_DEBUG
|
||||
#include <time.h>
|
||||
#define DEBUG_STUB(...) DEBUG_ON(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_STUB(...) DEBUG_OFF(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if defined(SEC_DEBUG) && SEC_DEBUG
|
||||
#include <time.h>
|
||||
#define DEBUG_SEC(...) DEBUG_ON(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_SEC(...) DEBUG_OFF(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
INLINE getdns_eventloop_event *getdns_eventloop_event_init(
|
||||
getdns_eventloop_event *ev,void *userarg, getdns_eventloop_callback read_cb,
|
||||
getdns_eventloop_callback write_cb, getdns_eventloop_callback timeout_cb)
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#define UTIL_LOG_H
|
||||
|
||||
#include "config.h"
|
||||
#include "util-internal.h"
|
||||
#include "debug.h"
|
||||
|
||||
#if defined(SEC_DEBUG) && SEC_DEBUG
|
||||
#define verbose(x, ...) DEBUG_NL(__VA_ARGS__)
|
||||
|
|
Loading…
Reference in New Issue