3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-23 18:54:05 +01:00

protocols: remove the endburst_delay option from spawn_server

Interestingly, this was never documented in the protocol module spec...
This commit is contained in:
James Lu 2018-02-10 15:39:01 -08:00
parent a425f873b5
commit ea84497359
5 changed files with 14 additions and 16 deletions

View File

@ -129,7 +129,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
return u 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. STUB: Pretends to spawn a new server with a subset of the given options.
""" """

View File

@ -331,33 +331,38 @@ class InspIRCdProtocol(TS6BaseProtocol):
self._send_with_prefix(source, 'AWAY') self._send_with_prefix(source, 'AWAY')
self.users[source].away = text 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) Spawns a server off a PyLink server. desc (server description)
defaults to the one in the config. uplink defaults to the main PyLink defaults to the one in the config. uplink defaults to the main PyLink
server, and sid (the server ID) is automatically generated if not server, and sid (the server ID) is automatically generated if not
given. given.
If endburst_delay is set greater than zero, the sending of ENDBURST Endburst delay can be tweaked by setting the _endburst_delay variable
will be delayed by the amount given. This can be used to prevent to a positive value before calling spawn_server(). This can be used to
pseudoserver bursts from triggering IRCd join-flood preventions, prevent PyLink bursts from filling up snomasks and triggering InspIRCd +j.
and prevent connections from filling up the snomasks too much.
""" """
# -> :0AL SERVER test.server * 1 0AM :some silly pseudoserver # -> :0AL SERVER test.server * 1 0AM :some silly pseudoserver
uplink = uplink or self.sid uplink = uplink or self.sid
name = name.lower() name = name.lower()
# "desc" defaults to the configured server description. # "desc" defaults to the configured server description.
desc = desc or self.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc'] desc = desc or self.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']
if sid is None: # No sid given; generate one! if sid is None: # No sid given; generate one!
sid = self.sidgen.next_sid() sid = self.sidgen.next_sid()
assert len(sid) == 3, "Incorrect SID length" assert len(sid) == 3, "Incorrect SID length"
if sid in self.servers: if sid in self.servers:
raise ValueError('A server with SID %r already exists!' % sid) raise ValueError('A server with SID %r already exists!' % sid)
for server in self.servers.values(): for server in self.servers.values():
if name == server.name: if name == server.name:
raise ValueError('A server named %r already exists!' % name) raise ValueError('A server named %r already exists!' % name)
if not self.is_internal_server(uplink): if not self.is_internal_server(uplink):
raise ValueError('Server %r is not a PyLink server!' % uplink) raise ValueError('Server %r is not a PyLink server!' % uplink)
if not self.is_server_name(name): if not self.is_server_name(name):
raise ValueError('Invalid server name %r' % name) raise ValueError('Invalid server name %r' % name)

View File

@ -101,15 +101,13 @@ class NgIRCdProtocol(IRCS2SProtocol):
ident, host, server_token, self.join_modes(modes), realname)) ident, host, server_token, self.join_modes(modes), realname))
return userobj 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. Spawns a server off a PyLink server.
* desc (server description) defaults to the one in the config. * desc (server description) defaults to the one in the config.
* uplink defaults to the main PyLink server. * uplink defaults to the main PyLink server.
* SID is set equal to the server name for ngIRCd, as server UIDs are not used. * 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 uplink = uplink or self.sid
assert uplink in self.servers, "Unknown uplink %r?" % uplink assert uplink in self.servers, "Unknown uplink %r?" % uplink

View File

@ -698,14 +698,12 @@ class P10Protocol(IRCS2SProtocol):
self.updateTS(server, channel, ts, changedmodes) 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) Spawns a server off a PyLink server. desc (server description)
defaults to the one in the config. uplink defaults to the main PyLink defaults to the one in the config. uplink defaults to the main PyLink
server, and sid (the server ID) is automatically generated if not server, and sid (the server ID) is automatically generated if not
given. 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 # <- SERVER nefarious.midnight.vpn 1 1460673022 1460673239 J10 ABP]] +h6 :Nefarious2 test server
uplink = uplink or self.sid uplink = uplink or self.sid

View File

@ -159,15 +159,12 @@ class TS6BaseProtocol(IRCS2SProtocol):
# Update the NICK TS. # Update the NICK TS.
self.users[numeric].ts = int(time.time()) 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) Spawns a server off a PyLink server. desc (server description)
defaults to the one in the config. uplink defaults to the main PyLink defaults to the one in the config. uplink defaults to the main PyLink
server, and sid (the server ID) is automatically generated if not server, and sid (the server ID) is automatically generated if not
given. 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 # -> :0AL SID test.server 1 0XY :some silly pseudoserver
uplink = uplink or self.sid uplink = uplink or self.sid