diff --git a/src/IRCServer.py b/src/IRCServer.py index 65beb09b..631092dc 100644 --- a/src/IRCServer.py +++ b/src/IRCServer.py @@ -97,7 +97,12 @@ class Server(IRCObject.Object): if client_certificate and client_key: context.load_cert_chain(client_certificate, keyfile=client_key) - self.socket = context.wrap_socket(self.socket) + server_hostname = None + if not utils.is_ip(self.connection_params.hostname): + server_hostname = self.connection_params.hostname + + self.socket = context.wrap_socket(self.socket, + server_hostname=server_hostname) def connect(self): ipv4 = self.connection_params.ipv4 diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 5267b79f..d76f020f 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -1,4 +1,4 @@ -import decimal, io, re, typing +import decimal, io, ipaddress, re, typing from src.utils import cli, consts, irc, http, parse TIME_SECOND = 1 @@ -179,3 +179,10 @@ class CaseInsensitiveDict(dict): return dict.__getitem__(self, key.lower()) def __setitem__(self, key: str, value: typing.Any) -> typing.Any: return dict.__setitem__(self, key.lower(), value) + +def is_ip(s: str) -> bool: + try: + ipaddress.ip_address(s) + except ValueError: + return False + return True