If a server has a hostname that's not an IP, use it as SNI server name
This commit is contained in:
parent
bf3986a1be
commit
1895ac34d7
2 changed files with 14 additions and 2 deletions
|
@ -97,7 +97,12 @@ class Server(IRCObject.Object):
|
||||||
if client_certificate and client_key:
|
if client_certificate and client_key:
|
||||||
context.load_cert_chain(client_certificate, keyfile=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):
|
def connect(self):
|
||||||
ipv4 = self.connection_params.ipv4
|
ipv4 = self.connection_params.ipv4
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import decimal, io, re, typing
|
import decimal, io, ipaddress, re, typing
|
||||||
from src.utils import cli, consts, irc, http, parse
|
from src.utils import cli, consts, irc, http, parse
|
||||||
|
|
||||||
TIME_SECOND = 1
|
TIME_SECOND = 1
|
||||||
|
@ -179,3 +179,10 @@ class CaseInsensitiveDict(dict):
|
||||||
return dict.__getitem__(self, key.lower())
|
return dict.__getitem__(self, key.lower())
|
||||||
def __setitem__(self, key: str, value: typing.Any) -> typing.Any:
|
def __setitem__(self, key: str, value: typing.Any) -> typing.Any:
|
||||||
return dict.__setitem__(self, key.lower(), value)
|
return dict.__setitem__(self, key.lower(), value)
|
||||||
|
|
||||||
|
def is_ip(s: str) -> bool:
|
||||||
|
try:
|
||||||
|
ipaddress.ip_address(s)
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
Loading…
Reference in a new issue