Commit 79277ef7 authored by Alexandre's avatar Alexandre
Browse files

Remove global scope to ECS option

parent e015e48a
......@@ -290,8 +290,8 @@ class CustomException(Exception):
pass
class Request:
def __init__(self, qname, qtype='AAAA', use_edns=True, want_dnssec=False):
if opts.no_ecs:
def __init__(self, qname, qtype='AAAA', use_edns=True, want_dnssec=False, no_ecs=True):
if no_ecs:
opt = dns.edns.ECSOption(address='', srclen=0) # Disable ECS (RFC 7871, section 7.1.2)
options = [opt]
else:
......@@ -334,8 +334,8 @@ class RequestDoT(Request):
class RequestDoH(Request):
def __init__(self, qname, qtype='AAAA', use_edns=True, want_dnssec=False):
Request.__init__(self, qname, qtype=qtype, use_edns=use_edns, want_dnssec=want_dnssec)
def __init__(self, qname, qtype='AAAA', use_edns=True, want_dnssec=False, no_ecs=True):
Request.__init__(self, qname, qtype=qtype, use_edns=use_edns, want_dnssec=want_dnssec, no_ecs=no_ecs)
self.message.id = 0 # DoH requests that
self.post = False
self.head = False
......@@ -857,11 +857,11 @@ def print_result(connection, request, prefix=None, display_err=True):
ok = False
return ok
def create_request(qname, qtype='AAAA', use_edns=True, want_dnssec=False, dot=False, trunc=False):
def create_request(qname, qtype='AAAA', use_edns=True, want_dnssec=False, no_ecs=True, dot=False, trunc=False):
if dot:
request = RequestDoT(qname, qtype, use_edns, want_dnssec)
request = RequestDoT(qname, qtype, use_edns, want_dnssec, no_ecs)
else:
request = RequestDoH(qname, qtype, use_edns, want_dnssec)
request = RequestDoH(qname, qtype, use_edns, want_dnssec, no_ecs)
if trunc:
request.trunc_data()
else:
......@@ -890,7 +890,7 @@ def create_requests_list(dot=False, **req_args):
def run_check_default(connection):
ok = True
req_args = { 'qname': name, 'qtype': opts.rtype, 'use_edns': opts.edns, 'want_dnssec': opts.dnssec }
req_args = { 'qname': name, 'qtype': opts.rtype, 'use_edns': opts.edns, 'want_dnssec': opts.dnssec, 'no_ecs': opts.no_ecs}
requests = create_requests_list(dot=connection.dot, **req_args)
for request_pack in requests:
if connection.dot:
......@@ -938,7 +938,7 @@ def run_check_mime(connection, accept="application/dns-message", content_type="a
if connection.verbose:
test_name = f'Test mime: {", ".join(h for h in header)}'
print(test_name)
req_args = { 'qname': name, 'qtype': opts.rtype, 'use_edns': opts.edns, 'want_dnssec': opts.dnssec }
req_args = { 'qname': name, 'qtype': opts.rtype, 'use_edns': opts.edns, 'want_dnssec': opts.dnssec, 'no_ecs': opts.no_ecs}
request = create_request(**req_args)
handle = connection.curl_handle
handle.setopt(pycurl.HTTPHEADER, header)
......@@ -967,7 +967,7 @@ def run_check_trunc(connection):
test_name = 'Test truncated data'
if opts.verbose:
print(test_name)
req_args = { 'qname': name, 'qtype': opts.rtype, 'use_edns': opts.edns, 'want_dnssec': opts.dnssec }
req_args = { 'qname': name, 'qtype': opts.rtype, 'use_edns': opts.edns, 'want_dnssec': opts.dnssec, 'no_ecs': opts.no_ecs}
if connection.dot:
request = create_request(dot=connection.dot, trunc=True, **req_args)
bundle = request
......@@ -1321,7 +1321,7 @@ for opts.connectTo in ip_set:
name, rtype = get_next_domain(input)
else:
name, rtype = name, opts.rtype
request = create_request(name, qtype=rtype, use_edns=opts.edns, want_dnssec=opts.dnssec, dot=opts.dot)
request = create_request(name, qtype=rtype, use_edns=opts.edns, want_dnssec=opts.dnssec, no_ecs=opts.no_ecs, dot=opts.dot)
request.i = i
if not opts.dot:
request.head = opts.head
......
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