def _edns_check(self, opt_record): """ Checks request EDNS record for compliance with EDNS0. :param opt_record: OPT Record to check. :return: Whether the request is valid and a corresponding OPT RR. """ flags = "do" if opt_record.edns_do else "" if opt_record.edns_ver != 0: opt = dnslib.EDNS0( version=0, ext_rcode=1, flags=flags, udp_len=opt_record.edns_len, ) return False, opt return True, dnslib.EDNS0(version=0, ext_rcode=0, flags=flags, udp_len=opt_record.edns_len)
qtype = qtypes.pop() query_data = get_wire() else: break if ok: mark_good_doh(server) if not qtypes: break else: mark_bad_doh(server) if xips: iplist.xip = xips return iplist remote_query_opt = dnslib.EDNS0(flags='do', udp_len=1024) # 1232 bv4_remote = 1 << 0 bv6_remote = 1 << 1 bv4_local = 1 << 2 bv6_local = 1 << 3 allresolved = (1 << 4) - 1 polluted_hosts = set() def check_edns_opt(ar): if len(ar) > 1: return True for r in ar: return r.rtype is OPT and r.edns_do