mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 03:29:28 +01:00
parent
9233a94379
commit
4e3d209831
44
classes.py
44
classes.py
@ -1186,6 +1186,12 @@ class Protocol():
|
|||||||
Merges modes of a channel given the remote TS and a list of modes.
|
Merges modes of a channel given the remote TS and a list of modes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Okay, so the situation is that we have 6 possible TS/sender combinations:
|
||||||
|
|
||||||
|
# | our TS lower | TS equal | their TS lower
|
||||||
|
# mode origin is us | OVERWRITE | MERGE | IGNORE
|
||||||
|
# mode origin is uplink | IGNORE | MERGE | OVERWRITE
|
||||||
|
|
||||||
def _clear():
|
def _clear():
|
||||||
log.debug("(%s) Clearing modes from channel %s due to TS change", self.irc.name,
|
log.debug("(%s) Clearing modes from channel %s due to TS change", self.irc.name,
|
||||||
channel)
|
channel)
|
||||||
@ -1208,41 +1214,25 @@ class Protocol():
|
|||||||
|
|
||||||
# Check if we're the mode sender based on the UID / SID given.
|
# Check if we're the mode sender based on the UID / SID given.
|
||||||
our_mode = self.irc.isInternalClient(sender) or self.irc.isInternalServer(sender)
|
our_mode = self.irc.isInternalClient(sender) or self.irc.isInternalServer(sender)
|
||||||
log.debug("(%s/%s) is the mode origin us? %s",
|
|
||||||
self.irc.name, channel, our_mode)
|
|
||||||
|
|
||||||
if their_ts < our_ts:
|
log.debug("(%s/%s) our_ts: %s; their_ts: %s; is the mode origin us? %s", self.irc.name,
|
||||||
# Their TS is older than ours. We should clear our stored modes for the channel and
|
channel, our_ts, their_ts, our_mode)
|
||||||
# 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 our %s; mode query %s",
|
|
||||||
self.irc.name, channel, their_ts, our_ts, modes)
|
|
||||||
|
|
||||||
# Update the channel TS to theirs regardless of whether the mode setting passes.
|
if their_ts == our_ts:
|
||||||
log.debug('(%s) Setting channel TS of %s to %s from %s',
|
|
||||||
self.irc.name, channel, their_ts, our_ts)
|
|
||||||
self.irc.channels[channel].ts = their_ts
|
|
||||||
|
|
||||||
_clear()
|
|
||||||
if not our_mode:
|
|
||||||
_apply()
|
|
||||||
|
|
||||||
elif their_ts == our_ts:
|
|
||||||
log.debug("(%s/%s) remote TS of %s is equal to our %s; mode query %s",
|
log.debug("(%s/%s) remote TS of %s is equal to our %s; mode query %s",
|
||||||
self.irc.name, channel, their_ts, our_ts, modes)
|
self.irc.name, channel, their_ts, our_ts, modes)
|
||||||
# Their TS is equal to ours. Merge modes.
|
# Their TS is equal to ours. Merge modes.
|
||||||
_apply()
|
_apply()
|
||||||
|
|
||||||
elif their_ts > our_ts:
|
elif ((their_ts < our_ts) and (not our_mode)) or ((our_ts < their_ts) and our_mode):
|
||||||
log.debug("(%s/%s) remote TS of %s is higher than our %s; mode query %s",
|
winning_ts = min(our_ts, their_ts)
|
||||||
self.irc.name, channel, their_ts, our_ts, modes)
|
log.debug('(%s) Resetting channel TS of %s from %s to %s',
|
||||||
# Their TS is younger than ours. Clear the state and replace the modes for the channel
|
self.irc.name, channel, self.irc.channels[channel].ts, winning_ts)
|
||||||
# with the ones being set, if we're the one setting modes.
|
self.irc.channels[channel].ts = winning_ts
|
||||||
_clear()
|
|
||||||
|
|
||||||
if our_mode:
|
if not our_mode: # Skip clearing if we're the one setting the mode.
|
||||||
_apply()
|
_clear()
|
||||||
|
_apply()
|
||||||
|
|
||||||
def _getSid(self, sname):
|
def _getSid(self, sname):
|
||||||
"""Returns the SID of a server with the given name, if present."""
|
"""Returns the SID of a server with the given name, if present."""
|
||||||
|
Loading…
Reference in New Issue
Block a user