Commit 22ca31ec authored by Alexandre's avatar Alexandre
Browse files

Remove represented address

parent 0444f1bf
......@@ -280,18 +280,8 @@ def get_addrfamily(addr, dot=False):
return family
def get_repraddr(ipaddr, sfamily):
if sfamily == socket.AF_INET6:
return ("[%s]" % ipaddr)
return ipaddr
def check_ip_address(addr, dot=False):
family = get_addrfamily(addr, dot)
if not dot:
repraddress = get_repraddr(addr, family)
else:
repraddress = addr
return (family, repraddress)
return get_addrfamily(addr, dot)
def dump_data(data, text="data"):
pref = ' ' * (len(text) - 4)
......@@ -449,7 +439,7 @@ class ConnectionDoT(Connection):
else:
addr = self.server
self.pipelining = pipelining
self.family, self.repraddress = check_ip_address(self.server, dot=True)
self.family = check_ip_address(self.server, dot=True)
addrinfo_list = socket.getaddrinfo(addr, 853, self.family)
addrinfo_set = { (addrinfo[4], addrinfo[0]) for addrinfo in addrinfo_list }
signal.signal(signal.SIGALRM, timeout_connection)
......@@ -667,9 +657,8 @@ def create_handle(connection):
handle.setopt(pycurl.IPRESOLVE, pycurl.IPRESOLVE_V4)
if connection.forceIPv6:
handle.setopt(pycurl.IPRESOLVE, pycurl.IPRESOLVE_V6)
if connection.connect is not None:
family, repraddress = check_ip_address(connection.connect, dot=False)
handle.setopt(pycurl.CONNECT_TO, [f'::{repraddress}:443',])
if connection.connect_to is not None:
handle.setopt(pycurl.CONNECT_TO, ["::[%s]:443" % connection.connect_to,])
handle.setopt(pycurl.HTTPHEADER,
["Accept: application/dns-message", "Content-type: application/dns-message"])
handle.reset_opt_default = reset_opt_default
......@@ -684,8 +673,13 @@ class ConnectionDoH(Connection):
forceIPv4=forceIPv4, forceIPv6=forceIPv6, dot=False,
verbose=verbose, debug=debug, insecure=insecure)
self.url = server
self.connect = connect
self.multistreams = multistreams
# temporary tweak to check that the ip family is coherent with
# user choice on forced IP
if self.connect_to:
check_ip_address(self.connect_to)
if self.multistreams:
self.multi = self.create_multi()
self.all_handles = []
......
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