3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

protocol/relay: fix handling of KILLs sent to non-relay users

This commit is contained in:
James Lu 2015-07-24 18:26:31 -07:00
parent 3b67ddfee6
commit a4da9b5324
2 changed files with 31 additions and 20 deletions

View File

@ -586,25 +586,35 @@ utils.add_hook(handle_topic, 'TOPIC')
def handle_kill(irc, numeric, command, args):
target = args['target']
userdata = args['userdata']
if numeric not in irc.users:
# A server's sending kill? Uh oh, this can't be good.
return
# We don't allow killing over the relay, so we must spawn the client.
# all over again and rejoin it to its channels.
realuser = getLocalUser(irc, target)
log.debug('(%s) relay handle_kill: realuser is %r', irc.name, realuser)
# Target user was remote:
if realuser and realuser[0] != irc.name:
# We don't allow killing over the relay, so we must respawn the affected
# client and rejoin it to its channels.
del relayusers[realuser][irc.name]
remoteirc = utils.networkobjects[realuser[0]]
for channel in remoteirc.channels:
remotechan = findRemoteChan(remoteirc, irc, channel)
if remotechan:
modes = getPrefixModes(remoteirc, irc, remotechan, realuser[1])
log.debug('(%s) handle_kill: userpair: %s, %s', irc.name, modes, realuser)
log.debug('(%s) relay handle_kill: userpair: %s, %s', irc.name, modes, realuser)
client = getRemoteUser(remoteirc, irc, realuser[1])
irc.proto.sjoinServer(irc, irc.sid, remotechan, [(modes, client)])
if userdata and numeric in irc.users:
utils.msg(irc, numeric, "Your kill has to %s been blocked "
"because PyLink does not allow killing"
" users over the relay at this time." % \
userdata.nick, notice=True)
# Target user was local.
else:
# IMPORTANT: some IRCds (charybdis) don't send explicit QUIT messages
# for locally killed clients, while others (inspircd) do!
# If we receive a user object in 'userdata' instead of None, it means
# that the KILL hasn't been handled by a preceding QUIT message.
if userdata:
handle_quit(irc, target, 'KILL', {'text': args['text']})
utils.add_hook(handle_kill, 'KILL')
def relayJoins(irc, channel, users, ts, modes):

View File

@ -327,7 +327,8 @@ def handle_privmsg(irc, source, command, args):
def handle_kill(irc, source, command, args):
killed = args[0]
data = irc.users[killed]
data = irc.users.get(killed)
if data:
removeClient(irc, killed)
return {'target': killed, 'text': args[1], 'userdata': data}