]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - contrib/ProtobufLogger.py
auth: Use the correct type while reading from the control channel
[thirdparty/pdns.git] / contrib / ProtobufLogger.py
index c5e5d33cd6d6aef200cdc143ca456c9050d5b2eb..c88653ce799beee38ce4db2b032312970f9eb955 100644 (file)
@@ -111,9 +111,12 @@ class PDNSPBConnHandler(object):
             for rr in response.rrs:
                 rrclass = 1
                 rdatastr = ''
+                rrudr = 0
                 if rr.HasField('class'):
                     rrclass = getattr(rr, 'class')
                 rrtype = rr.type
+                if rr.HasField('udr'):
+                    rrudr = rr.udr
                 if (rrclass == 1 or rrclass == 255) and rr.HasField('rdata'):
                     if rrtype == 1:
                         rdatastr = socket.inet_ntop(socket.AF_INET, rr.rdata)
@@ -122,11 +125,12 @@ class PDNSPBConnHandler(object):
                     elif rrtype == 28:
                         rdatastr = socket.inet_ntop(socket.AF_INET6, rr.rdata)
 
-                print("\t - %d, %d, %s, %d, %s" % (rrclass,
+                print("\t - %d, %d, %s, %d, %s, %d" % (rrclass,
                                                    rrtype,
                                                    rr.name,
                                                    rr.ttl,
-                                                   rdatastr))
+                                                   rdatastr,
+                                                   rrudr))
 
     def printSummary(self, msg, typestr):
         datestr = datetime.datetime.fromtimestamp(msg.timeSec).strftime('%Y-%m-%d %H:%M:%S')
@@ -152,25 +156,41 @@ class PDNSPBConnHandler(object):
             protostr = 'TCP'
 
         messageidstr = binascii.hexlify(bytearray(msg.messageId))
+
+        serveridstr = 'N/A'
+        if msg.HasField('serverIdentity'):
+            serveridstr = msg.serverIdentity
+
         initialrequestidstr = ''
         if msg.HasField('initialRequestId'):
-            initialrequestidstr = ', initial uuid: ' + binascii.hexlify(bytearray(msg.initialRequestId))
+            initialrequestidstr = ', initial uuid: %s ' % (binascii.hexlify(bytearray(msg.initialRequestId)))
 
         requestorstr = ''
         requestor = self.getRequestorSubnet(msg)
         if requestor:
             requestorstr = ' (' + requestor + ')'
 
-        print('[%s] %s of size %d: %s%s -> %s (%s), id: %d, uuid: %s%s' % (datestr,
-                                                                           typestr,
-                                                                           msg.inBytes,
-                                                                           ipfromstr,
-                                                                           requestorstr,
-                                                                           iptostr,
-                                                                           protostr,
-                                                                           msg.id,
-                                                                           messageidstr,
-                                                                           initialrequestidstr))
+        deviceId = binascii.hexlify(bytearray(msg.deviceId))
+        requestorId = msg.requestorId
+        nod = 0
+        if (msg.HasField('newlyObservedDomain')):
+            nod = msg.newlyObservedDomain
+
+        print('[%s] %s of size %d: %s%s -> %s (%s), id: %d, uuid: %s%s '
+                  'requestorid: %s deviceid: %s serverid: %s nod: %d' % (datestr,
+                                                    typestr,
+                                                    msg.inBytes,
+                                                    ipfromstr,
+                                                    requestorstr,
+                                                    iptostr,
+                                                    protostr,
+                                                    msg.id,
+                                                    messageidstr,
+                                                    initialrequestidstr,
+                                                    requestorId,
+                                                    deviceId,
+                                                    serveridstr,
+                                                    nod))
 
     def getRequestorSubnet(self, msg):
         requestorstr = None