log ip, if available, when connection fails (mostly for tls)
This commit is contained in:
parent
32e1e40cd2
commit
2d6efc4975
2 changed files with 8 additions and 3 deletions
|
@ -204,8 +204,12 @@ class Bot(object):
|
||||||
try:
|
try:
|
||||||
server.connect()
|
server.connect()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.warn("Failed to connect to %s: %s",
|
ip = ""
|
||||||
[str(server), str(e)])
|
if server.socket.connected_ip is not None:
|
||||||
|
ip = f" ({server.socket.connected_ip})"
|
||||||
|
|
||||||
|
self.log.warn("Failed to connect to %s%s: %s",
|
||||||
|
[str(server), ip, str(e)])
|
||||||
self.log.debug("Connection failure reason:", exc_info=True)
|
self.log.debug("Connection failure reason:", exc_info=True)
|
||||||
return False
|
return False
|
||||||
self.servers[server.fileno()] = server
|
self.servers[server.fileno()] = server
|
||||||
|
|
|
@ -69,11 +69,12 @@ class Socket(IRCObject.Object):
|
||||||
5.0)
|
5.0)
|
||||||
self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||||
|
|
||||||
|
self.connected_ip = self._socket.getpeername()[0]
|
||||||
|
|
||||||
if self._tls:
|
if self._tls:
|
||||||
self._tls_wrap()
|
self._tls_wrap()
|
||||||
|
|
||||||
self.connect_time = time.time()
|
self.connect_time = time.time()
|
||||||
self.connected_ip = self._socket.getpeername()[0]
|
|
||||||
self.cached_fileno = self._socket.fileno()
|
self.cached_fileno = self._socket.fileno()
|
||||||
self.connected = True
|
self.connected = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue