mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 06:00:42 +01:00
Try all IP addresses of a hostname.
Fixes a regression in ecc2c32950efd0389d9d2c6b37ea7fb2728ab1d1 that caused Socket.py to ignore the IP address entirely after computing it, and to call getSocket() and connect() with the hostname instead.
This commit is contained in:
parent
771c05c666
commit
ba77de0946
@ -267,7 +267,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
|||||||
socks_proxy = ''
|
socks_proxy = ''
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
hostname = utils.net.getAddressFromHostname(
|
address = utils.net.getAddressFromHostname(
|
||||||
self.currentServer.hostname,
|
self.currentServer.hostname,
|
||||||
attempt=self._attempt)
|
attempt=self._attempt)
|
||||||
except (socket.gaierror, socket.error) as e:
|
except (socket.gaierror, socket.error) as e:
|
||||||
@ -277,7 +277,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
|||||||
drivers.log.connect(self.currentServer)
|
drivers.log.connect(self.currentServer)
|
||||||
try:
|
try:
|
||||||
self.conn = utils.net.getSocket(
|
self.conn = utils.net.getSocket(
|
||||||
self.currentServer.hostname,
|
address,
|
||||||
port=self.currentServer.port,
|
port=self.currentServer.port,
|
||||||
socks_proxy=socks_proxy,
|
socks_proxy=socks_proxy,
|
||||||
vhost=conf.supybot.protocols.irc.vhost(),
|
vhost=conf.supybot.protocols.irc.vhost(),
|
||||||
@ -294,20 +294,19 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
|||||||
# Connect before SSL, otherwise SSL is disabled if we use SOCKS.
|
# Connect before SSL, otherwise SSL is disabled if we use SOCKS.
|
||||||
# See http://stackoverflow.com/q/16136916/539465
|
# See http://stackoverflow.com/q/16136916/539465
|
||||||
self.conn.connect(
|
self.conn.connect(
|
||||||
(self.currentServer.hostname, self.currentServer.port))
|
(address, self.currentServer.port))
|
||||||
if network_config.ssl() or \
|
if network_config.ssl() or \
|
||||||
self.currentServer.force_tls_verification:
|
self.currentServer.force_tls_verification:
|
||||||
self.starttls()
|
self.starttls()
|
||||||
|
|
||||||
# Suppress this warning for loopback IPs.
|
# Suppress this warning for loopback IPs.
|
||||||
targetip = hostname
|
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
# Backported Python 2 ipaddress demands unicode instead of str
|
# Backported Python 2 ipaddress demands unicode instead of str
|
||||||
targetip = targetip.decode('utf-8')
|
address = address.decode('utf-8')
|
||||||
elif (not network_config.requireStarttls()) and \
|
elif (not network_config.requireStarttls()) and \
|
||||||
(not network_config.ssl()) and \
|
(not network_config.ssl()) and \
|
||||||
(not self.currentServer.force_tls_verification) and \
|
(not self.currentServer.force_tls_verification) and \
|
||||||
(ipaddress is None or not ipaddress.ip_address(targetip).is_loopback):
|
(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…
x
Reference in New Issue
Block a user