]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
allow building sdig without doh support 7832/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 21 May 2019 08:30:23 +0000 (10:30 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 4 Jun 2019 13:46:16 +0000 (15:46 +0200)
m4/pdns_check_libcurl.m4
pdns/Makefile.am
pdns/sdig.cc

index c85ed123df1e764086a50c49b60886ee5b52cc92..43412decaf27a5c93f803af4c0fa8e50749322d1 100644 (file)
@@ -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"])
 ])
index b8ef5d4973763a67f921f8f59cb745fe2be7f8b8..edf380e967554e8ce17a4f09c6742f5808e857e2 100644 (file)
@@ -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 \
index 7fc65f7f317b9a867f5189d75641327e79f08a0a..c3853cd7e60b4a841cd8cab8d7e5456ede712481 100644 (file)
 #include "statbag.hh"
 #include <boost/array.hpp>
 #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);