diff --git a/protocols/clientbot.py b/protocols/clientbot.py index bc48744..1f262aa 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -129,7 +129,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): return u - def spawn_server(self, name, sid=None, uplink=None, desc=None, endburst_delay=0, internal=True): + def spawn_server(self, name, sid=None, uplink=None, desc=None, internal=True): """ STUB: Pretends to spawn a new server with a subset of the given options. """ diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 35ec464..82a3c89 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -331,33 +331,38 @@ class InspIRCdProtocol(TS6BaseProtocol): self._send_with_prefix(source, 'AWAY') self.users[source].away = text - def spawn_server(self, name, sid=None, uplink=None, desc=None, endburst_delay=0): + def spawn_server(self, name, sid=None, uplink=None, desc=None): """ Spawns a server off a PyLink server. desc (server description) defaults to the one in the config. uplink defaults to the main PyLink server, and sid (the server ID) is automatically generated if not given. - If endburst_delay is set greater than zero, the sending of ENDBURST - will be delayed by the amount given. This can be used to prevent - pseudoserver bursts from triggering IRCd join-flood preventions, - and prevent connections from filling up the snomasks too much. + Endburst delay can be tweaked by setting the _endburst_delay variable + to a positive value before calling spawn_server(). This can be used to + prevent PyLink bursts from filling up snomasks and triggering InspIRCd +j. """ # -> :0AL SERVER test.server * 1 0AM :some silly pseudoserver uplink = uplink or self.sid name = name.lower() + # "desc" defaults to the configured server description. 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" if sid in self.servers: raise ValueError('A server with SID %r already exists!' % sid) + for server in self.servers.values(): if name == server.name: raise ValueError('A server named %r already exists!' % name) + if not self.is_internal_server(uplink): raise ValueError('Server %r is not a PyLink server!' % uplink) + if not self.is_server_name(name): raise ValueError('Invalid server name %r' % name) diff --git a/protocols/ngircd.py b/protocols/ngircd.py index 6a08763..360b8df 100644 --- a/protocols/ngircd.py +++ b/protocols/ngircd.py @@ -101,15 +101,13 @@ class NgIRCdProtocol(IRCS2SProtocol): 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): + def spawn_server(self, name, sid=None, uplink=None, desc=None): """ Spawns a server off a PyLink server. * desc (server description) defaults to the one in the config. * uplink defaults to the main PyLink server. * SID is set equal to the server name for ngIRCd, as server UIDs are not used. - - Endburst delay is not used on ngIRCd. """ uplink = uplink or self.sid assert uplink in self.servers, "Unknown uplink %r?" % uplink diff --git a/protocols/p10.py b/protocols/p10.py index 48a34d9..6ff9eee 100644 --- a/protocols/p10.py +++ b/protocols/p10.py @@ -698,14 +698,12 @@ class P10Protocol(IRCS2SProtocol): self.updateTS(server, channel, ts, changedmodes) - def spawn_server(self, name, sid=None, uplink=None, desc=None, endburst_delay=0): + def spawn_server(self, name, sid=None, uplink=None, desc=None): """ Spawns a server off a PyLink server. desc (server description) defaults to the one in the config. uplink defaults to the main PyLink server, and sid (the server ID) is automatically generated if not given. - - Note: the endburst_delay is not implemented for P10 and will be ignored. """ # <- SERVER nefarious.midnight.vpn 1 1460673022 1460673239 J10 ABP]] +h6 :Nefarious2 test server uplink = uplink or self.sid diff --git a/protocols/ts6_common.py b/protocols/ts6_common.py index 7b366af..ffa7fd4 100644 --- a/protocols/ts6_common.py +++ b/protocols/ts6_common.py @@ -159,15 +159,12 @@ class TS6BaseProtocol(IRCS2SProtocol): # Update the NICK TS. self.users[numeric].ts = int(time.time()) - def spawn_server(self, name, sid=None, uplink=None, desc=None, endburst_delay=0): + def spawn_server(self, name, sid=None, uplink=None, desc=None): """ Spawns a server off a PyLink server. desc (server description) defaults to the one in the config. uplink defaults to the main PyLink server, and sid (the server ID) is automatically generated if not given. - - Note: TS6 doesn't use a specific ENDBURST command, so the endburst_delay - option will be ignored if given. """ # -> :0AL SID test.server 1 0XY :some silly pseudoserver uplink = uplink or self.sid