mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Had to change PING/PONG handling to workaround non-RFC-compliant servers.
This commit is contained in:
parent
06fe786029
commit
d9ca1637d7
@ -302,7 +302,7 @@ class Irc(object):
|
|||||||
self.lastTake = 0
|
self.lastTake = 0
|
||||||
self.fastqueue = queue()
|
self.fastqueue = queue()
|
||||||
self.lastping = time.time()
|
self.lastping = time.time()
|
||||||
self.outstandingPongs = set()
|
self.outstandingPing = False
|
||||||
self.driver = None # The driver should set this later.
|
self.driver = None # The driver should set this later.
|
||||||
if self.password:
|
if self.password:
|
||||||
self.queue.enqueue(ircmsgs.password(self.password))
|
self.queue.enqueue(ircmsgs.password(self.password))
|
||||||
@ -314,7 +314,7 @@ class Irc(object):
|
|||||||
self.state.reset()
|
self.state.reset()
|
||||||
self.queue.reset()
|
self.queue.reset()
|
||||||
self.lastping = time.time()
|
self.lastping = time.time()
|
||||||
self.outstandingPongs = set()
|
self.outstandingPongs = False
|
||||||
self.fastqueue = queue()
|
self.fastqueue = queue()
|
||||||
if self.password:
|
if self.password:
|
||||||
self.queue.enqueue(ircmsgs.password(self.password))
|
self.queue.enqueue(ircmsgs.password(self.password))
|
||||||
@ -348,24 +348,27 @@ class Irc(object):
|
|||||||
else:
|
else:
|
||||||
self.lastTake = now
|
self.lastTake = now
|
||||||
msg = self.queue.dequeue()
|
msg = self.queue.dequeue()
|
||||||
elif len(self.outstandingPongs) >= 2:
|
|
||||||
# Our pings hasn't be responded to.
|
|
||||||
debug.msg('Reconnecting, 3 pings not replied to.', 'normal')
|
|
||||||
if hasattr(self.driver, 'scheduleReconnect'):
|
|
||||||
self.driver.scheduleReconnect()
|
|
||||||
self.driver.die()
|
|
||||||
elif now > (self.lastping + conf.pingInterval):
|
elif now > (self.lastping + conf.pingInterval):
|
||||||
if now - self.lastTake <= conf.throttleTime:
|
if self.outstandingPing:
|
||||||
debug.msg('Irc.takeMsg throttling.', 'verbose')
|
debug.msg('Reconnecting, ping not replied to.', 'normal')
|
||||||
|
self.driver.reconnect()
|
||||||
else:
|
else:
|
||||||
self.lastping = now
|
self.lastping = now
|
||||||
now = str(int(now))
|
now = str(int(now))
|
||||||
self.outstandingPongs.add(now)
|
self.outstandingPing = True
|
||||||
msg = ircmsgs.ping(str(int(now)))
|
self.queueMsg(ircmsgs.ping(now))
|
||||||
if msg:
|
if msg:
|
||||||
for callback in self.callbacks:
|
for callback in self.callbacks:
|
||||||
#debug.printf(repr(msg))
|
#debug.printf(repr(msg))
|
||||||
msg = callback.outFilter(self, msg)
|
try:
|
||||||
|
outFilter = getattr(callback, 'outFilter')
|
||||||
|
except AttributeError, e:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
msg = outFilter(self, msg)
|
||||||
|
except:
|
||||||
|
debug.recoverableException()
|
||||||
|
continue
|
||||||
if msg is None:
|
if msg is None:
|
||||||
s = 'outFilter %s returned None' % callback.name()
|
s = 'outFilter %s returned None' % callback.name()
|
||||||
debug.msg(s)
|
debug.msg(s)
|
||||||
@ -420,7 +423,7 @@ class Irc(object):
|
|||||||
ircdb.users.setUser(self.nick, u)
|
ircdb.users.setUser(self.nick, u)
|
||||||
atexit.register(lambda: catch(ircdb.users.delUser(self.nick)))
|
atexit.register(lambda: catch(ircdb.users.delUser(self.nick)))
|
||||||
elif msg.command == 'PONG':
|
elif msg.command == 'PONG':
|
||||||
self.outstandingPongs.remove(msg.args[1])
|
self.outstandingPing = False
|
||||||
elif msg.command == 'ERROR':
|
elif msg.command == 'ERROR':
|
||||||
if msg.args[0].startswith('Closing Link'):
|
if msg.args[0].startswith('Closing Link'):
|
||||||
if hasattr(self.driver, 'scheduleReconnect'):
|
if hasattr(self.driver, 'scheduleReconnect'):
|
||||||
|
Loading…
Reference in New Issue
Block a user