Skip to content

Commit c2f1e8f

Browse files
committed
more graceful handling of attempted DCC connections
1 parent 5d6adb4 commit c2f1e8f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

DCCSocket.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,21 @@ def getAddr(self):
190190
def addPending(self, sender):
191191
try:
192192
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]
193+
ip = None
194+
for entry in addr_info:
195+
if len(entry[4]) == 2:
196+
ip = entry[4][0]
197+
break
198+
199+
if not ip:
200+
self.logger.info('Unable to find IPv4 address in address info: ' + str(addr_info))
201+
return False
202+
197203
self.logger.info("Adding %s - %s to the pending list" % (ip, sender))
198204
self.pending[ip] = sender
199205
return True
200206
except Exception as e:
201-
self.bot.sendNotice(sender.nick, "Error while initialiasing DCC connection.")
207+
self.bot.sendNotice(sender.nick, "Error while initializing DCC connection.")
202208
print str(e)
203209
return False
204210

0 commit comments

Comments
 (0)