mirror of
https://github.com/jlu5/PyLink.git
synced 2025-03-01 12:00:42 +01:00
relay: catch various errors if a relay client is killed while commands are called from it
This commit is contained in:
parent
cc40cacb7a
commit
06ee35dcfc
@ -313,11 +313,17 @@ def spawnRelayUser(irc, remoteirc, user):
|
|||||||
modes=modes, ts=userobj.ts,
|
modes=modes, ts=userobj.ts,
|
||||||
opertype=opertype, server=rsid,
|
opertype=opertype, server=rsid,
|
||||||
ip=ip, realhost=realhost).uid
|
ip=ip, realhost=realhost).uid
|
||||||
remoteirc.users[u].remote = (irc.name, user)
|
try:
|
||||||
remoteirc.users[u].opertype = opertype
|
remoteirc.users[u].remote = (irc.name, user)
|
||||||
away = userobj.away
|
remoteirc.users[u].opertype = opertype
|
||||||
if away:
|
away = userobj.away
|
||||||
remoteirc.proto.away(u, away)
|
if away:
|
||||||
|
remoteirc.proto.away(u, away)
|
||||||
|
except KeyError:
|
||||||
|
# User got killed somehow while we were setting options on it.
|
||||||
|
# This is probably being done by the uplink, due to something like an
|
||||||
|
# invalid nick, etc.
|
||||||
|
raise
|
||||||
|
|
||||||
relayusers[(irc.name, user)][remoteirc.name] = u
|
relayusers[(irc.name, user)][remoteirc.name] = u
|
||||||
return u
|
return u
|
||||||
@ -953,16 +959,30 @@ def handle_messages(irc, numeric, command, args):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
# Remote main client hasn't spawned yet. Drop the message.
|
# Remote main client hasn't spawned yet. Drop the message.
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
if remoteirc.pseudoclient.uid not in remoteirc.users:
|
||||||
|
# Remote UID is ghosted, drop message.
|
||||||
|
continue
|
||||||
|
|
||||||
else:
|
else:
|
||||||
real_text = text
|
real_text = text
|
||||||
|
|
||||||
real_target = prefix + real_target
|
real_target = prefix + real_target
|
||||||
log.debug('(%s) relay.handle_messages: sending message to %s from %s on behalf of %s',
|
log.debug('(%s) relay.handle_messages: sending message to %s from %s on behalf of %s',
|
||||||
irc.name, real_target, user, numeric)
|
irc.name, real_target, user, numeric)
|
||||||
if notice:
|
|
||||||
remoteirc.proto.notice(user, real_target, real_text)
|
try:
|
||||||
else:
|
if notice:
|
||||||
remoteirc.proto.message(user, real_target, real_text)
|
remoteirc.proto.notice(user, real_target, real_text)
|
||||||
|
else:
|
||||||
|
remoteirc.proto.message(user, real_target, real_text)
|
||||||
|
except LookupError:
|
||||||
|
# Our relay clone disappeared while we were trying to send the message.
|
||||||
|
# This is normally due to a nick conflict with the IRCd.
|
||||||
|
log.warning("(%s) relay: Relay client %s on %s was killed while "
|
||||||
|
"trying to send a message through it!", irc.name,
|
||||||
|
remoteirc.name, user)
|
||||||
|
continue
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Get the real user that the PM was meant for
|
# Get the real user that the PM was meant for
|
||||||
@ -983,10 +1003,18 @@ def handle_messages(irc, numeric, command, args):
|
|||||||
remoteirc = world.networkobjects[homenet]
|
remoteirc = world.networkobjects[homenet]
|
||||||
user = getRemoteUser(irc, remoteirc, numeric, spawnIfMissing=False)
|
user = getRemoteUser(irc, remoteirc, numeric, spawnIfMissing=False)
|
||||||
|
|
||||||
if notice:
|
try:
|
||||||
remoteirc.proto.notice(user, real_target, text)
|
if notice:
|
||||||
else:
|
remoteirc.proto.notice(user, real_target, text)
|
||||||
remoteirc.proto.message(user, real_target, text)
|
else:
|
||||||
|
remoteirc.proto.message(user, real_target, text)
|
||||||
|
except LookupError:
|
||||||
|
# Our relay clone disappeared while we were trying to send the message.
|
||||||
|
# This is normally due to a nick conflict with the IRCd.
|
||||||
|
log.warning("(%s) relay: Relay client %s on %s was killed while "
|
||||||
|
"trying to send a message through it!", irc.name,
|
||||||
|
remoteirc.name, user)
|
||||||
|
return
|
||||||
|
|
||||||
for cmd in ('PRIVMSG', 'NOTICE', 'PYLINK_SELF_NOTICE', 'PYLINK_SELF_PRIVMSG'):
|
for cmd in ('PRIVMSG', 'NOTICE', 'PYLINK_SELF_NOTICE', 'PYLINK_SELF_PRIVMSG'):
|
||||||
utils.add_hook(handle_messages, cmd)
|
utils.add_hook(handle_messages, cmd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user