Commit d0836940 authored by Alexandre's avatar Alexandre
Browse files

Remove hard coded DoT and DoH port values

parent 7e72380f
......@@ -638,12 +638,12 @@ if not opts.check or opts.connectTo is not None:
ip_set = {opts.connectTo, }
else:
if opts.dot:
port = 853
port = homer.PORT_DOT
if not homer.is_valid_hostname(url):
error("DoT requires a host name or IP address, not \"%s\"" % url)
netloc = url
else:
port = 443
port = homer.PORT_DOH
if not homer.is_valid_url(url):
error("DoH requires a valid HTTPS URL, not \"%s\"" % url)
try:
......
......@@ -27,6 +27,9 @@ from .exceptions import RequestDOTException
from .exceptions import PipeliningException
from .exceptions import DOHException
PORT_DOT = 853
PORT_DOH = 443
TIMEOUT_CONN = 2
TIMEOUT_READ = 1
SLEEP_TIMEOUT = 0.5
......
......@@ -105,7 +105,7 @@ class ConnectionDOT(Connection):
addr = self.server # otherwise keep the server name
family = homer.get_addrfamily(addr, forceIPv4=self.forceIPv4, forceIPv6=self.forceIPv6)
addrinfo_list = socket.getaddrinfo(addr, 853, family)
addrinfo_list = socket.getaddrinfo(addr, homer.PORT_DOT, family)
addrinfo_set = { (addrinfo[4], addrinfo[0]) for addrinfo in addrinfo_list }
signal.signal(signal.SIGALRM, homer.exceptions.timeout_connection)
......@@ -336,7 +336,7 @@ def create_handle(connection):
if connection.forceIPv6:
handle.setopt(pycurl.IPRESOLVE, pycurl.IPRESOLVE_V6)
if connection.connect_to is not None:
handle.setopt(pycurl.CONNECT_TO, ["::[%s]:443" % connection.connect_to,])
handle.setopt(pycurl.CONNECT_TO, ["::[%s]:%d" % (connection.connect_to, homer.PORT_DOH),])
handle.setopt(pycurl.HTTPHEADER,
["Accept: application/dns-message", "Content-type: application/dns-message"])
handle.reset_opt_default = reset_opt_default
......
Markdown is supported
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