Commit 374c47c3 authored by Alexandre's avatar Alexandre
Browse files

Raise exception on connection error

parent 79277ef7
......@@ -386,12 +386,16 @@ class RequestDoH(Request):
class Connection:
def __init__(self, server, servername=None, connect=None, forceIPv4=False, forceIPv6=False,
dot=False, verbose=False, debug=False, insecure=False):
if dot and not is_valid_hostname(server):
error("DoT requires a host name or IP address, not \"%s\"" % server)
raise CustomException("DoT requires a host name or IP address, not \"%s\"" % server)
if not dot and not is_valid_url(server):
error("DoH requires a valid HTTPS URL, not \"%s\"" % server)
raise CustomException("DoH requires a valid HTTPS URL, not \"%s\"" % server)
if forceIPv4 and forceIPv6:
raise CustomException("Force IPv4 *or* IPv6 but not both")
self.dot = dot
self.server = server
self.servername = servername
......@@ -399,7 +403,6 @@ class Connection:
self.check_name_cert = self.servername
else:
self.check_name_cert = self.server
self.dot = dot
self.verbose = verbose
self.debug = debug
self.insecure = insecure
......
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