mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-03 08:04:07 +01:00
Merge branch 'devel+next' into devel
This commit is contained in:
commit
1bd6149ee2
@ -169,7 +169,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)
|
self.check_nick_collision(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
|
||||||
|
@ -575,7 +575,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)
|
self.check_nick_collision(nick)
|
||||||
realname = args[-1]
|
realname = args[-1]
|
||||||
self.irc.users[uid] = userobj = IrcUser(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
self.irc.users[uid] = userobj = IrcUser(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class IRCS2SProtocol(Protocol):
|
|||||||
self.protocol_caps = {'can-spawn-clients', 'has-ts', 'can-host-relay',
|
self.protocol_caps = {'can-spawn-clients', 'has-ts', 'can-host-relay',
|
||||||
'can-track-servers'}
|
'can-track-servers'}
|
||||||
|
|
||||||
def checkCollision(self, nick):
|
def check_nick_collision(self, nick):
|
||||||
"""
|
"""
|
||||||
Nick collision checker.
|
Nick collision checker.
|
||||||
"""
|
"""
|
||||||
|
208
protocols/p10.py
208
protocols/p10.py
@ -63,6 +63,93 @@ class P10SIDGenerator():
|
|||||||
return sid
|
return sid
|
||||||
|
|
||||||
class P10Protocol(IRCS2SProtocol):
|
class P10Protocol(IRCS2SProtocol):
|
||||||
|
COMMAND_TOKENS = {
|
||||||
|
'AC': 'ACCOUNT',
|
||||||
|
'AD': 'ADMIN',
|
||||||
|
'LL': 'ASLL',
|
||||||
|
'A': 'AWAY',
|
||||||
|
'B': 'BURST',
|
||||||
|
'CAP': 'CAP',
|
||||||
|
'CM': 'CLEARMODE',
|
||||||
|
'CLOSE': 'CLOSE',
|
||||||
|
'CN': 'CNOTICE',
|
||||||
|
'CO': 'CONNECT',
|
||||||
|
'CP': 'CPRIVMSG',
|
||||||
|
'C': 'CREATE',
|
||||||
|
'DE': 'DESTRUCT',
|
||||||
|
'DS': 'DESYNCH',
|
||||||
|
'DIE': 'DIE',
|
||||||
|
'DNS': 'DNS',
|
||||||
|
'EB': 'END_OF_BURST',
|
||||||
|
'EA': 'EOB_ACK',
|
||||||
|
'Y': 'ERROR',
|
||||||
|
'GET': 'GET',
|
||||||
|
'GL': 'GLINE',
|
||||||
|
'HASH': 'HASH',
|
||||||
|
'HELP': 'HELP',
|
||||||
|
'F': 'INFO',
|
||||||
|
'I': 'INVITE',
|
||||||
|
'ISON': 'ISON',
|
||||||
|
'J': 'JOIN',
|
||||||
|
'JU': 'JUPE',
|
||||||
|
'K': 'KICK',
|
||||||
|
'D': 'KILL',
|
||||||
|
'LI': 'LINKS',
|
||||||
|
'LIST': 'LIST',
|
||||||
|
'LU': 'LUSERS',
|
||||||
|
'MAP': 'MAP',
|
||||||
|
'M': 'MODE',
|
||||||
|
'MO': 'MOTD',
|
||||||
|
'E': 'NAMES',
|
||||||
|
'N': 'NICK',
|
||||||
|
'O': 'NOTICE',
|
||||||
|
'OPER': 'OPER',
|
||||||
|
'OM': 'OPMODE',
|
||||||
|
'L': 'PART',
|
||||||
|
'PA': 'PASS',
|
||||||
|
'G': 'PING',
|
||||||
|
'Z': 'PONG',
|
||||||
|
'POST': 'POST',
|
||||||
|
'P': 'PRIVMSG',
|
||||||
|
'PRIVS': 'PRIVS',
|
||||||
|
'PROTO': 'PROTO',
|
||||||
|
'Q': 'QUIT',
|
||||||
|
'REHASH': 'REHASH',
|
||||||
|
'RESET': 'RESET',
|
||||||
|
'RESTART': 'RESTART',
|
||||||
|
'RI': 'RPING',
|
||||||
|
'RO': 'RPONG',
|
||||||
|
'S': 'SERVER',
|
||||||
|
'SERVSET': 'SERVLIST',
|
||||||
|
'SERVSET': 'SERVSET',
|
||||||
|
'SET': 'SET',
|
||||||
|
'SE': 'SETTIME',
|
||||||
|
'U': 'SILENCE',
|
||||||
|
'SQUERY': 'SQUERY',
|
||||||
|
'SQ': 'SQUIT',
|
||||||
|
'R': 'STATS',
|
||||||
|
'TI': 'TIME',
|
||||||
|
'T': 'TOPIC',
|
||||||
|
'TR': 'TRACE',
|
||||||
|
'UP': 'UPING',
|
||||||
|
'USER': 'USER',
|
||||||
|
'USERHOST': 'USERHOST',
|
||||||
|
'USERIP': 'USERIP',
|
||||||
|
'V': 'VERSION',
|
||||||
|
'WC': 'WALLCHOPS',
|
||||||
|
'WA': 'WALLOPS',
|
||||||
|
'WU': 'WALLUSERS',
|
||||||
|
'WV': 'WALLVOICES',
|
||||||
|
'H': 'WHO',
|
||||||
|
'W': 'WHOIS',
|
||||||
|
'X': 'WHOWAS',
|
||||||
|
'XQ': 'XQUERY',
|
||||||
|
'XR': 'XREPLY',
|
||||||
|
'SN': 'SVSNICK',
|
||||||
|
'SJ': 'SVSJOIN',
|
||||||
|
'SH': 'SETHOST',
|
||||||
|
'FA': 'FAKE'
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
super().__init__(irc)
|
super().__init__(irc)
|
||||||
@ -151,99 +238,6 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
ip = '0' + ip
|
ip = '0' + ip
|
||||||
return ip
|
return ip
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _getCommand(token):
|
|
||||||
"""Returns the command name for the given token."""
|
|
||||||
tokens = {
|
|
||||||
'AC': 'ACCOUNT',
|
|
||||||
'AD': 'ADMIN',
|
|
||||||
'LL': 'ASLL',
|
|
||||||
'A': 'AWAY',
|
|
||||||
'B': 'BURST',
|
|
||||||
'CAP': 'CAP',
|
|
||||||
'CM': 'CLEARMODE',
|
|
||||||
'CLOSE': 'CLOSE',
|
|
||||||
'CN': 'CNOTICE',
|
|
||||||
'CO': 'CONNECT',
|
|
||||||
'CP': 'CPRIVMSG',
|
|
||||||
'C': 'CREATE',
|
|
||||||
'DE': 'DESTRUCT',
|
|
||||||
'DS': 'DESYNCH',
|
|
||||||
'DIE': 'DIE',
|
|
||||||
'DNS': 'DNS',
|
|
||||||
'EB': 'END_OF_BURST',
|
|
||||||
'EA': 'EOB_ACK',
|
|
||||||
'Y': 'ERROR',
|
|
||||||
'GET': 'GET',
|
|
||||||
'GL': 'GLINE',
|
|
||||||
'HASH': 'HASH',
|
|
||||||
'HELP': 'HELP',
|
|
||||||
'F': 'INFO',
|
|
||||||
'I': 'INVITE',
|
|
||||||
'ISON': 'ISON',
|
|
||||||
'J': 'JOIN',
|
|
||||||
'JU': 'JUPE',
|
|
||||||
'K': 'KICK',
|
|
||||||
'D': 'KILL',
|
|
||||||
'LI': 'LINKS',
|
|
||||||
'LIST': 'LIST',
|
|
||||||
'LU': 'LUSERS',
|
|
||||||
'MAP': 'MAP',
|
|
||||||
'M': 'MODE',
|
|
||||||
'MO': 'MOTD',
|
|
||||||
'E': 'NAMES',
|
|
||||||
'N': 'NICK',
|
|
||||||
'O': 'NOTICE',
|
|
||||||
'OPER': 'OPER',
|
|
||||||
'OM': 'OPMODE',
|
|
||||||
'L': 'PART',
|
|
||||||
'PA': 'PASS',
|
|
||||||
'G': 'PING',
|
|
||||||
'Z': 'PONG',
|
|
||||||
'POST': 'POST',
|
|
||||||
'P': 'PRIVMSG',
|
|
||||||
'PRIVS': 'PRIVS',
|
|
||||||
'PROTO': 'PROTO',
|
|
||||||
'Q': 'QUIT',
|
|
||||||
'REHASH': 'REHASH',
|
|
||||||
'RESET': 'RESET',
|
|
||||||
'RESTART': 'RESTART',
|
|
||||||
'RI': 'RPING',
|
|
||||||
'RO': 'RPONG',
|
|
||||||
'S': 'SERVER',
|
|
||||||
'SERVSET': 'SERVLIST',
|
|
||||||
'SERVSET': 'SERVSET',
|
|
||||||
'SET': 'SET',
|
|
||||||
'SE': 'SETTIME',
|
|
||||||
'U': 'SILENCE',
|
|
||||||
'SQUERY': 'SQUERY',
|
|
||||||
'SQ': 'SQUIT',
|
|
||||||
'R': 'STATS',
|
|
||||||
'TI': 'TIME',
|
|
||||||
'T': 'TOPIC',
|
|
||||||
'TR': 'TRACE',
|
|
||||||
'UP': 'UPING',
|
|
||||||
'USER': 'USER',
|
|
||||||
'USERHOST': 'USERHOST',
|
|
||||||
'USERIP': 'USERIP',
|
|
||||||
'V': 'VERSION',
|
|
||||||
'WC': 'WALLCHOPS',
|
|
||||||
'WA': 'WALLOPS',
|
|
||||||
'WU': 'WALLUSERS',
|
|
||||||
'WV': 'WALLVOICES',
|
|
||||||
'H': 'WHO',
|
|
||||||
'W': 'WHOIS',
|
|
||||||
'X': 'WHOWAS',
|
|
||||||
'XQ': 'XQUERY',
|
|
||||||
'XR': 'XREPLY',
|
|
||||||
'SN': 'SVSNICK',
|
|
||||||
'SJ': 'SVSJOIN',
|
|
||||||
'SH': 'SETHOST',
|
|
||||||
'FA': 'FAKE'
|
|
||||||
}
|
|
||||||
# If the token isn't in the list, return it raw.
|
|
||||||
return tokens.get(token, token)
|
|
||||||
|
|
||||||
### COMMANDS
|
### COMMANDS
|
||||||
|
|
||||||
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
||||||
@ -755,8 +749,8 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
|
|
||||||
# P10 cloaks aren't as simple as just replacing the displayed host with the one we're
|
# P10 cloaks aren't as simple as just replacing the displayed host with the one we're
|
||||||
# sending. Check for cloak changes properly.
|
# sending. Check for cloak changes properly.
|
||||||
# Note: we don't need to send any hooks here, checkCloakChange does that for us.
|
# Note: we don't need to send any hooks here, check_cloak_change does that for us.
|
||||||
self.checkCloakChange(target)
|
self.check_cloak_change(target)
|
||||||
|
|
||||||
### HANDLERS
|
### HANDLERS
|
||||||
|
|
||||||
@ -869,14 +863,12 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
args = args[2:]
|
args = args[2:]
|
||||||
|
|
||||||
log.debug('(%s) Found message sender as %s', self.irc.name, sender)
|
log.debug('(%s) Found message sender as %s', self.irc.name, sender)
|
||||||
|
# Convert the token given into a regular command, if present.
|
||||||
|
command = self.COMMAND_TOKENS.get(command_token, command_token)
|
||||||
|
log.debug('(%s) Translating token %s to command %s', self.irc.name, command_token, command)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Convert the token given into a regular command, if present.
|
|
||||||
command = self._getCommand(command_token)
|
|
||||||
log.debug('(%s) Translating token %s to command %s', self.irc.name, command_token, command)
|
|
||||||
|
|
||||||
func = getattr(self, 'handle_'+command.lower())
|
func = getattr(self, 'handle_'+command.lower())
|
||||||
|
|
||||||
except AttributeError: # Unhandled command, ignore
|
except AttributeError: # Unhandled command, ignore
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -909,7 +901,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)
|
self.check_nick_collision(nick)
|
||||||
ts, ident, host = args[2:5]
|
ts, ident, host = args[2:5]
|
||||||
realhost = host
|
realhost = host
|
||||||
ip = args[-3]
|
ip = args[-3]
|
||||||
@ -943,7 +935,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
if ('+o', None) in parsedmodes:
|
if ('+o', None) in parsedmodes:
|
||||||
self.irc.callHooks([uid, 'CLIENT_OPERED', {'text': 'IRC Operator'}])
|
self.irc.callHooks([uid, 'CLIENT_OPERED', {'text': 'IRC Operator'}])
|
||||||
|
|
||||||
self.checkCloakChange(uid)
|
self.check_cloak_change(uid)
|
||||||
|
|
||||||
return {'uid': uid, 'ts': ts, 'nick': nick, 'realhost': realhost, 'host': host, 'ident': ident, 'ip': ip}
|
return {'uid': uid, 'ts': ts, 'nick': nick, 'realhost': realhost, 'host': host, 'ident': ident, 'ip': ip}
|
||||||
|
|
||||||
@ -957,13 +949,13 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
# Update the nick TS.
|
# Update the nick TS.
|
||||||
return {'newnick': newnick, 'oldnick': oldnick, 'ts': ts}
|
return {'newnick': newnick, 'oldnick': oldnick, 'ts': ts}
|
||||||
|
|
||||||
def checkCloakChange(self, uid):
|
def check_cloak_change(self, uid):
|
||||||
"""Checks for cloak changes (ident and host) on the given UID."""
|
"""Checks for cloak changes (ident and host) on the given UID."""
|
||||||
uobj = self.irc.users[uid]
|
uobj = self.irc.users[uid]
|
||||||
ident = uobj.ident
|
ident = uobj.ident
|
||||||
|
|
||||||
modes = dict(uobj.modes)
|
modes = dict(uobj.modes)
|
||||||
log.debug('(%s) checkCloakChange: modes of %s are %s', self.irc.name, uid, modes)
|
log.debug('(%s) check_cloak_change: modes of %s are %s', self.irc.name, uid, modes)
|
||||||
|
|
||||||
if 'x' not in modes: # +x isn't set, so cloaking is disabled.
|
if 'x' not in modes: # +x isn't set, so cloaking is disabled.
|
||||||
newhost = uobj.realhost
|
newhost = uobj.realhost
|
||||||
@ -1219,7 +1211,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
|
|
||||||
if target in self.irc.users:
|
if target in self.irc.users:
|
||||||
# Target was a user. Check for any cloak changes.
|
# Target was a user. Check for any cloak changes.
|
||||||
self.checkCloakChange(target)
|
self.check_cloak_change(target)
|
||||||
|
|
||||||
return {'target': target, 'modes': changedmodes}
|
return {'target': target, 'modes': changedmodes}
|
||||||
# OPMODE is like SAMODE on other IRCds, and it follows the same modesetting syntax.
|
# OPMODE is like SAMODE on other IRCds, and it follows the same modesetting syntax.
|
||||||
@ -1353,7 +1345,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
self.irc.callHooks([target, 'CLIENT_SERVICES_LOGIN', {'text': accountname}])
|
self.irc.callHooks([target, 'CLIENT_SERVICES_LOGIN', {'text': accountname}])
|
||||||
|
|
||||||
# Check for any cloak changes now.
|
# Check for any cloak changes now.
|
||||||
self.checkCloakChange(target)
|
self.check_cloak_change(target)
|
||||||
|
|
||||||
def handle_fake(self, numeric, command, args):
|
def handle_fake(self, numeric, command, args):
|
||||||
"""Handles incoming FAKE hostmask changes."""
|
"""Handles incoming FAKE hostmask changes."""
|
||||||
@ -1363,8 +1355,8 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
# Assume a usermode +f change, and then update the cloak checking.
|
# Assume a usermode +f change, and then update the cloak checking.
|
||||||
self.irc.applyModes(target, [('+f', text)])
|
self.irc.applyModes(target, [('+f', text)])
|
||||||
|
|
||||||
self.checkCloakChange(target)
|
self.check_cloak_change(target)
|
||||||
# We don't need to send any hooks here, checkCloakChange does that for us.
|
# We don't need to send any hooks here, check_cloak_change does that for us.
|
||||||
|
|
||||||
def handle_svsnick(self, source, command, args):
|
def handle_svsnick(self, source, command, args):
|
||||||
"""Handles SVSNICK (forced nickname change attempts)."""
|
"""Handles SVSNICK (forced nickname change attempts)."""
|
||||||
|
@ -499,7 +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)
|
self.check_nick_collision(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
|
||||||
|
@ -390,7 +390,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)
|
self.check_nick_collision(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