original_docstring: Analyze a packet with a DNS record
docstring: Analyze a packet with a DNS record
docstring_tokens: Analyze a packet with a DNS record
code: def analyze_dns_record(self, dns_record):
          """Analyze a packet with a DNS record"""
          dns_type = dns_record.get_field('type').i2repr(dns_record, dns_record.type)
          rrname = dns_record.rrname.decode('utf-8', errors='replace')
          if dns_type == 'A':
              self.ipaddrdb.add_name(dns_record.rdata, rrname)
              return
          if dns_type == 'AAAA':
              self.ipaddrdb.add_name(dns_record.rdata, rrname)
              return
          if dns_type == 'PTR':
              if rrname.endswith(('._tcp.local.', '._udp.local.')):
                  return
              match = re.match(r'^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.in-addr\.arpa\.$', rrname, re.I)
              if match:
                  ip_addr = '.'.join(match.groups()[::-1])
                  self.ipaddrdb.add_name(ip_addr, dns_record.rdata.decode('utf-8'))
                  return
              match = re.match(r'^' + (r'([0-9a-f])\.' * 32) + r'ip6\.arpa\.$', rrname, re.I)
              if match:
                  bin_ipv6 = binascii.unhexlify(''.join(match.groups()[::-1]))
                  ip_addr = socket.inet_ntop(socket.AF_INET6, bin_ipv6)
                  self.ipaddrdb.add_name(ip_addr, dns_record.rdata.decode('utf-8'))
                  return
          if dns_type in ('DNSKEY', 'DS', 'RRSIG'):  # Ignore DNSSEC records
              return
          if dns_type in ('TKEY', 'TSIG'):  # Ignore DNS transfers and updates
              return
          if dns_type in ('NS', 'SOA'):  # Ignore DNS infrastructure records
              return
          if dns_type in ('CNAME', 'HINFO', 'MX', 'SRV', 'SSHFP', 'TXT'):
              return
  
          logger.warning("Unknown DNS packet type %r for %r: %r", dns_type, rrname, dns_record)
code_tokens: def analyze_dns_record ( self , dns_record ) : dns_type = dns_record . get_field ( 'type' ) . i2repr ( dns_record , dns_record . type ) rrname = dns_record . rrname . decode ( 'utf-8' , errors = 'replace' ) if dns_type == 'A' : self . ipaddrdb . add_name ( dns_record . rdata , rrname ) return if dns_type == 'AAAA' : self . ipaddrdb . add_name ( dns_record . rdata , rrname ) return if dns_type == 'PTR' : if rrname . endswith ( ( '._tcp.local.' , '._udp.local.' ) ) : return match = re . match ( r'^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.in-addr\.arpa\.$' , rrname , re . I ) if match : ip_addr = '.' . join ( match . groups ( ) [ : : - 1 ] ) self . ipaddrdb . add_name ( ip_addr , dns_record . rdata . decode ( 'utf-8' ) ) return match = re . match ( r'^' + ( r'([0-9a-f])\.' * 32 ) + r'ip6\.arpa\.$' , rrname , re . I ) if match : bin_ipv6 = binascii . unhexlify ( '' . join ( match . groups ( ) [ : : - 1 ] ) ) ip_addr = socket . inet_ntop ( socket . AF_INET6 , bin_ipv6 ) self . ipaddrdb . add_name ( ip_addr , dns_record . rdata . decode ( 'utf-8' ) ) return if dns_type in ( 'DNSKEY' , 'DS' , 'RRSIG' ) : return if dns_type in ( 'TKEY' , 'TSIG' ) : return if dns_type in ( 'NS' , 'SOA' ) : return if dns_type in ( 'CNAME' , 'HINFO' , 'MX' , 'SRV' , 'SSHFP' , 'TXT' ) : return logger . warning ( "Unknown DNS packet type %r for %r: %r" , dns_type , rrname , dns_record )
short_docstring: Analyze a packet with a DNS record
short_docstring_tokens: Analyze a packet with a DNS record
comment: """Analyze a packet with a DNS record"""$SEP$# Ignore DNSSEC records$SEP$# Ignore DNS transfers and updates$SEP$# Ignore DNS infrastructure records