diff --git a/classes.py b/classes.py index 93c6e36..74bfa72 100644 --- a/classes.py +++ b/classes.py @@ -1117,7 +1117,7 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils): def _schedule_ping(self): """Schedules periodic pings in a loop.""" - self.ping() + self._ping_uplink() self.pingTimer = threading.Timer(self.pingfreq, self._schedule_ping) self.pingTimer.daemon = True diff --git a/protocols/clientbot.py b/protocols/clientbot.py index 0da9874..40aa8b1 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -245,9 +245,9 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): # Wrap around message(), which does all the text formatting for us. self.message(source, target, text, notice=True) - def ping(self, source=None, target=None): + def _ping_uplink(self): """ - Sends PING to the uplink. + Sends a PING to the uplink. """ if self.uplink: self.send('PING %s' % self.get_friendly_name(self.uplink)) diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index 6667284..488c18d 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -358,18 +358,12 @@ class IRCS2SProtocol(IRCCommonProtocol): self._send_with_prefix(client, msg) self.handle_part(client, 'PART', [channel]) - def ping(self, source=None, target=None): - """Sends a PING to a target server. + def _ping_uplink(self): + """Sends a PING to the uplink. This is mostly used by PyLink internals to check whether the remote link is up.""" - source = source or self.sid - if source is None: # Source hasn't been initialized yet; ignore this command - return - - if target is not None: - self._send_with_prefix(source, 'PING %s %s' % (source, target)) - else: - self._send_with_prefix(source, 'PING %s' % source) + if self.sid: + self._send_with_prefix(self.sid, 'PING %s' % self.sid) def quit(self, numeric, reason): """Quits a PyLink client.""" diff --git a/protocols/ngircd.py b/protocols/ngircd.py index 1ff41b3..02a88dc 100644 --- a/protocols/ngircd.py +++ b/protocols/ngircd.py @@ -72,7 +72,6 @@ class NgIRCdProtocol(IRCS2SProtocol): def spawn_server(self, name, sid=None, uplink=None, desc=None, endburst_delay=0): - pass ''' """ Spawns a server off a PyLink server. @@ -80,9 +79,6 @@ class NgIRCdProtocol(IRCS2SProtocol): * 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. - - 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 @@ -106,10 +102,12 @@ class NgIRCdProtocol(IRCS2SProtocol): ''' def join(self, client, channel): - return - - def ping(self, *args): - self.lastping = time.time() + channel = self.to_lower(channel) + if not self.is_internal_client(client): + raise LookupError('No such PyLink client exists.') + self._send_with_prefix(client, "JOIN %s" % channel) + self.channels[channel].users.add(client) + self.users[client].channels.add(channel) ### Handlers diff --git a/protocols/p10.py b/protocols/p10.py index d9788a1..1d4197d 100644 --- a/protocols/p10.py +++ b/protocols/p10.py @@ -471,16 +471,10 @@ class P10Protocol(IRCS2SProtocol): self._send_with_prefix(client, msg) self.handle_part(client, 'PART', [channel]) - def ping(self, source=None, target=None): - """Sends a PING to a target server. Periodic PINGs are sent to our uplink - automatically by the Irc() internals; plugins shouldn't have to use this.""" - source = source or self.sid - if source is None: - return - if target is not None: - self._send_with_prefix(source, 'G %s %s' % (source, target)) - else: - self._send_with_prefix(source, 'G %s' % source) + def _ping_uplink(self): + """Sends a PING to the uplink.""" + if self.sid: + self._send_with_prefix(self.sid, 'G %s' % self.sid) def quit(self, numeric, reason): """Quits a PyLink client.""" diff --git a/protocols/ts6.py b/protocols/ts6.py index 10943e0..37c63d0 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -332,7 +332,7 @@ class TS6Protocol(TS6BaseProtocol): # Finally, end all the initialization with a PING - that's Charybdis' # way of saying end-of-burst :) - self.ping() + self._ping_uplink() def handle_pass(self, numeric, command, args): """ @@ -399,7 +399,7 @@ class TS6Protocol(TS6BaseProtocol): self._send_with_prefix(destination, 'PONG %s %s' % (destination, source), queue=False) if destination == self.sid and not self.has_eob: - # Charybdis' idea of endburst is just sending a PING. No, really! + # Charybdis' endburst is just sending a PING to the other server. # https://github.com/charybdis-ircd/charybdis/blob/dc336d1/modules/core/m_server.c#L484-L485 self.has_eob = True diff --git a/protocols/unreal.py b/protocols/unreal.py index df469d8..6e3ea49 100644 --- a/protocols/unreal.py +++ b/protocols/unreal.py @@ -187,13 +187,10 @@ class UnrealProtocol(TS6BaseProtocol): self.updateTS(server, channel, ts, changedmodes) - def ping(self, source=None, target=None): - """Sends a PING to a target server. Periodic PINGs are sent to our uplink - automatically by the Irc() internals; plugins shouldn't have to use this.""" - source = source or self.sid - target = target or self.uplink - if not (target is None or source is None): - self._send_with_prefix(source, 'PING %s %s' % (self.servers[source].name, self.servers[target].name)) + def _ping_uplink(self): + """Sends a PING to the uplink.""" + if self.sid and self.uplink: + self._send_with_prefix(self.sid, 'PING %s %s' % (self.get_friendly_name(self.sid), self.get_friendly_name(self.uplink))) def mode(self, numeric, target, modes, ts=None): """