mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-25 04:02:45 +01:00
protocols: implement basic nick collision detection in UID handlers
Closes #285. Closes #375.
This commit is contained in:
parent
3a852393bc
commit
194a62fcea
@ -171,6 +171,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
"""
|
"""
|
||||||
# <- :0UY UID dan 1 1451041551 +Facdeiklosuw ~ident localhost 127.0.0.1 0UYAAAAAB * :realname
|
# <- :0UY UID dan 1 1451041551 +Facdeiklosuw ~ident localhost 127.0.0.1 0UYAAAAAB * :realname
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
|
self.checkCollision(nick)
|
||||||
ts, modes, ident, host, ip, uid, account, realname = args[2:10]
|
ts, modes, ident, host, ip, uid, account, realname = args[2:10]
|
||||||
if account == '*':
|
if account == '*':
|
||||||
account = None
|
account = None
|
||||||
|
@ -562,6 +562,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
"""Handles incoming UID commands (user introduction)."""
|
"""Handles incoming UID commands (user introduction)."""
|
||||||
# :70M UID 70MAAAAAB 1429934638 GL 0::1 hidden-7j810p.9mdf.lrek.0000.0000.IP gl 0::1 1429934638 +Wioswx +ACGKNOQXacfgklnoqvx :realname
|
# :70M UID 70MAAAAAB 1429934638 GL 0::1 hidden-7j810p.9mdf.lrek.0000.0000.IP gl 0::1 1429934638 +Wioswx +ACGKNOQXacfgklnoqvx :realname
|
||||||
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
||||||
|
self.checkCollision(nick)
|
||||||
realname = args[-1]
|
realname = args[-1]
|
||||||
self.irc.users[uid] = userobj = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
self.irc.users[uid] = userobj = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
|
@ -7,6 +7,18 @@ from pylinkirc.log import log
|
|||||||
|
|
||||||
class IRCS2SProtocol(Protocol):
|
class IRCS2SProtocol(Protocol):
|
||||||
|
|
||||||
|
def checkCollision(self, nick):
|
||||||
|
"""
|
||||||
|
Nick collision checker.
|
||||||
|
"""
|
||||||
|
uid = self.irc.nickToUid(nick)
|
||||||
|
# If there is a nick collision, we simply alert plugins. Relay will purposely try to
|
||||||
|
# lose fights and tag nicks instead, while other plugins can choose how to handle this.
|
||||||
|
if uid:
|
||||||
|
log.info('(%s) Nick collision on %s/%s, forwarding this to plugins', self.irc.name,
|
||||||
|
uid, nick)
|
||||||
|
self.irc.callHooks([self.irc.sid, 'SAVE', {'target': uid}])
|
||||||
|
|
||||||
def handle_kill(self, source, command, args):
|
def handle_kill(self, source, command, args):
|
||||||
"""Handles incoming KILLs."""
|
"""Handles incoming KILLs."""
|
||||||
killed = args[0]
|
killed = args[0]
|
||||||
|
@ -827,6 +827,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
# <- AB N GL 1 1460673049 ~gl nefarious.midnight.vpn +iw B]AAAB ABAAA :realname
|
# <- AB N GL 1 1460673049 ~gl nefarious.midnight.vpn +iw B]AAAB ABAAA :realname
|
||||||
|
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
|
self.checkCollision(nick)
|
||||||
ts, ident, host = args[2:5]
|
ts, ident, host = args[2:5]
|
||||||
realhost = host
|
realhost = host
|
||||||
ip = args[-3]
|
ip = args[-3]
|
||||||
|
@ -499,6 +499,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
"""Handles incoming EUID commands (user introduction)."""
|
"""Handles incoming EUID commands (user introduction)."""
|
||||||
# <- :42X EUID GL 1 1437505322 +ailoswz ~gl 127.0.0.1 127.0.0.1 42XAAAAAB * * :realname
|
# <- :42X EUID GL 1 1437505322 +ailoswz ~gl 127.0.0.1 127.0.0.1 42XAAAAAB * * :realname
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
|
self.checkCollision(nick)
|
||||||
ts, modes, ident, host, ip, uid, realhost, accountname, realname = args[2:11]
|
ts, modes, ident, host, ip, uid, realhost, accountname, realname = args[2:11]
|
||||||
if realhost == '*':
|
if realhost == '*':
|
||||||
realhost = None
|
realhost = None
|
||||||
|
@ -338,6 +338,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
# arguments: nick, hopcount?, ts, ident, real-host, UID, services account (0 if none), modes,
|
# arguments: nick, hopcount?, ts, ident, real-host, UID, services account (0 if none), modes,
|
||||||
# displayed host, cloaked (+x) host, base64-encoded IP, and realname
|
# displayed host, cloaked (+x) host, base64-encoded IP, and realname
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
|
self.checkCollision(nick)
|
||||||
ts, ident, realhost, uid, accountname, modestring, host = args[2:9]
|
ts, ident, realhost, uid, accountname, modestring, host = args[2:9]
|
||||||
|
|
||||||
if host == '*':
|
if host == '*':
|
||||||
|
Loading…
Reference in New Issue
Block a user