| 114 | getattr(CLASS,qclass))) |
| 115 | |
| 116 | def parseAnswers(self,a,auth,ar,dns): |
| 117 | sect_map = {'a':'add_answer','auth':'add_auth','ar':'add_ar'} |
| 118 | for sect in 'a','auth','ar': |
| 119 | f = getattr(dns,sect_map[sect]) |
| 120 | for rr in locals()[sect]: |
| 121 | rname,ttl,rclass,rtype = rr[:4] |
| 122 | rdata = rr[4:] |
| 123 | rd = RDMAP.get(rtype,RD) |
| 124 | try: |
| 125 | if rd == RD and \ |
| 126 | any([ x not in string.hexdigits for x in rdata[-1]]): |
| 127 | # Only support hex encoded data for fallback RD |
| 128 | pass |
| 129 | else: |
| 130 | f(RR(rname=rname, |
| 131 | ttl=int(ttl), |
| 132 | rtype=getattr(QTYPE,rtype), |
| 133 | rclass=getattr(CLASS,rclass), |
| 134 | rdata=rd.fromZone(rdata))) |
| 135 | except DNSError as e: |
| 136 | if self.debug: |
| 137 | print("DNSError:",e,rr) |
| 138 | else: |
| 139 | # Skip records we dont understand |
| 140 | pass |
| 141 | |
| 142 | def __iter__(self): |
| 143 | return self.parse() |