Commit 17890fbd authored by Alexandre's avatar Alexandre
Browse files

Instantiates the Request outside from do_test

parent 5e16e844
......@@ -313,8 +313,8 @@ class Connection:
def __str__(self):
return self.server
def do_test(self, qname, qtype=rtype, synchronous=True):
# Routine doing one actual test. Returns a Request object
def do_test(self, request):
# Routine doing one actual test. Returns nothing
pass
......@@ -427,12 +427,9 @@ class ConnectionDoT(Connection):
self.send_data(request.data)
self.receive_data(request)
def do_test(self, qname, qtype=rtype, synchronous=True):
request = RequestDoT(qname, qtype, want_dnssec=dnssec, use_edns=edns)
request.to_wire()
def do_test(self, request, synchronous=True):
self.send_and_receive(request)
request.check_response()
return request
class CurlHandle():
......@@ -584,11 +581,7 @@ class ConnectionDoH(Connection):
self.send(request)
self.receive(request)
def do_test(self, qname, qtype=rtype, synchronous=True):
request = RequestDoH(qname, qtype, want_dnssec=dnssec, use_edns=edns)
request.head = head
request.post = post
request.to_wire()
def do_test(self, request, synchronous=True):
if synchronous:
request.handle = self.curl_handle
else:
......@@ -599,7 +592,6 @@ class ConnectionDoH(Connection):
request.check_response()
else:
self.multi.add_handle(request.handle.handle)
return request
def get_next_domain(input_file):
......@@ -665,11 +657,11 @@ def read_results(connection, pending_requests):
request.check_response()
return pending_requests
def create_request(dot=dot, trunc=False, **req_args):
def create_request(qname, qtype=rtype, use_edns=edns, want_dnssec=dnssec, dot=dot, trunc=False):
if dot:
request = RequestDoT(**req_args)
request = RequestDoT(qname, rtype, use_edns, want_dnssec)
else:
request = RequestDoH(**req_args)
request = RequestDoH(qname, rtype, use_edns, want_dnssec)
if trunc:
request.trunc_data()
else:
......@@ -1054,8 +1046,12 @@ for connectTo in ip_set:
print("\nTest %i" % i)
if ifile is not None:
name, rtype = get_next_domain(input)
request = create_request(name, qtype=rtype, use_edns=edns, want_dnssec=dnssec, dot=dot)
if not dot:
request.head = head
request.post = post
try:
request = conn.do_test(name, rtype, synchronous = not multistreams)
conn.do_test(request, synchronous = not multistreams)
except (OpenSSL.SSL.Error, CustomException) as e:
ok = False
error(e)
......
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