From 3595e5fdbf5b6705349e2c11362318de59b796dd Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 9 Dec 2016 22:07:27 -0800 Subject: [PATCH 1/5] changehost: limit 'applyhosts' to those with the changehost.applyhosts perm (cherry picked from commit 12a85092990743d46808544e35a787e5e048ab8c) --- plugins/changehost.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/changehost.py b/plugins/changehost.py index ec87997..a84d127 100644 --- a/plugins/changehost.py +++ b/plugins/changehost.py @@ -3,6 +3,7 @@ Changehost plugin - automatically changes the hostname of matching users. """ from pylinkirc import utils, world, conf from pylinkirc.log import log +from pylinkirc.coremods import permissions import string @@ -87,6 +88,8 @@ def applyhosts(irc, sender, args): Applies all configured hosts for users on the given network, or the current network if none is specified.""" + permissions.checkPermissions(irc, sender, ['changehost.applyhosts']) + try: # Try to get network from the command line. network = world.networkobjects[args[0]] except IndexError: # No network was given From 930443f4cd969d8c75047b84a61965ed3a3a65b6 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 19 Dec 2016 22:29:25 -0800 Subject: [PATCH 2/5] PyLink 1.0.4 --- RELNOTES.md | 20 ++++++++++++++++++-- VERSION | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/RELNOTES.md b/RELNOTES.md index 978196d..7ee34fe 100644 --- a/RELNOTES.md +++ b/RELNOTES.md @@ -1,5 +1,21 @@ -# PyLink 1.0.3 -Tagged as **1.0.3** by [GLolol](https://github.com/GLolol) +# PyLink 1.0.4 +Tagged as **1.0.4** by [GLolol](https://github.com/GLolol) + +The "Bonfire" release. + +#### Bug fixes +- protocols: implement basic nick collision detection in UID handlers. This fixes users potentially going missing on UnrealIRCd networks, if the remote IRCd introduces a user of the same nick *after* PyLink does. Thanks to kevin for reporting! +- relay: strip underscores (`_`) from hosts on ts6 and ratbox, fixing possible invalid user@host errors +- Backported fixes from 1.1.x / devel: + - Demote "unknown user" warnings in mode handling to DEBUG, suppressing warnings when old services like Anope 1.8 set modes on users as they quit. + - Fix `irc.matchHost()` confusing the `realhost` boolean to be the same as `ip`. + - changehost: add missing permissions check to `applyhosts`; it now requires the `changehost.applyhost` permission. + +#### Misc changes +- networks: update help for `disconnect` to reflect how it now always disables autoconnect. + +# [PyLink 1.0.3](https://github.com/GLolol/PyLink/releases/tag/1.0.3) +Tagged as **1.0.3** by [GLolol](https://github.com/GLolol) on 2016-11-20T04:51:11Z The "Buoyant" release. diff --git a/VERSION b/VERSION index 21e8796..ee90284 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.3 +1.0.4 From d5eb01b724aada59ccb0817da6291c84e1a4fe36 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 1 Jan 2017 20:24:34 -0800 Subject: [PATCH 3/5] protocols: move handle_pong into ircs2s_common, be less strict about the ping argument This fixes issues on UnrealIRCd where PONGs get ignored if the argument doesn't match the server name entirely (e.g. different case). Treating all PONGs from the uplink as valid is totally fine, as all we care about is that the uplink is alive. (cherry picked from commit 38350465c1dcc3f45fafc5706aaacb37e534b9bb) --- protocols/inspircd.py | 9 --------- protocols/ircs2s_common.py | 5 +++++ protocols/nefarious.py | 6 ------ protocols/ts6.py | 6 ------ protocols/unreal.py | 6 ------ 5 files changed, 5 insertions(+), 27 deletions(-) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 0eeb004..8d68b31 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -508,15 +508,6 @@ class InspIRCdProtocol(TS6BaseProtocol): if self.irc.isInternalServer(args[1]): self._send(args[1], 'PONG %s %s' % (args[1], source)) - def handle_pong(self, source, command, args): - """Handles incoming PONG commands. - - This is used to keep track of whether the uplink is alive by the Irc() - internals - a server that fails to reply to our PINGs eventually - times out and is disconnected.""" - if source == self.irc.uplink and args[1] == self.irc.sid: - self.irc.lastping = time.time() - def handle_fjoin(self, servernumeric, command, args): """Handles incoming FJOIN commands (InspIRCd equivalent of JOIN/SJOIN).""" # :70M FJOIN #chat 1423790411 +AFPfjnt 6:5 7:5 9:5 :o,1SRAABIT4 v,1IOAAF53R <...> diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index c8542fb..0feef81 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -98,3 +98,8 @@ class IRCS2SProtocol(Protocol): def handle_time(self, numeric, command, args): """Handles incoming /TIME requests.""" return {'target': args[0]} + + def handle_pong(self, source, command, args): + """Handles incoming PONG commands.""" + if source == self.irc.uplink: + self.irc.lastping = time.time() diff --git a/protocols/nefarious.py b/protocols/nefarious.py index 235777a..03987c8 100644 --- a/protocols/nefarious.py +++ b/protocols/nefarious.py @@ -966,12 +966,6 @@ class P10Protocol(IRCS2SProtocol): if args[0] != self.irc.serverdata['recvpass']: raise ProtocolError("Error: RECVPASS from uplink does not match configuration!") - def handle_pong(self, source, command, args): - """Handles incoming PONGs.""" - # <- AB Z AB :Ay - if source == self.irc.uplink: - self.irc.lastping = time.time() - def handle_burst(self, source, command, args): """Handles the BURST command, used for bursting channels on link. diff --git a/protocols/ts6.py b/protocols/ts6.py index 4f0b2fb..b06ee91 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -411,12 +411,6 @@ class TS6Protocol(TS6BaseProtocol): # Return the endburst hook. return {'parse_as': 'ENDBURST'} - - def handle_pong(self, source, command, args): - """Handles incoming PONG commands.""" - if source == self.irc.uplink: - self.irc.lastping = time.time() - def handle_sjoin(self, servernumeric, command, args): """Handles incoming SJOIN commands.""" # parameters: channelTS, channel, simple modes, opt. mode parameters..., nicklist diff --git a/protocols/unreal.py b/protocols/unreal.py index 9b670df..04c8b79 100644 --- a/protocols/unreal.py +++ b/protocols/unreal.py @@ -404,12 +404,6 @@ class UnrealProtocol(TS6BaseProtocol): if numeric == self.irc.uplink: self.irc.send('PONG %s :%s' % (self.irc.serverdata['hostname'], args[-1])) - def handle_pong(self, source, command, args): - log.debug('(%s) Ping received from %s for %s.', self.irc.name, source, args[-1]) - if source in (self.irc.uplink, self.irc.servers[self.irc.uplink].name) and args[-1] == self.irc.serverdata['hostname']: - log.debug('(%s) Set self.irc.lastping.', self.irc.name) - self.irc.lastping = time.time() - def handle_server(self, numeric, command, args): """Handles the SERVER command, which is used for both authentication and introducing legacy (non-SID) servers.""" From 4020c3dea19ac7624ec15b076224845aa79a2c2c Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 1 Jan 2017 20:39:34 -0800 Subject: [PATCH 4/5] ircs2s_common: fix last commit (missing import) (cherry picked from commit 6a90401d563567ead0823be0a9a5b6b77f9f4378) --- protocols/ircs2s_common.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index 0feef81..65c8d6e 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -2,6 +2,8 @@ ircs2s_common.py: Common base protocol class with functions shared by TS6 and P10-based protocols. """ +import time + from pylinkirc.classes import Protocol from pylinkirc.log import log From 8878f776366386111434d4c9c871f0a89b211208 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 6 Jan 2017 21:56:22 -0800 Subject: [PATCH 5/5] updateTS: don't save any broken TS values lower than 750000 Workaround for #385, and other related timestamp issues caused by the TS value getting cut off in mode messages (#283) (cherry picked from commit ba330bbfac5c542bb2fc0661d01e1fd203253308) --- classes.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/classes.py b/classes.py index 1320ea4..0ef809a 100644 --- a/classes.py +++ b/classes.py @@ -1295,9 +1295,12 @@ class Protocol(): _apply() elif (their_ts < our_ts): - log.debug('(%s) Resetting channel TS of %s from %s to %s (remote has lower TS)', - self.irc.name, channel, our_ts, their_ts) - self.irc.channels[channel].ts = their_ts + if their_ts < 750000: + log.warning('(%s) Possible desync? Not setting bogus TS %s on channel %s', self.irc.name, their_ts, channel) + else: + log.debug('(%s) Resetting channel TS of %s from %s to %s (remote has lower TS)', + self.irc.name, channel, our_ts, their_ts) + self.irc.channels[channel].ts = their_ts # Remote TS was lower and we're receiving modes. Clear the modelist and apply theirs.