From 0ff13512cb8a48f668d841e5f33ba1b48fb99a2a Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 27 Sep 2018 16:45:03 +0200 Subject: [PATCH] rec: Export the outgoing ECS value if any in our protobuf messages --- pdns/lwres.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pdns/lwres.cc b/pdns/lwres.cc index ba0c3322a..a0f97902b 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -50,7 +50,7 @@ #ifdef HAVE_PROTOBUF -static void logOutgoingQuery(std::shared_ptr outgoingLogger, boost::optional 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 outgoingLogger, boost::optional initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, boost::optional& srcmask) { if(!outgoingLogger) return; @@ -60,6 +60,10 @@ static void logOutgoingQuery(std::shared_ptr outgoingLogger, boost message.setInitialRequestID(*initialRequestId); } + if (srcmask) { + message.setEDNSSubnet(*srcmask); + } + // cerr <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; -- 2.40.0