Commit a4a95090 authored by Alexandre's avatar Alexandre
Browse files

Store status in request object

parent 05a7af5d
......@@ -204,6 +204,7 @@ class Request:
def __init__(self, qname, qtype=rtype, use_edns=edns, want_dnssec=dnssec):
self.message = dns.message.make_query(qname, dns.rdatatype.from_text(qtype), use_edns=use_edns, want_dnssec=want_dnssec)
self.message.flags |= dns.flags.AD # Ask for validation
self.ok = True
def to_wire(self):
self.data = self.message.to_wire()
......@@ -223,7 +224,7 @@ class RequestDoH(Request):
self.head = False
def check_response(self):
ok = True
ok = self.ok
if self.rcode == 200:
if self.ctype != "application/dns-message":
self.response = "Content type of the response (\"%s\") invalid" % self.ctype
......@@ -252,6 +253,7 @@ class RequestDoH(Request):
self.response = "[No details]"
else:
self.response = self.body
self.ok = ok
return ok
......@@ -497,7 +499,7 @@ def get_next_domain(input_file):
return name, rtype
def print_result(connection, request, prefix=None):
ok = True
ok = request.ok
dot = connection.dot
server = connection.server
rcode = request.rcode
......@@ -536,6 +538,7 @@ def print_result(connection, request, prefix=None):
def run_check(connection):
ok = True
req_args = { 'qname': name, 'qtype': rtype, 'use_edns': edns, 'want_dnssec': dnssec }
requests = create_requests_list(dot=dot, **req_args)
for request_pack in requests:
......@@ -560,6 +563,7 @@ def run_check(connection):
if not print_result(connection, request, prefix=test_name):
ok = False
break
return ok
# Main program
me = os.path.basename(sys.argv[0])
......@@ -737,7 +741,7 @@ if not check:
if delay is not None:
time.sleep(delay)
else:
run_check(conn)
ok = run_check(conn)
stop = time.time()
if tests > 1:
extra = ", %.2f ms/request if we ignore the first one" % ((stop-start2)*1000/(tests-1))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment