if msg.HasField('newlyObservedDomain'):
nod = msg.newlyObservedDomain
+ workerId = 'N/A'
+ if msg.HasField('workerId'):
+ workerId = str(msg.workerId)
+
+ pcCacheHit = 'N/A'
+ if msg.HasField('packetCacheHit'):
+ pcCacheHit = str(msg.packetCacheHit)
+
+ outgoingQs = 'N/A'
+ if msg.HasField('outgoingQueries'):
+ outgoingQs = str(msg.outgoingQueries)
+
+
print('[%s] %s of size %d: %s%s%s -> %s%s(%s) id: %d uuid: %s%s '
- 'requestorid: %s deviceid: %s devicename: %s serverid: %s nod: %d' % (datestr,
+ 'requestorid: %s deviceid: %s devicename: %s serverid: %s nod: %d workerId: %s pcCacheHit: %s outgoingQueries: %s' % (datestr,
typestr,
msg.inBytes,
ipfromstr,
deviceId,
deviceName,
serveridstr,
- nod))
+ nod,
+ workerId,
+ pcCacheHit,
+ outgoingQs))
for mt in msg.meta:
values = ''
* This file describes the message format used by the protobuf logging feature in PowerDNS and dnsdist.
*
* MIT License
- *
+ *
* Copyright (c) 2016-now PowerDNS.COM B.V. and its contributors.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
optional string custom = 8; // The name of the event for custom events
}
repeated Event trace = 23;
+
optional HTTPVersion httpVersion = 24; // HTTP version used for DNS over HTTP
+ optional uint64 workerId = 25; // Thread id
+ optional bool packetCacheHit = 26; // Was it a packet cache hit?
+ optional uint32 outgoingQueries = 27; // NUmber of outgoing queries used to answer the query
}
message PBDNSMessageList {
enum class MetaField : protozero::pbf_tag_type { key = 1, value = 2 };
enum class Event : protozero::pbf_tag_type { ts = 1, event = 2, start = 3, boolVal = 4, intVal = 5, stringVal = 6, bytesVal = 7, custom = 8 };
enum class MessageType : int32_t { DNSQueryType = 1, DNSResponseType = 2, DNSOutgoingQueryType = 3, DNSIncomingResponseType = 4 };
- enum class Field : protozero::pbf_tag_type { type = 1, messageId = 2, serverIdentity = 3, socketFamily = 4, socketProtocol = 5, from = 6, to = 7, inBytes = 8, timeSec = 9, timeUsec = 10, id = 11, question = 12, response = 13, originalRequestorSubnet = 14, requestorId = 15, initialRequestId = 16, deviceId = 17, newlyObservedDomain = 18, deviceName = 19, fromPort = 20, toPort = 21, meta = 22, trace = 23, httpVersion = 24 };
+ enum class Field : protozero::pbf_tag_type { type = 1, messageId = 2, serverIdentity = 3, socketFamily = 4, socketProtocol = 5, from = 6, to = 7, inBytes = 8, timeSec = 9, timeUsec = 10, id = 11, question = 12, response = 13, originalRequestorSubnet = 14, requestorId = 15, initialRequestId = 16, deviceId = 17, newlyObservedDomain = 18, deviceName = 19, fromPort = 20, toPort = 21, meta = 22, trace = 23, httpVersion = 24, workerId = 25, packetCacheHit = 26, outgoingQueries = 27};
enum class QuestionField : protozero::pbf_tag_type { qName = 1, qType = 2, qClass = 3 };
enum class ResponseField : protozero::pbf_tag_type { rcode = 1, rrs = 2, appliedPolicy = 3, tags = 4, queryTimeSec = 5, queryTimeUsec = 6, appliedPolicyType = 7, appliedPolicyTrigger = 8, appliedPolicyHit = 9, appliedPolicyKind = 10, validationState = 11 };
enum class RRField : protozero::pbf_tag_type { name = 1, type = 2, class_ = 3, ttl = 4, rdata = 5, udr = 6 };
add_uint32(d_message, Field::toPort, port);
}
+ void setWorkerId(uint64_t wid)
+ {
+ add_uint64(d_message, Field::workerId, wid);
+ }
+
+ void setPacketCacheHit(bool hit)
+ {
+ add_bool(d_message, Field::packetCacheHit, hit);
+ }
+
+ void setOutgoingQueries(uint32_t num)
+ {
+ add_uint32(d_message, Field::outgoingQueries, num);
+ }
+
void startResponse()
{
d_response = protozero::pbf_writer{d_message, static_cast<protozero::pbf_tag_type>(Field::response)};
pbMessage.setDeviceName(dnsQuestion.deviceName);
pbMessage.setToPort(comboWriter->d_destination.getPort());
pbMessage.addPolicyTags(comboWriter->d_gettagPolicyTags);
-
+ pbMessage.setWorkerId(RecThreadInfo::id());
+ pbMessage.setPacketCacheHit(false);
+ pbMessage.setOutgoingQueries(resolver.d_outqueries);
for (const auto& metaValue : dnsQuestion.meta) {
pbMessage.setMeta(metaValue.first, metaValue.second.stringVal, metaValue.second.intVal);
}
msg.setRequestorId(requestorId);
msg.setDeviceId(deviceId);
msg.setDeviceName(deviceName);
+ msg.setWorkerId(RecThreadInfo::id());
+ // For queries, packetCacheHit and outgoingQueries are not relevant
if (!policyTags.empty()) {
msg.addPolicyTags(policyTags);
pbMessage.setDeviceId(deviceId);
pbMessage.setDeviceName(deviceName);
pbMessage.setToPort(destination.getPort());
+ pbMessage.setWorkerId(RecThreadInfo::id());
+ // this method is only used for PC cache hits
+ pbMessage.setPacketCacheHit(true);
+ // we do not set outgoingQueries, it is not relevant for PC cache hits
+
for (const auto& metaItem : meta) {
pbMessage.setMeta(metaItem.first, metaItem.second.stringVal, metaItem.second.intVal);
}
# because it doesn't keep the information around.
self.assertTrue(msg.HasField('to'))
self.assertEqual(socket.inet_ntop(socket.AF_INET, msg.to), to)
+ self.assertTrue(msg.HasField('workerId'))
self.assertTrue(msg.HasField('question'))
self.assertTrue(msg.question.HasField('qClass'))
self.assertEqual(msg.question.qClass, qclass)
def checkProtobufResponse(self, msg, protocol, response, initiator='127.0.0.1', receivedSize=None, vstate=dnsmessage_pb2.PBDNSMessage.VState.Indeterminate):
self.assertEqual(msg.type, dnsmessage_pb2.PBDNSMessage.DNSResponseType)
self.checkProtobufBase(msg, protocol, response, initiator, receivedSize=receivedSize)
+ self.assertTrue(msg.HasField('workerId'))
+ self.assertTrue(msg.HasField('packetCacheHit'))
self.assertTrue(msg.HasField('response'))
self.assertTrue(msg.response.HasField('queryTimeSec'))
self.assertTrue(msg.response.HasField('validationState'))