mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
Socket: suppress "not using TLS" errors on loopback addresses
This is a refined version of #1317.
This commit is contained in:
parent
36309ad1dc
commit
91a38887a2
@ -40,6 +40,12 @@ import errno
|
|||||||
import select
|
import select
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
try:
|
||||||
|
import ipaddress
|
||||||
|
except ImportError:
|
||||||
|
# Python < 3.3
|
||||||
|
ipaddress = None
|
||||||
|
|
||||||
from .. import (conf, drivers, log, utils, world)
|
from .. import (conf, drivers, log, utils, world)
|
||||||
from ..utils import minisix
|
from ..utils import minisix
|
||||||
from ..utils.str import decode_raw_line
|
from ..utils.str import decode_raw_line
|
||||||
@ -53,7 +59,6 @@ except:
|
|||||||
class SSLError(Exception):
|
class SSLError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
||||||
_instances = []
|
_instances = []
|
||||||
_selecting = [False] # We want it to be mutable.
|
_selecting = [False] # We want it to be mutable.
|
||||||
@ -279,7 +284,9 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
|||||||
self.conn.connect((address, port))
|
self.conn.connect((address, port))
|
||||||
if network_config.ssl():
|
if network_config.ssl():
|
||||||
self.starttls()
|
self.starttls()
|
||||||
elif not network_config.requireStarttls():
|
elif (not network_config.requireStarttls()) and \
|
||||||
|
# Suppress this warning for loopback IPs.
|
||||||
|
(ipaddress is None or not ipaddress.ip_address(address).is_loopback):
|
||||||
drivers.log.warning(('Connection to network %s '
|
drivers.log.warning(('Connection to network %s '
|
||||||
'does not use SSL/TLS, which makes it vulnerable to '
|
'does not use SSL/TLS, which makes it vulnerable to '
|
||||||
'man-in-the-middle attacks and passive eavesdropping. '
|
'man-in-the-middle attacks and passive eavesdropping. '
|
||||||
|
Loading…
Reference in New Issue
Block a user