]> granicus.if.org Git - pdns/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>
Fri, 28 Sep 2018 14:10:50 +0000 (16:10 +0200)
pdns/lwres.cc

index ba0c3322a6d3a4f3796c4f08d1d0c18d71104737..a0f97902b66e5085da5e17e482358c4d5959448a 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);
@@ -134,7 +138,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;
@@ -149,10 +152,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;