3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-02 15:44:06 +01:00

clientbot: block attempts from virtual clients to change to an existing nick (#535)

This commit is contained in:
James Lu 2017-10-07 20:50:09 -07:00
parent d7766d54d5
commit 740b399ec2

View File

@ -253,6 +253,13 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
self.send('NICK :%s' % newnick) self.send('NICK :%s' % newnick)
# No state update here: the IRCd will respond with a NICK acknowledgement if the change succeeds. # No state update here: the IRCd will respond with a NICK acknowledgement if the change succeeds.
else: else:
assert source, "No source given?"
# Check that the new nick exists and isn't the same client as the sender
# (for changing nick case)
nick_uid = self.nick_to_uid(newnick)
if nick_uid and nick_uid != source:
log.warning('(%s) Blocking attempt from virtual client %s to change nick to %s (nick in use)', self.name, source, newnick)
return
self.call_hooks([source, 'CLIENTBOT_NICK', {'newnick': newnick}]) self.call_hooks([source, 'CLIENTBOT_NICK', {'newnick': newnick}])
self.users[source].nick = newnick self.users[source].nick = newnick