Commit 0e447fe0 authored by Alexandre's avatar Alexandre
Browse files

Standalone function for --check option

parent 1cf9f851
......@@ -529,6 +529,32 @@ def get_next_domain(input_file):
(name, rtype) = line.split()
return name, rtype
def run_check(connection):
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:
if dot:
test_name, request = request_pack
else:
test_name, request, method = request_pack
if verbose:
print(test_name)
if not dot:
if method == DOH_POST:
request.post = True
elif method == DOH_HEAD:
request.head = True
try:
connection.send_and_receive(request)
except CustomException as e:
ok = False
error(e)
break
request.check_response()
if not connection.print_result(request.rcode, request.response, request.response_size, prefix=test_name):
ok = False
break
# Main program
me = os.path.basename(sys.argv[0])
monitoring = (me == "check_doh" or me == "check_dot")
......@@ -705,30 +731,7 @@ if not check:
if delay is not None:
time.sleep(delay)
else:
req_args = { 'qname': name, 'qtype': rtype, 'use_edns': edns, 'want_dnssec': dnssec }
requests = create_requests_list(**req_args)
for request_pack in requests:
if dot:
test_name, request = request_pack
else:
test_name, request, method = request_pack
if verbose:
print(test_name)
if not dot:
if method == DOH_POST:
request.post = True
elif method == DOH_HEAD:
request.head = True
try:
conn.send_and_receive(request)
except CustomException as e:
ok = False
error(e)
break
request.check_response()
if not conn.print_result(request.rcode, request.response, request.response_size, prefix=test_name):
ok = False
break
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