diff --git a/protocols/hybrid.py b/protocols/hybrid.py index 60df8de..16e9cc6 100644 --- a/protocols/hybrid.py +++ b/protocols/hybrid.py @@ -115,10 +115,11 @@ class HybridProtocol(TS6Protocol): realhost=realhost, ip=ip, manipulatable=manipulatable) self.apply_modes(uid, modes) self.servers[server].users.add(uid) - self._send_with_prefix(server, "UID {nick} 1 {ts} {modes} {ident} {host} {ip} {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, - modes=raw_modes, ip=ip, realname=realname)) + modes=raw_modes, ip=ip, realname=realname, + hopcount=self.servers[server].hopcount)) return u def update_client(self, target, field, text): diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 1e3bfa0..98adc5e 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -56,17 +56,17 @@ class InspIRCdProtocol(TS6BaseProtocol): realname = realname or conf.conf['bot']['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, opertype=opertype) self.apply_modes(uid, modes) self.servers[server].users.add(uid) self._send_with_prefix(server, "UID {uid} {ts} {nick} {realhost} {host} {ident} {ip}" - " {ts} {modes} + :{realname}".format(ts=ts, host=host, - nick=nick, ident=ident, uid=uid, - modes=raw_modes, ip=ip, realname=realname, - realhost=realhost)) + " {ts} {modes} + :{realname}".format(ts=ts, host=host, + nick=nick, ident=ident, uid=uid, + modes=raw_modes, ip=ip, realname=realname, + realhost=realhost)) if ('o', None) in modes or ('+o', None) in modes: self._oper_up(uid, opertype) return u @@ -355,8 +355,9 @@ class InspIRCdProtocol(TS6BaseProtocol): raise ValueError('Server %r is not a PyLink server!' % uplink) if not self.is_server_name(name): raise ValueError('Invalid server name %r' % name) - self._send_with_prefix(uplink, 'SERVER %s * 1 %s :%s' % (name, sid, desc)) + self.servers[sid] = Server(self, uplink, name, internal=True, desc=desc) + self._send_with_prefix(uplink, 'SERVER %s * %s %s :%s' % (name, self.servers[sid].hopcount, sid, desc)) def endburstf(): # Delay ENDBURST by X seconds if requested. diff --git a/protocols/ngircd.py b/protocols/ngircd.py index b29010d..6a08763 100644 --- a/protocols/ngircd.py +++ b/protocols/ngircd.py @@ -97,7 +97,8 @@ class NgIRCdProtocol(IRCS2SProtocol): # Grab our server token; this is used instead of server name to denote where the client is. server_token = server.rsplit('@')[-1] # <- :ngircd.midnight.local NICK GL 1 ~gl localhost 1 +io :realname - self._send_with_prefix(server, 'NICK %s 1 %s %s %s %s :%s' % (nick, ident, host, server_token, self.join_modes(modes), realname)) + self._send_with_prefix(server, 'NICK %s %s %s %s %s %s :%s' % (nick, self.servers[server].hopcount, + ident, host, server_token, self.join_modes(modes), realname)) return userobj def spawn_server(self, name, sid=None, uplink=None, desc=None, endburst_delay=0): @@ -130,8 +131,8 @@ class NgIRCdProtocol(IRCS2SProtocol): # We need to store a server token to introduce clients on the right server. Since this is just # a number, we can simply use the counter in our PSID generator for this. server_token = sid.rsplit('@')[-1] - self._send_with_prefix(uplink, 'SERVER %s 1 %s :%s' % (name, server_token, desc)) self.servers[sid] = Server(self, uplink, name, internal=True, desc=desc) + self._send_with_prefix(uplink, 'SERVER %s %s %s :%s' % (name, self.servers[sid].hopcount, server_token, desc)) return sid def away(self, source, text): diff --git a/protocols/p10.py b/protocols/p10.py index b0fc364..b6dbfe6 100644 --- a/protocols/p10.py +++ b/protocols/p10.py @@ -319,10 +319,10 @@ class P10Protocol(IRCS2SProtocol): else: b64ip = 'AAAAAA' - self._send_with_prefix(server, "N {nick} 1 {ts} {ident} {host} {modes} {ip} {uid} " - ":{realname}".format(ts=ts, host=host, nick=nick, ident=ident, uid=uid, - modes=raw_modes, ip=b64ip, realname=realname, - realhost=realhost)) + self._send_with_prefix(server, "N {nick} {hopcount} {ts} {ident} {host} {modes} {ip} {uid} " + ":{realname}".format(ts=ts, host=host, nick=nick, ident=ident, uid=uid, + modes=raw_modes, ip=b64ip, realname=realname, + realhost=realhost, hopcount=self.servers[server].hopcount)) return u def away(self, source, text): @@ -696,10 +696,10 @@ class P10Protocol(IRCS2SProtocol): if not self.is_server_name(name): raise ValueError('Invalid server name %r' % name) - self._send_with_prefix(uplink, 'SERVER %s 1 %s %s P10 %s]]] +h6 :%s' % \ - (name, self.start_ts, int(time.time()), sid, desc)) - self.servers[sid] = Server(self, uplink, name, internal=True, desc=desc) + self._send_with_prefix(uplink, 'SERVER %s %s %s %s P10 %s]]] +h6 :%s' % \ + (name, self.servers[sid].hopcount, self.start_ts, int(time.time()), sid, desc)) + return sid def squit(self, source, target, text='No reason given'): diff --git a/protocols/ratbox.py b/protocols/ratbox.py index fb171eb..f4bd6d7 100644 --- a/protocols/ratbox.py +++ b/protocols/ratbox.py @@ -77,10 +77,11 @@ class RatboxProtocol(TS6Protocol): self.apply_modes(uid, modes) self.servers[server].users.add(uid) - self._send_with_prefix(server, "UID {nick} 1 {ts} {modes} {ident} {host} {ip} {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, - modes=raw_modes, ip=ip, realname=realname)) + modes=raw_modes, ip=ip, realname=realname, + hopcount=self.servers[server].hopcount)) if orig_realhost: # If real host is specified, send it using ENCAP REALHOST diff --git a/protocols/ts6.py b/protocols/ts6.py index aab7dd4..d8a2d9e 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -58,11 +58,11 @@ class TS6Protocol(TS6BaseProtocol): self.apply_modes(uid, modes) self.servers[server].users.add(uid) - self._send_with_prefix(server, "EUID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} " - "{realhost} * :{realname}".format(ts=ts, host=host, - nick=nick, ident=ident, uid=uid, - modes=raw_modes, ip=ip, realname=realname, - realhost=realhost)) + self._send_with_prefix(server, "EUID {nick} {hopcount} {ts} {modes} {ident} {host} {ip} {uid} " + "{realhost} * :{realname}".format(ts=ts, host=host, + nick=nick, ident=ident, uid=uid, + modes=raw_modes, ip=ip, realname=realname, + realhost=realhost, hopcount=self.servers[server].hopcount)) return u diff --git a/protocols/ts6_common.py b/protocols/ts6_common.py index 7fca9f6..f6215f8 100644 --- a/protocols/ts6_common.py +++ b/protocols/ts6_common.py @@ -169,6 +169,7 @@ class TS6BaseProtocol(IRCS2SProtocol): uplink = uplink or self.sid name = name.lower() desc = desc or self.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc'] + if sid is None: # No sid given; generate one! sid = self.sidgen.next_sid() assert len(sid) == 3, "Incorrect SID length" @@ -181,8 +182,9 @@ class TS6BaseProtocol(IRCS2SProtocol): raise ValueError('Server %r is not a PyLink server!' % uplink) if not self.is_server_name(name): raise ValueError('Invalid server name %r' % name) - self._send_with_prefix(uplink, 'SID %s 1 %s :%s' % (name, sid, desc)) + self.servers[sid] = Server(self, uplink, name, internal=True, desc=desc) + self._send_with_prefix(uplink, 'SID %s %s %s :%s' % (name, self.servers[sid].hopcount, sid, desc)) return sid def away(self, source, text): diff --git a/protocols/unreal.py b/protocols/unreal.py index 87f44e5..05186db 100644 --- a/protocols/unreal.py +++ b/protocols/unreal.py @@ -93,11 +93,12 @@ class UnrealProtocol(TS6BaseProtocol): encoded_ip = encoded_ip.strip().decode() # <- :001 UID GL 0 1441306929 gl localhost 0018S7901 0 +iowx * midnight-1C620195 fwAAAQ== :realname - self._send_with_prefix(server, "UID {nick} 0 {ts} {ident} {realhost} {uid} 0 {modes} " - "{host} * {ip} :{realname}".format(ts=ts, host=host, - nick=nick, ident=ident, uid=uid, - modes=raw_modes, realname=realname, - realhost=realhost, ip=encoded_ip)) + self._send_with_prefix(server, "UID {nick} {hopcount} {ts} {ident} {realhost} {uid} 0 {modes} " + "{host} * {ip} :{realname}".format(ts=ts, host=host, + nick=nick, ident=ident, uid=uid, + modes=raw_modes, realname=realname, + realhost=realhost, ip=encoded_ip, + hopcount=self.servers[server].hopcount)) return u