]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Export the outgoing ECS value if any in our protobuf messages
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 27 Sep 2018 14:45:03 +0000 (16:45 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 31 Oct 2018 15:07:01 +0000 (16:07 +0100)
(cherry picked from commit 0ff13512cb8a48f668d841e5f33ba1b48fb99a2a)

pdns/lwres.cc

index fd07f4b8944c0e61cf93a9051ee4f069362021a3..58e605d9d772f0fa9a23b9efc07370d63e017be8 100644 (file)
@@ -50,7 +50,7 @@
 
 #ifdef HAVE_PROTOBUF
 
-static void logOutgoingQuery(std::shared_ptr<RemoteLogger> outgoingLogger, boost::optional<const boost::uuids::uuid&> initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes)
+static void logOutgoingQuery(std::shared_ptr<RemoteLogger> outgoingLogger, boost::optional<const boost::uuids::uuid&> initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, boost::optional<Netmask>& srcmask)
 {
   if(!outgoingLogger)
     return;
@@ -60,6 +60,10 @@ static void logOutgoingQuery(std::shared_ptr<RemoteLogger> outgoingLogger, boost
     message.setInitialRequestID(*initialRequestId);
   }
 
+  if (srcmask) {
+    message.setEDNSSubnet(*srcmask);
+  }
+
 //  cerr <<message.toDebugString()<<endl;
   std::string str;
   message.serialize(str);
@@ -133,7 +137,6 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d
     pw.addOpt(g_outgoingEDNSBufsize, 0, g_dnssecmode == DNSSECMode::Off ? 0 : EDNSOpts::DNSSECOK, opts); 
     pw.commit();
   }
-  srcmask = boost::none; // this is also our return value, even if EDNS0Level == 0
   lwr->d_rcode = 0;
   lwr->d_haveEDNS = false;
   int ret;
@@ -148,10 +151,12 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d
 
   if (outgoingLogger) {
     uuid = (*t_uuidGenerator)();
-    logOutgoingQuery(outgoingLogger, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, vpacket.size());
+    logOutgoingQuery(outgoingLogger, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, vpacket.size(), srcmask);
   }
 #endif
 
+  srcmask = boost::none; // this is also our return value, even if EDNS0Level == 0
+
   errno=0;
   if(!doTCP) {
     int queryfd;