mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-25 04:02:45 +01:00
relay: join remote users before sending ours
This fixes race conditions where modes can be set on our joining users (e.g. auto-op by ChanServ), but are promptly erased as relay joins remote users and resets the channel TS. Also, move relayModes() calls back into relayJoins(), with an optional "burst" argument. Closes #102.
This commit is contained in:
parent
8d44830d5c
commit
708d949164
@ -222,11 +222,6 @@ def initializeChannel(irc, channel):
|
||||
log.debug('(%s) initializeChannel: relay pair found to be %s', irc.name, relay)
|
||||
queued_users = []
|
||||
if relay:
|
||||
# Send our users and channel modes to the other nets
|
||||
log.debug('(%s) initializeChannel: joining our users: %s', irc.name, c.users)
|
||||
relayJoins(irc, channel, c.users, c.ts)
|
||||
irc.proto.joinClient(irc, irc.pseudoclient.uid, channel)
|
||||
|
||||
all_links = db[relay]['links'].copy()
|
||||
all_links.update((relay,))
|
||||
log.debug('(%s) initializeChannel: all_links: %s', irc.name, all_links)
|
||||
@ -243,13 +238,15 @@ def initializeChannel(irc, channel):
|
||||
continue # They aren't connected, don't bother!
|
||||
# Join their (remote) users and set their modes.
|
||||
relayJoins(remoteirc, remotechan, rc.users, rc.ts)
|
||||
relayModes(remoteirc, irc, remoteirc.sid, remotechan, rc.modes)
|
||||
relayModes(irc, remoteirc, irc.sid, channel, c.modes)
|
||||
topic = remoteirc.channels[remotechan].topic
|
||||
# Only update the topic if it's different from what we already have,
|
||||
# and topic bursting is complete.
|
||||
if remoteirc.channels[remotechan].topicset and topic != irc.channels[channel].topic:
|
||||
irc.proto.topicServer(irc, irc.sid, channel, topic)
|
||||
# Send our users and channel modes to the other nets
|
||||
log.debug('(%s) initializeChannel: joining our users: %s', irc.name, c.users)
|
||||
relayJoins(irc, channel, c.users, c.ts)
|
||||
irc.proto.joinClient(irc, irc.pseudoclient.uid, channel)
|
||||
|
||||
def handle_join(irc, numeric, command, args):
|
||||
channel = args['channel']
|
||||
@ -672,7 +669,7 @@ def isRelayClient(irc, user):
|
||||
pass
|
||||
return False
|
||||
|
||||
def relayJoins(irc, channel, users, ts):
|
||||
def relayJoins(irc, channel, users, ts, burst=True):
|
||||
for name, remoteirc in utils.networkobjects.items():
|
||||
queued_users = []
|
||||
if name == irc.name or not remoteirc.connected.is_set():
|
||||
@ -704,7 +701,13 @@ def relayJoins(irc, channel, users, ts):
|
||||
log.debug('(%s) relayJoins: not joining %s to %s%s; they\'re already there!', irc.name,
|
||||
u, remoteirc.name, remotechan)
|
||||
if queued_users:
|
||||
remoteirc.proto.sjoinServer(remoteirc, remoteirc.sid, remotechan, queued_users, ts=ts)
|
||||
# Burst was explicitly given, or we're trying to join multiple
|
||||
# users/someone with a prefix.
|
||||
if burst or len(queued_users) > 1 or queued_users[0][0]:
|
||||
remoteirc.proto.sjoinServer(remoteirc, remoteirc.sid, remotechan, queued_users, ts=ts)
|
||||
relayModes(irc, remoteirc, remoteirc.sid, remotechan)
|
||||
else:
|
||||
remoteirc.proto.joinClient(remoteirc, queued_users[0][1], remotechan)
|
||||
|
||||
def relayPart(irc, channel, user):
|
||||
for name, remoteirc in utils.networkobjects.items():
|
||||
|
Loading…
Reference in New Issue
Block a user