From: Peter van Dijk Date: Tue, 21 May 2019 08:30:23 +0000 (+0200) Subject: allow building sdig without doh support X-Git-Tag: dnsdist-1.4.0-beta1~3^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f33f80ba602878188091bf1114898de8df7d15d6;p=thirdparty%2Fpdns.git allow building sdig without doh support --- diff --git a/m4/pdns_check_libcurl.m4 b/m4/pdns_check_libcurl.m4 index c85ed123df..43412decaf 100644 --- a/m4/pdns_check_libcurl.m4 +++ b/m4/pdns_check_libcurl.m4 @@ -2,4 +2,5 @@ AC_DEFUN([PDNS_CHECK_LIBCURL], [ AS_IF([test -n "$HAVE_LIBCURL"], [ : ], [ LIBCURL_CHECK_CONFIG("yes", "7.21.3", [ HAVE_LIBCURL=y ], [ HAVE_LIBCURL=n ]) ]) + AM_CONDITIONAL([HAVE_LIBCURL], [test "$HAVE_LIBCURL" = "y"]) ]) diff --git a/pdns/Makefile.am b/pdns/Makefile.am index b8ef5d4973..edf380e967 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -498,12 +498,16 @@ sdig_SOURCES = \ sillyrecords.cc \ sstuff.hh \ statbag.cc \ - unix_utility.cc \ - minicurl.cc minicurl.hh + unix_utility.cc -sdig_LDADD = $(LIBCRYPTO_LIBS) $(LIBCURL) +sdig_LDADD = $(LIBCRYPTO_LIBS) sdig_LDFLAGS = $(AM_LDFLAGS) $(LIBCRYPTO_LDFLAGS) +if HAVE_LIBCURL +sdig_SOURCES += minicurl.cc minicurl.hh +sdig_LDADD += $(LIBCURL) +endif + calidns_SOURCES = \ base32.cc \ base64.cc base64.hh \ diff --git a/pdns/sdig.cc b/pdns/sdig.cc index 7fc65f7f31..c3853cd7e6 100644 --- a/pdns/sdig.cc +++ b/pdns/sdig.cc @@ -10,7 +10,11 @@ #include "statbag.hh" #include #include "ednssubnet.hh" + +#ifdef HAVE_LIBCURL #include "minicurl.hh" +#endif + StatBag S; bool hidettl=false; @@ -153,17 +157,23 @@ try string reply; string question(packet.begin(), packet.end()); ComboAddress dest; - if(*argv[1]=='h') + if(*argv[1]=='h') { doh = true; - else + } + else { dest = ComboAddress(argv[1] + (*argv[1]=='@'), atoi(argv[2])); + } if(doh) { +#ifdef HAVE_LIBCURL MiniCurl mc; MiniCurl::MiniCurlHeaders mch; mch.insert(std::make_pair("Content-Type", "application/dns-message")); mch.insert(std::make_pair("Accept", "application/dns-message")); reply = mc.postURL(argv[1], question, mch); +#else + throw PDNSException("please link sdig against libcurl for DoH support"); +#endif } else if(tcp) { Socket sock(dest.sin4.sin_family, SOCK_STREAM);