if response.HasField('queryTimeSec'):
datestr = datetime.datetime.fromtimestamp(response.queryTimeSec).strftime('%Y-%m-%d %H:%M:%S')
if response.HasField('queryTimeUsec'):
- datestr = datestr + '.' + str(response.queryTimeUsec)
+ datestr = datestr + '.' + ("%06d" % response.queryTimeUsec)
print("- Query time: %s" % (datestr))
policystr = ''
for rr in response.rrs:
rrclass = 1
rdatastr = ''
- rrudr = 0
+ rrudr = 'N/A'
if rr.HasField('class'):
rrclass = getattr(rr, 'class')
rrtype = rr.type
if rr.HasField('udr'):
- rrudr = rr.udr
+ rrudr = str(rr.udr)
if (rrclass == 1 or rrclass == 255) and rr.HasField('rdata'):
if rrtype == 1:
rdatastr = socket.inet_ntop(socket.AF_INET, rr.rdata)
elif rrtype == 28:
rdatastr = socket.inet_ntop(socket.AF_INET6, rr.rdata)
- print("\t - %d, %d, %s, %d, %s, %d" % (rrclass,
+ print("\t - %d, %d, %s, %d, %s, %s" % (rrclass,
rrtype,
rr.name,
rr.ttl,
def printSummary(self, msg, typestr):
datestr = datetime.datetime.fromtimestamp(msg.timeSec).strftime('%Y-%m-%d %H:%M:%S')
if msg.HasField('timeUsec'):
- datestr = datestr + '.' + str(msg.timeUsec)
+ datestr = datestr + '.' + ("%06d" % msg.timeUsec)
ipfromstr = 'N/A'
iptostr = 'N/A'
toportstr = ''
if msg.HasField('requestorId'):
requestorId = msg.requestorId
- nod = 0
+ nod = 'N/A';
if msg.HasField('newlyObservedDomain'):
- nod = msg.newlyObservedDomain
+ nod = str(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 workerId: %s pcCacheHit: %s outgoingQueries: %s' % (datestr,
+ 'requestorid: %s deviceid: %s devicename: %s serverid: %s nod: %s workerId: %s pcCacheHit: %s outgoingQueries: %s' % (datestr,
typestr,
msg.inBytes,
ipfromstr,
#include "rec-protozero.hh"
#include <variant>
-void pdns::ProtoZero::RecMessage::addRR(const DNSRecord& record, const std::set<uint16_t>& exportTypes, [[maybe_unused]] bool udr)
+void pdns::ProtoZero::RecMessage::addRR(const DNSRecord& record, const std::set<uint16_t>& exportTypes, [[maybe_unused]] std::optional<bool> udr)
{
if (record.d_place != DNSResourceRecord::ANSWER || record.d_class != QClass::IN) {
return;
break;
}
#ifdef NOD_ENABLED
- pbf_rr.add_bool(static_cast<protozero::pbf_tag_type>(pdns::ProtoZero::Message::RRField::udr), udr);
- pbf_rr.commit();
+ if (udr) {
+ pbf_rr.add_bool(static_cast<protozero::pbf_tag_type>(pdns::ProtoZero::Message::RRField::udr), *udr);
+ pbf_rr.commit();
- // Save the offset of the byte containing the just added bool. We can do this since
- // we know a bit about how protobuf's encoding works.
- offsets.push_back(d_rspbuf.length() - 1);
+ // Save the offset of the byte containing the just added bool. We can do this since
+ // we know a bit about how protobuf's encoding works.
+ offsets.push_back(d_rspbuf.length() - 1);
+ }
#endif
}