Skip to content

Commit d723e25

Browse files
committed
try to get the IPv4 address if both v4 and v6 are available
1 parent 0efe1e7 commit d723e25

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

DCCSocket.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,13 @@ def getAddr(self):
189189

190190
def addPending(self, sender):
191191
try:
192-
self.logger.info("Adding %s - %s to the pending list" % (socket.getaddrinfo(sender.host, None)[0][4][0], sender))
193-
self.pending[socket.getaddrinfo(sender.host, None)[0][4][0]] = sender
192+
addr_info = socket.getaddrinfo(sender.host, None)
193+
if len(addr_info) >= 2:
194+
ip = addr_info[1][4][0]
195+
else:
196+
ip = addr_info[0][4][0]
197+
self.logger.info("Adding %s - %s to the pending list" % (ip, sender))
198+
self.pending[ip] = sender
194199
return True
195200
except Exception as e:
196201
self.bot.sendNotice(sender.nick, "Error while initialiasing DCC connection.")

0 commit comments

Comments
 (0)