mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-11 12:42:34 +01:00
updateTS: fix handling for outbound modes
Outgoing and incoming modes should be handled the same way - we're only dealing with a "received TS" which could originate from PyLink (sjoin() in protocols) OR the uplink.
This commit is contained in:
parent
7f829ba0ec
commit
167963ddc4
26
classes.py
26
classes.py
@ -1063,7 +1063,7 @@ class Protocol():
|
||||
log.debug('Removing client %s from self.irc.servers[%s].users', numeric, sid)
|
||||
self.irc.servers[sid].users.discard(numeric)
|
||||
|
||||
def updateTS(self, channel, their_ts, modes=[], outbound=True):
|
||||
def updateTS(self, channel, their_ts, modes=[]):
|
||||
"""
|
||||
Merges modes of a channel given the remote TS and a list of modes.
|
||||
"""
|
||||
@ -1083,10 +1083,11 @@ class Protocol():
|
||||
our_ts = self.irc.channels[channel].ts
|
||||
|
||||
if their_ts < our_ts:
|
||||
# Their TS is older than ours. If we're receiving a mode change, we should
|
||||
# clear our stored modes for the channel and apply theirs. Otherwise, if we're
|
||||
# the one setting modes, just drop them.
|
||||
log.debug("(%s/%s) remote TS of %s is lower than ours %s; outbound mode: %s; setting modes %s",
|
||||
# Their TS is older than ours. We should clear our stored modes for the channel and
|
||||
# apply the ones in the queue to be set. This is regardless of whether we're sending
|
||||
# outgoing modes or receiving some - both are handled the same with a "received" TS,
|
||||
# and comparing it with the one we have.
|
||||
log.debug("(%s/%s) received TS of %s is lower than ours %s; outbound mode: %s; setting modes %s",
|
||||
self.irc.name, channel, their_ts, our_ts, outbound, modes)
|
||||
|
||||
# Update the channel TS to theirs regardless of whether the mode setting passes.
|
||||
@ -1094,9 +1095,8 @@ class Protocol():
|
||||
self.irc.name, channel, their_ts, our_ts)
|
||||
self.irc.channels[channel].ts = their_ts
|
||||
|
||||
if not outbound:
|
||||
_clear()
|
||||
_apply()
|
||||
_clear()
|
||||
_apply()
|
||||
|
||||
elif their_ts == our_ts:
|
||||
log.debug("(%s/%s) remote TS of %s is equal to ours %s; outbound mode: %s; setting modes %s",
|
||||
@ -1107,12 +1107,10 @@ class Protocol():
|
||||
elif their_ts > our_ts:
|
||||
log.debug("(%s/%s) remote TS of %s is higher than ours %s; outbound mode: %s; setting modes %s",
|
||||
self.irc.name, channel, their_ts, our_ts, outbound, modes)
|
||||
# Their TS is younger than ours. If we're setting modes, clear the state
|
||||
# and replace the modes for the channel with ours. Otherwise, just ignore the
|
||||
# remote's changes.
|
||||
if outbound:
|
||||
_clear()
|
||||
_apply()
|
||||
# Their TS is younger than ours. Clear the state and replace the modes for the channel
|
||||
# with the ones being set.
|
||||
_clear()
|
||||
_apply()
|
||||
|
||||
def _getSid(self, sname):
|
||||
"""Returns the SID of a server with the given name, if present."""
|
||||
|
@ -528,7 +528,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
# Statekeeping with timestamps
|
||||
their_ts = int(args[1])
|
||||
our_ts = self.irc.channels[channel].ts
|
||||
self.updateTS(channel, their_ts, changedmodes, outbound=False)
|
||||
self.updateTS(channel, their_ts, changedmodes)
|
||||
|
||||
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts}
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ class P10Protocol(Protocol):
|
||||
# Statekeeping with timestamps
|
||||
their_ts = int(args[1])
|
||||
our_ts = self.irc.channels[channel].ts
|
||||
self.updateTS(channel, their_ts, changedmodes, outbound=False)
|
||||
self.updateTS(channel, their_ts, changedmodes)
|
||||
|
||||
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts}
|
||||
|
||||
|
@ -477,7 +477,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
# Statekeeping with timestamps
|
||||
their_ts = int(args[0])
|
||||
our_ts = self.irc.channels[channel].ts
|
||||
self.updateTS(channel, their_ts, changedmodes, outbound=False)
|
||||
self.updateTS(channel, their_ts, changedmodes)
|
||||
|
||||
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts}
|
||||
|
||||
|
@ -591,7 +591,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
|
||||
our_ts = self.irc.channels[channel].ts
|
||||
their_ts = int(args[0])
|
||||
self.updateTS(channel, their_ts, changedmodes, outbound=False)
|
||||
self.updateTS(channel, their_ts, changedmodes)
|
||||
|
||||
return {'channel': channel, 'users': namelist, 'modes': self.irc.channels[channel].modes, 'ts': their_ts}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user