3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

protocols: convert user TS to an int when receiving new users (#594)

This commit is contained in:
James Lu 2018-05-26 16:22:36 -07:00
parent e3a935d0b7
commit 1ab5d614c0
7 changed files with 29 additions and 14 deletions

View File

@ -103,7 +103,8 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
f('NICK %s' % nick)
f('USER %s 8 * :%s' % (ident, realname))
self.pseudoclient = User(self, nick, int(time.time()), self.uidgen.next_uid(prefix='@ClientbotInternal'), self.sid,
self.pseudoclient = User(self, nick, int(time.time()),
self.uidgen.next_uid(prefix='@ClientbotInternal'), self.sid,
ident=ident, realname=realname, host=self.hostname())
self.users[self.pseudoclient.uid] = self.pseudoclient
@ -121,7 +122,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
ts = ts or int(time.time())
log.debug('(%s) spawn_client stub called, saving nick %s as PUID %s', self.name, nick, uid)
u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname,
u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname,
manipulatable=manipulatable, realhost=realhost, ip=ip)
self.servers[server].users.add(uid)

View File

@ -110,10 +110,13 @@ class HybridProtocol(TS6Protocol):
realname = realname or conf.conf['pylink']['realname']
realhost = realhost or host
raw_modes = self.join_modes(modes)
u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname,
u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname,
realhost=realhost, ip=ip, manipulatable=manipulatable)
self.apply_modes(uid, modes)
self.servers[server].users.add(uid)
self._send_with_prefix(server, "UID {nick} {hopcount} {ts} {modes} {ident} {host} {ip} {uid} "
"* :{realname}".format(ts=ts, host=host,
nick=nick, ident=ident, uid=uid,
@ -188,13 +191,14 @@ class HybridProtocol(TS6Protocol):
nick = args[0]
self._check_nick_collision(nick)
ts, modes, ident, host, ip, uid, account, realname = args[2:10]
ts = int(ts)
if account == '*':
account = None
log.debug('(%s) handle_uid: got args nick=%s ts=%s uid=%s ident=%s '
'host=%s realname=%s ip=%s', self.name, nick, ts, uid,
ident, host, realname, ip)
self.users[uid] = User(self, nick, ts, uid, numeric, ident, host, realname, host, ip)
self.users[uid] = User(self, nick, ts, uid, numeric, ident, host, realname, host, ip)
parsedmodes = self.parse_modes(uid, [modes])
log.debug('(%s) handle_uid: Applying modes %s for %s', self.name, parsedmodes, uid)

View File

@ -63,8 +63,9 @@ class InspIRCdProtocol(TS6BaseProtocol):
realname = realname or conf.conf['pylink']['realname']
realhost = realhost or host
raw_modes = self.join_modes(modes)
u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname,
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host,
realname=realname, realhost=realhost, ip=ip,
manipulatable=manipulatable, opertype=opertype)
self.apply_modes(uid, modes)
self.servers[server].users.add(uid)
@ -598,9 +599,12 @@ class InspIRCdProtocol(TS6BaseProtocol):
"""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
uid, ts, nick, realhost, host, ident, ip = args[0:7]
ts = int(ts)
self._check_nick_collision(nick)
realname = args[-1]
self.users[uid] = userobj = User(self, nick, ts, uid, numeric, ident, host, realname, realhost, ip)
self.users[uid] = userobj = User(self, nick, ts, uid, numeric, ident, host, realname, realhost, ip)
parsedmodes = self.parse_modes(uid, [args[8], args[9]])
self.apply_modes(uid, parsedmodes)

View File

@ -88,8 +88,10 @@ class NgIRCdProtocol(IRCS2SProtocol):
realname = realname or conf.conf['pylink']['realname']
uid = self._uidgen.next_uid(prefix=nick)
userobj = self.users[uid] = User(self, nick, ts or int(time.time()), uid, server, ident=ident, host=host, realname=realname,
manipulatable=manipulatable, opertype=opertype, realhost=host)
userobj = self.users[uid] = User(self, nick, ts or int(time.time()), uid, server,
ident=ident, host=host, realname=realname,
manipulatable=manipulatable, opertype=opertype,
realhost=host)
self.apply_modes(uid, modes)
self.servers[server].users.add(uid)
@ -451,7 +453,8 @@ class NgIRCdProtocol(IRCS2SProtocol):
realname = args[-1]
ts = int(time.time())
self.users[uid] = User(self, nick, ts, uid, source, ident=ident, host=host, realname=realname, realhost=host)
self.users[uid] = User(self, nick, ts, uid, source, ident=ident, host=host,
realname=realname, realhost=host)
parsedmodes = self.parse_modes(uid, [args[5]])
self.apply_modes(uid, parsedmodes)

View File

@ -306,7 +306,7 @@ class P10Protocol(IRCS2SProtocol):
raw_modes = self.join_modes(modes)
# Initialize an User instance
u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname,
u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname,
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
# Fill in modes and add it to our users index
@ -919,6 +919,7 @@ class P10Protocol(IRCS2SProtocol):
nick = args[0]
self._check_nick_collision(nick)
ts, ident, host = args[2:5]
ts = int(ts)
realhost = host
ip = args[-3]
ip = self.decode_p10_ip(ip)
@ -929,7 +930,7 @@ class P10Protocol(IRCS2SProtocol):
'host=%s realname=%s realhost=%s ip=%s', self.name, nick, ts, uid,
ident, host, realname, realhost, ip)
uobj = self.users[uid] = User(self, nick, ts, uid, source, ident, host, realname, realhost, ip)
uobj = self.users[uid] = User(self, nick, ts, uid, source, ident, host, realname, realhost, ip)
self.servers[source].users.add(uid)
# https://github.com/evilnet/nefarious2/blob/master/doc/p10.txt#L708

View File

@ -561,6 +561,7 @@ class TS6Protocol(TS6BaseProtocol):
nick = args[0]
self._check_nick_collision(nick)
ts, modes, ident, host, ip, uid, realhost, accountname, realname = args[2:11]
ts = int(ts)
if realhost == '*':
realhost = host
@ -572,7 +573,7 @@ class TS6Protocol(TS6BaseProtocol):
if ip == '0': # IP was invalid; something used for services.
ip = '0.0.0.0'
self.users[uid] = User(self, nick, ts, uid, numeric, ident, host, realname, realhost, ip)
self.users[uid] = User(self, nick, ts, uid, numeric, ident, host, realname, realhost, ip)
parsedmodes = self.parse_modes(uid, [modes])
log.debug('Applying modes %s for %s', parsedmodes, uid)

View File

@ -395,6 +395,7 @@ class UnrealProtocol(TS6BaseProtocol):
nick = args[0]
self._check_nick_collision(nick)
ts, ident, realhost, uid, accountname, modestring, host = args[2:9]
ts = int(ts)
if host == '*':
# A single * means that there is no displayed/virtual host, and
@ -421,7 +422,7 @@ class UnrealProtocol(TS6BaseProtocol):
realname = args[-1]
self.users[uid] = User(self, nick, ts, uid, numeric, ident, host, realname, realhost, ip)
self.users[uid] = User(self, nick, ts, uid, numeric, ident, host, realname, realhost, ip)
self.servers[numeric].users.add(uid)
# Handle user modes