From 59a4ecdcb9f4fdd558b22f7977cc5f7ad8f3f15b Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 10 Jul 2017 22:06:08 -0700 Subject: [PATCH 01/25] automode: rewrap help for SET (cherry picked from commit 499e94e0a52c91f6bd4e143fd1d221990e4ee3da) --- plugins/automode.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/automode.py b/plugins/automode.py index d129bd4..c912d23 100644 --- a/plugins/automode.py +++ b/plugins/automode.py @@ -180,11 +180,16 @@ def setacc(irc, source, args): Channel pairs are also supported (for operations on remote channels), using the form "network#channel". + Examples: - SET #channel *!*@localhost ohv - SET #channel $account v - SET othernet#channel $oper:Network?Administrator qo - SET #staffchan $channel:#mainchan:op o + + \x02SET #channel *!*@localhost ohv + + \x02SET #channel $account v + + \x02SET othernet#channel $oper:Network?Administrator qo + + \x02SET #staffchan $channel:#mainchan:op o """ try: From 79db7b2124bad5080fe5e81c066212bb5d5d3aa3 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 10 Jul 2017 22:06:41 -0700 Subject: [PATCH 02/25] automode: fix $ircop exttarget name in setacc examples (cherry picked from commit 24caf36230849709707c867e6a33c1870bc630aa) --- plugins/automode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/automode.py b/plugins/automode.py index c912d23..7b55700 100644 --- a/plugins/automode.py +++ b/plugins/automode.py @@ -187,7 +187,7 @@ def setacc(irc, source, args): \x02SET #channel $account v - \x02SET othernet#channel $oper:Network?Administrator qo + \x02SET othernet#channel $ircop:Network?Administrator qo \x02SET #staffchan $channel:#mainchan:op o """ From 1f377adfeeadb1279210272b263f7f87b98eba2d Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 16 Jul 2017 07:34:45 -0700 Subject: [PATCH 03/25] p10: also acknowledge our own kicks with a PART (adapted from commit 1438f9e566a8f1778a448fd3fb3d1fc9da90a26b) --- protocols/p10.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/protocols/p10.py b/protocols/p10.py index 76dd10d..8b89d18 100644 --- a/protocols/p10.py +++ b/protocols/p10.py @@ -365,6 +365,11 @@ class P10Protocol(IRCS2SProtocol): # handle_part() does that just fine. self.handle_part(target, 'KICK', [channel]) + if self.irc.isInternalClient(target): + # Send PART in response to acknowledge the KICK, per + # https://github.com/evilnet/nefarious2/blob/ed12d64/doc/p10.txt#L611-L616 + self._send(target, 'L %s :%s' % (channel, reason)) + def kill(self, numeric, target, reason): """Sends a kill from a PyLink client/server.""" # <- ABAAA D AyAAA :nefarious.midnight.vpn!GL (test) From b4ef0d1b16f2844cd27c92e9396f500eef632bd9 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 20 Jul 2017 18:41:53 +0800 Subject: [PATCH 04/25] PyLink 1.2.0-rc1 --- RELNOTES.md | 33 +++++++++++++++++++++++++++++++++ VERSION | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/RELNOTES.md b/RELNOTES.md index f8baf8e..2c5a659 100644 --- a/RELNOTES.md +++ b/RELNOTES.md @@ -1,3 +1,35 @@ +# PyLink 1.2.0-rc1 + +The "Droplet" release. Changes since 1.2-beta1: + +#### Bug fixes +- relay: fix channel claim disabling (i.e. "`CLAIM #channel -`" was broken since 1.2-alpha1) +- IRCS2SProtocol: fix `UnboundLocalError` in "message coming from wrong wrong way" error +- ts6: fix parsing of the `INVITE` command's `ts` argument +- automode: fix formatting and examples in `setacc` help text +- p10: fix rejoin-on-kick relaying by also acknowledging kicks sent from PyLink to its clients with a PART + +### Major changes since 1.1.x +- Added support for snircd, ircu, and other (generic) P10 variants. The target IRCd can be chosen using the new server-specific `p10_ircd` option; see the example config for details (#330). +- **The `nefarious` protocol module was renamed to `p10`**, as it is no longer Nefarious-specific. You should update your configuration to use the new name! +- **Certain configuration options were renamed / deprecated:** + - The `bot:` configuration block was renamed to `pylink:`, with the old name now deprecated. + - `logging:stdout` is now `logging:console` (the previous name was a misnomer since text actually went to `stderr`). + - The `bot:prefix` option is deprecated: you should instead define the `prefixes` setting in a separate config block for each service you wish to customize (e.g. set `automode:prefix` and `games:prefix`) +- **Using new-style accounts exclusively (i.e. specifying things under `login:accounts`) now requires a `permissions:` block for PyLink to start** (#413). +- New `stats` (uptime info) and `global` (global announcement) plugins. +- Plugins and protocol modules can now be loaded from any directory, using the new `plugin_dirs` and `protocol_dirs` options. (#350) + - The `pylink-contribdl` utility was dropped as it is now it obsolete. +- Relay message formatting became more flexible, and messages from servers (e.g. spurious invite announcements) can now be dropped: look for the `relay_weird_senders` and `accept_weird_senders` options. +- Relay now forbids linking to channels where the home network is down, which previously caused errors due to unreliable target TS (#419). This, along with the regular TS check, can be overridden with a new `link --force` option. +- The `remote` command now routes replies back to the caller network, and supports service bots that aren't the main PyLink bot via a `--service` option. +- Service bot spawning can now be disabled via the global `spawn_services` and per-service `spawn_service` options; doing so will merge the relevant commands into the main PyLink bot. +- Added a `pylink::show_unknown_commands` option to optionally disable "unknown command" errors. This option can also be overridden per-server and per-service (#441). +- Added a `pylink::prefer_private_replies` option to default to private command replies (#409). +- Relay can now announce to leaf channels when the home network disconnects; see the `relay::disconnect_announcement` option (#421). + +For a full list of changes since 1.1.x, consult the changelogs for the 1.2.x beta and alpha releases below. + # PyLink 1.2-beta1 The "Dynamo" release. This release includes all fixes from 1.1.2, plus the following: @@ -73,6 +105,7 @@ The "Darkness" release. This release includes all fixes from 1.1.2, plus the fol - The `bot:` config block is renamed to `pylink:`. Existing configurations will still work, as the `bot` and `pylink` blocks are always merged together (#343). - Added better documentation for generic options available to all service bots (`nick`, `ident`, `prefix` for fantasy, etc.) - `Irc.botdata`, `Irc.conf`, `Irc.checkAuthenticated()` have been deprecated: use `conf.conf['pylink']`, `conf.conf`, and the permissions API respectively instead! + # PyLink 1.1.2 The "Calamari" release. diff --git a/VERSION b/VERSION index b2fac53..4edb02d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2-beta1 +1.2.0-rc1 From b90da19dfa17d827a022040124db4b2be86da201 Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 12 Jul 2017 22:17:00 -0700 Subject: [PATCH 05/25] control: log the name of the PID file on shutdown (cherry picked from commit d57e141fbce83ea5c91f292d5db805af8b515e68) --- coremods/control.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/coremods/control.py b/coremods/control.py index 3d273ce..78f1c54 100644 --- a/coremods/control.py +++ b/coremods/control.py @@ -25,11 +25,12 @@ def _print_remaining_threads(): def _remove_pid(): # Remove our pid file. - log.info("Removing our pid file.") + pidfile = "%s.pid" % conf.confname + log.info("Removing PID file %r.", pidfile) try: - os.remove("%s.pid" % conf.confname) + os.remove(pidfile) except OSError: - log.exception("Failed to remove PID, ignoring...") + log.exception("Failed to remove PID file %r, ignoring..." % pidfile) def _kill_plugins(irc=None): log.info("Shutting down plugins.") From dac0d5b234336e6864c4d1569086854dbe8bcc70 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 20 Jul 2017 21:33:17 +0800 Subject: [PATCH 06/25] core: Properly track whether we should actually remove the PID file Previously, PyLink spuriously removed PID files even if -n/--no-check-pid was set or if PID file checking caused PyLink to quit (cherry picked from commit 91659ea992e5be9fc645f8805a09c2dffef4148e) --- coremods/control.py | 15 +++++++++------ pylink | 1 + world.py | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/coremods/control.py b/coremods/control.py index 78f1c54..ad352ce 100644 --- a/coremods/control.py +++ b/coremods/control.py @@ -24,13 +24,16 @@ def _print_remaining_threads(): log.debug('_shutdown(): Remaining threads: %s', ['%s/%s' % (t.name, t.ident) for t in threading.enumerate()]) def _remove_pid(): - # Remove our pid file. pidfile = "%s.pid" % conf.confname - log.info("Removing PID file %r.", pidfile) - try: - os.remove(pidfile) - except OSError: - log.exception("Failed to remove PID file %r, ignoring..." % pidfile) + if world._should_remove_pid: + # Remove our pid file. + log.info("Removing PID file %r.", pidfile) + try: + os.remove(pidfile) + except OSError: + log.exception("Failed to remove PID file %r, ignoring..." % pidfile) + else: + log.debug('Not removing PID file %s as world._should_remove_pid is False.' % pidfile) def _kill_plugins(irc=None): log.info("Shutting down plugins.") diff --git a/pylink b/pylink index aea3b45..08166fb 100755 --- a/pylink +++ b/pylink @@ -58,6 +58,7 @@ if __name__ == '__main__': if not args.no_pid: with open('%s.pid' % conf.confname, 'w') as f: f.write(str(os.getpid())) + world._should_remove_pid = True # Import plugins first globally, because they can listen for events # that happen before the connection phase. diff --git a/world.py b/world.py index 7e81d4e..dd42640 100644 --- a/world.py +++ b/world.py @@ -33,3 +33,6 @@ fallback_hostname = 'pylink.int' # Defines messages to be logged as soon as the log system is set up, for modules like conf that are # initialized before log. This is processed (and then not used again) when the log module loads. log_queue = deque() + +# Determines whether we have a PID file that needs to be removed. +_should_remove_pid = False From bed40cc10a9d48b3c15d67de2765b2f6401ef2fe Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 30 Jul 2017 07:54:58 -0500 Subject: [PATCH 07/25] faq: add point about maxnicklen misconfigurations and relay (cherry picked from commit c7f300357c12e6c1aac1cf7fd7e76a42aef5f447) --- docs/faq.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index edbcbc9..ce6658d 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -35,3 +35,9 @@ In no particular order: - Proper protocol negotiation leading to fewer DoS possibilities: - Better support for channel modes such as +fjMOR, etc. - Configurable nick length limits for relayed users. + +### My IRCd SQUITs the relay server with errors like "Bad nickname introduced"! + +First, check whether the SQUIT message includes the nick that triggered the netsplit. If this nick includes any characters not allowed in regular IRC, such as the slash ("/"), or is otherwise an invalid nick (e.g. beginning with a hyphen or number), this likely indicates a bug in PyLink Relay. These problems should be reported on the issue tracker! + +However, if the nick mentioned is legal on IRC, this issue is likely caused by a max nick length misconfiguration: i.e. the relay server is introducing nicks too long for the target network. This can be fixed by setting the `maxnicklen` option in the affected network's PyLink `server:` block to the same value as that network's `005` `NICKLEN` (that is, the `NICKLEN=` value in `/raw version`). From 54dab5f1077fe819e7bf67172c0b8d5ddd15b5d6 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 30 Jul 2017 07:57:05 -0500 Subject: [PATCH 08/25] faq: remove obsolete note about clientbot support The answer is fairly obvious now, and it's even mentioned in the readme. (cherry picked from commit 01dc2505e2c2aff9ca0a30a22bca63eed220287f) --- docs/faq.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index ce6658d..3160955 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -12,10 +12,6 @@ You must use SPACES and not tabs in your configuration! (`\t` is the escaped cod PyLink does not support inbound connections - much like regular services such as Atheme or Anope, it only connects outwards *to* IRCds. (If you don't understand what this means, it means you should turn autoconnect OFF for PyLink) -### Does PyLink support Clientbot relay like Janus? - -Yes. However, Clientbot support is in alpha stages as of PyLink 0.10 and is far from complete: [Clientbot TODO](https://github.com/GLolol/PyLink/issues?q=is%3Aissue+is%3Aopen+label%3Aprotocols%2Fclientbot). - ### Clientbot doesn't relay both ways! Load the `relay_clientbot` plugin. https://github.com/GLolol/PyLink/blob/e1fab8c/example-conf.yml#L303-L306 From c16ca14fba372005e42572f4c53f96767fb1d79c Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 30 Jul 2017 23:40:26 +0800 Subject: [PATCH 09/25] faq: reword "advantages over Janus" section (cherry picked from commit 9dcc94129256e3d7f037514397fba11fc001d1e1) --- docs/faq.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 3160955..f1df808 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -22,15 +22,15 @@ Load the `relay_clientbot` plugin. https://github.com/GLolol/PyLink/blob/e1fab8c InterJanus-style links between PyLink daemons are not supported yet; see https://github.com/GLolol/PyLink/issues/99 for any progress regarding that. -### What are PyLink Relay's benefits over Janus? +### What are PyLink's advantages over Janus? -In no particular order: +PyLink provides, in no particular order: - More complete support for modern IRCds (UnrealIRCd 4.x, InspIRCd 2.0, charybdis 4, Nefarious IRCu, etc.). -- PyLink is built upon a flexible, maintainable codebase. -- Cross platform (*nix, Windows, and probably others too). -- Proper protocol negotiation leading to fewer DoS possibilities: +- A flexible, maintainable codebase extensible beyond Relay. +- Cross platform functionality (*nix, Windows, and probably others too). +- Proper protocol negotiation leading to fewer SQUIT/DoS possibilities: - Better support for channel modes such as +fjMOR, etc. - - Configurable nick length limits for relayed users. + - Proper support for nick length limits with relayed users. ### My IRCd SQUITs the relay server with errors like "Bad nickname introduced"! From f18f7de9f7e0697d904b475b42e19d6c0c80efec Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 30 Jul 2017 23:42:23 +0800 Subject: [PATCH 10/25] faq: sort by subtopic (cherry picked from commit 42ce9c83b5e6827cd1140ef4ff482248b78ccc11) --- docs/faq.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index f1df808..a558c8e 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,20 +1,22 @@ # PyLink FAQ +## Startup errors + ### I get errors like "ImportError: No module named 'yaml'" when I start PyLink You are missing dependencies - re-read https://github.com/GLolol/PyLink/blob/master/README.md#installation ### I get errors like "yaml.scanner.ScannerError: while scanning for the next token, found character '\t' that cannot start any token" -You must use SPACES and not tabs in your configuration! (`\t` is the escaped code for a tab, which is disallowed by YAML) +You must use **spaces** and not tabs to indent your configuration file! (`\t` is the escaped code for a tab, which is disallowed by YAML) + +## Linking / connection issues ### I turned autoconnect for PyLink on, and now I'm getting errors! PyLink does not support inbound connections - much like regular services such as Atheme or Anope, it only connects outwards *to* IRCds. (If you don't understand what this means, it means you should turn autoconnect OFF for PyLink) -### Clientbot doesn't relay both ways! - -Load the `relay_clientbot` plugin. https://github.com/GLolol/PyLink/blob/e1fab8c/example-conf.yml#L303-L306 +## Relay issues ### Does everyone need to install PyLink Relay for it to work? @@ -37,3 +39,7 @@ PyLink provides, in no particular order: First, check whether the SQUIT message includes the nick that triggered the netsplit. If this nick includes any characters not allowed in regular IRC, such as the slash ("/"), or is otherwise an invalid nick (e.g. beginning with a hyphen or number), this likely indicates a bug in PyLink Relay. These problems should be reported on the issue tracker! However, if the nick mentioned is legal on IRC, this issue is likely caused by a max nick length misconfiguration: i.e. the relay server is introducing nicks too long for the target network. This can be fixed by setting the `maxnicklen` option in the affected network's PyLink `server:` block to the same value as that network's `005` `NICKLEN` (that is, the `NICKLEN=` value in `/raw version`). + +### Clientbot doesn't relay both ways! + +Load the `relay_clientbot` plugin. https://github.com/GLolol/PyLink/blob/e1fab8c/example-conf.yml#L303-L306 From b41234ad793b6ac86e76ff94623319a5b258bca0 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 31 Jul 2017 00:01:07 +0800 Subject: [PATCH 11/25] faq: add a troubleshooting guide for connection failures (cherry picked from commit bc5474a43a73a40303b6ba3a62c02825aa2a33c9) --- docs/faq.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/faq.md b/docs/faq.md index a558c8e..2c76653 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -12,9 +12,27 @@ You must use **spaces** and not tabs to indent your configuration file! (`\t` is ## Linking / connection issues +### PyLink won't connect to my network! + +As a general guide, you should check the following before asking for support: + +1) Is the target network's IRCd showing failed connection attempts? +- If not: + 1) Is PyLink connecting to the right port (i.e. one the IRCd is listening on?) + 2) Is the target network's IRCd actually binding to the port you're trying to use? If there is a port conflict with another program, the IRCd may fail to bind but *still start* on other ports that are free. + 3) Is the target port firewalled on the target machine? + 4) Is there a working connection between the source and target servers? Use ping to test this, as sometimes routing issues between providers can cause servers to become unreachable. + - If your servers are purposely blocking ping, it's up to you to find another solution to test this! 😬 + +- If so: + 1) Check for recvpass/sendpass/server hostname/IP mismatches - usually the IRCd will tell you if you're running into one of these, provided you have the right server notices enabled (consult your IRCd documentation for how to do this). + 2) Make sure you're not connecting with SSL on a non-SSL port, or vice versa. + +If these steps haven't helped you so far, it doesn't hurt to ask for help. :) + ### I turned autoconnect for PyLink on, and now I'm getting errors! -PyLink does not support inbound connections - much like regular services such as Atheme or Anope, it only connects outwards *to* IRCds. (If you don't understand what this means, it means you should turn autoconnect OFF for PyLink) +PyLink does not support inbound connections - much like regular services such as Atheme or Anope, it only connects outwards *to* IRCds. (If you don't understand what this means, it means you should turn autoconnect **off** for PyLink) ## Relay issues From c9734cc0af84d5e1d696fee95840324003714b08 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 31 Jul 2017 00:06:19 +0800 Subject: [PATCH 12/25] faq: add "Relay users are missing" section (cherry picked from commit 0d9c53a4f401f74ad9fdc369ab0c065f53d6b948) --- docs/faq.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index 2c76653..6f7811b 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -61,3 +61,7 @@ However, if the nick mentioned is legal on IRC, this issue is likely caused by a ### Clientbot doesn't relay both ways! Load the `relay_clientbot` plugin. https://github.com/GLolol/PyLink/blob/e1fab8c/example-conf.yml#L303-L306 + +### Relay is occasionally dropping users from channels! + +This usually indicates a serious bug in either Relay or PyLink's protocol modules, and should be reported as an issue. When asking for help, please state which IRCds your PyLink instance is linking to: specifically, which IRCd the missing users are *from* and which IRCd the users are missing *on*. Also, be prepared to send debug logs as you reproduce the issue! From 8e67017c818a92dc4e6fd7d251de4126d43ff548 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 31 Jul 2017 00:19:26 +0800 Subject: [PATCH 13/25] faq: be slightly less excited (cherry picked from commit cc4890184cc00ebc736697cbe5609c7e14bf386c) --- docs/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq.md b/docs/faq.md index 6f7811b..373aab2 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -54,7 +54,7 @@ PyLink provides, in no particular order: ### My IRCd SQUITs the relay server with errors like "Bad nickname introduced"! -First, check whether the SQUIT message includes the nick that triggered the netsplit. If this nick includes any characters not allowed in regular IRC, such as the slash ("/"), or is otherwise an invalid nick (e.g. beginning with a hyphen or number), this likely indicates a bug in PyLink Relay. These problems should be reported on the issue tracker! +First, check whether the SQUIT message includes the nick that triggered the netsplit. If this nick includes any characters not allowed in regular IRC, such as the slash ("/"), or is otherwise an invalid nick (e.g. beginning with a hyphen or number), this likely indicates a bug in PyLink Relay. These problems should be reported on the issue tracker. However, if the nick mentioned is legal on IRC, this issue is likely caused by a max nick length misconfiguration: i.e. the relay server is introducing nicks too long for the target network. This can be fixed by setting the `maxnicklen` option in the affected network's PyLink `server:` block to the same value as that network's `005` `NICKLEN` (that is, the `NICKLEN=` value in `/raw version`). From 5d000c9930d1dbffa16466f3397898e179e0ef74 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 31 Jul 2017 00:19:53 +0800 Subject: [PATCH 14/25] faq: add a section regarding #463 (sporadic SSL-related errors) (cherry picked from commit 99acd06e02f8543f8d9196fa63913f57fe42a9a8) --- docs/faq.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index 373aab2..aecaf5e 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -30,6 +30,10 @@ As a general guide, you should check the following before asking for support: If these steps haven't helped you so far, it doesn't hurt to ask for help. :) +### My networks keep disconnecting with SSL errors! + +See https://github.com/GLolol/PyLink/issues/463 - this seems to be caused by a regression in OpenSSL 1.0.2, which ships with distros such as Ubuntu 16.04 LTS. Unfortunately, the only workarounds so far are to either disable SSL/TLS, or wrap a plain IRC connection in an external service (stunnel, OpenVPN, etc.) + ### I turned autoconnect for PyLink on, and now I'm getting errors! PyLink does not support inbound connections - much like regular services such as Atheme or Anope, it only connects outwards *to* IRCds. (If you don't understand what this means, it means you should turn autoconnect **off** for PyLink) From 381d96552b9900098912a13ee5f08878cdfa4134 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 31 Jul 2017 00:27:48 +0800 Subject: [PATCH 15/25] faq: fix formatting in the connection troubleshooting guide (cherry picked from commit f1f8f91bd7b6097c962b047b5b644b0c6bb9632b) --- docs/faq.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index aecaf5e..94fd2e1 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -16,17 +16,17 @@ You must use **spaces** and not tabs to indent your configuration file! (`\t` is As a general guide, you should check the following before asking for support: -1) Is the target network's IRCd showing failed connection attempts? -- If not: - 1) Is PyLink connecting to the right port (i.e. one the IRCd is listening on?) - 2) Is the target network's IRCd actually binding to the port you're trying to use? If there is a port conflict with another program, the IRCd may fail to bind but *still start* on other ports that are free. - 3) Is the target port firewalled on the target machine? - 4) Is there a working connection between the source and target servers? Use ping to test this, as sometimes routing issues between providers can cause servers to become unreachable. - - If your servers are purposely blocking ping, it's up to you to find another solution to test this! 😬 +- Is the target network's IRCd showing failed connection attempts? + - If not: + 1) Is PyLink connecting to the right port (i.e. one the IRCd is listening on?) + 2) Is the target network's IRCd actually binding to the port you're trying to use? If there is a port conflict with another program, the IRCd may fail to bind but *still start* on other ports that are free. + 3) Is the target port firewalled on the target machine? + 4) Is there a working connection between the source and target servers? Use ping to test this, as sometimes routing issues between providers can cause servers to become unreachable. + - If your servers are purposely blocking ping, it's up to you to find another solution to test this! 😬 -- If so: - 1) Check for recvpass/sendpass/server hostname/IP mismatches - usually the IRCd will tell you if you're running into one of these, provided you have the right server notices enabled (consult your IRCd documentation for how to do this). - 2) Make sure you're not connecting with SSL on a non-SSL port, or vice versa. + - If so: + 1) Check for recvpass/sendpass/server hostname/IP mismatches - usually the IRCd will tell you if you're running into one of these, provided you have the right server notices enabled (consult your IRCd documentation for how to do this). + 2) Make sure you're not connecting with SSL on a non-SSL port, or vice versa. If these steps haven't helped you so far, it doesn't hurt to ask for help. :) From 7b281e4b0481d76bedb2561c3a1e0ff69774097b Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 31 Jul 2017 00:29:04 +0800 Subject: [PATCH 16/25] faq: tweak wording (cherry picked from commit 17a4bbea87686d814eb2292d0142f8a8fdf591b4) --- docs/faq.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 94fd2e1..1218a50 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -10,7 +10,7 @@ You are missing dependencies - re-read https://github.com/GLolol/PyLink/blob/mas You must use **spaces** and not tabs to indent your configuration file! (`\t` is the escaped code for a tab, which is disallowed by YAML) -## Linking / connection issues +## Linking / Connection issues ### PyLink won't connect to my network! @@ -22,7 +22,7 @@ As a general guide, you should check the following before asking for support: 2) Is the target network's IRCd actually binding to the port you're trying to use? If there is a port conflict with another program, the IRCd may fail to bind but *still start* on other ports that are free. 3) Is the target port firewalled on the target machine? 4) Is there a working connection between the source and target servers? Use ping to test this, as sometimes routing issues between providers can cause servers to become unreachable. - - If your servers are purposely blocking ping, it's up to you to find another solution to test this! 😬 + - If your servers are purposely blocking ping, it's up to you to find another way to test this! 😬 - If so: 1) Check for recvpass/sendpass/server hostname/IP mismatches - usually the IRCd will tell you if you're running into one of these, provided you have the right server notices enabled (consult your IRCd documentation for how to do this). From 7df19bae5f967cca8eb8e378b8d1b3998e13547e Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 12 Jul 2017 08:33:28 -0700 Subject: [PATCH 17/25] example-conf: tweak whether some options are commented out by default or not (cherry picked from commit dbc1e80def928528e60969739f041f01779a250b) --- example-conf.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/example-conf.yml b/example-conf.yml index 603843d..b200886 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -37,23 +37,23 @@ pylink: # Determines whether hideoper modes should be respected in WHOIS replies. # Defaults to true if not specified. - whois_use_hideoper: true + #whois_use_hideoper: true # Determines whether extended WHOIS replies should be sent to users marked as a # bot (usually with umode +B). For better security (i.e. with bots that track services # accounts for authentication), it is recommended to leave this off. - whois_show_extensions_to_bots: false + #whois_show_extensions_to_bots: false # Determines whether PyLink service clients should protect themselves from # kicks, kills, etc. using IRCd-side servprotect modes. For this to work # properly, this usually requires that PyLink be U-Lined. This defaults to # False. - protect_services: false + #protect_services: false # Determines how long plugins should wait (in seconds) before flushing their # databases to disk. Defaults to 300 seconds. Changes here require a reload # of all database-enabled plugins to take effect. - save_delay: 300 + #save_delay: 300 # Determines whether services should default to sending command responses as private notices, # even if the command was called in a channel. This defaults to False. @@ -146,8 +146,8 @@ servers: # Comment out or remove these keys if you don't want service bots# to join any channels by # default. channels: ["#pylink"] - pylink_channels: ["#services"] - automode_channels: ["#chat"] + #pylink_channels: ["#services"] + #automode_channels: ["#chat"] # Sets the protocol module to use for this network - see the README for a # list of supported IRCds. @@ -167,7 +167,7 @@ servers: # Sets the ping frequency in seconds (i.e. how long we should wait between # sending pings to our uplink). When more than two consecutive pings are missed, # PyLink will disconnect with a ping timeout. This defaults to 90 if not set. - pingfreq: 90 + #pingfreq: 90 # If enabled, this opts this network out of relay IP sharing: this network # will not have its users' IPs sent across the relay, and it will not see any @@ -263,7 +263,6 @@ servers: sid: "2PY" netname: "This should match your UnrealIRCd config" sidrange: "8##" - channels: [] protocol: "unreal" autoconnect: 5 @@ -312,7 +311,7 @@ servers: # With this key set to 'generic', neither of these host changing features are enabled # and a baseline RFC1459 mode set is used. This configuration is not officially supported. - #p10_ircd: nefarious + p10_ircd: nefarious # Determines whether account-based cloaks should be used (someone.users.yournet.org # format). This should match your IRCd configuration: @@ -358,7 +357,7 @@ servers: # Once again, you can override the nick and ident of service bots on specific networks using # the "servicename_nick" and "servicename_ident" options. - pylink_nick: pybot + #pylink_nick: pybot #pylink_ident: pybot # SSL options. Certfile and keyfile are optional, but can be used for CertFP/SASL external @@ -399,7 +398,8 @@ servers: # Determines whether oper statuses should be tracked on this Clientbot network. This # defaults to False for the best security, since oper status may allow more access to the # entire PyLink service than what's desired, even when PyLink is only connected as a bot. - track_oper_statuses: false + # This defaults to false if not specified. + #track_oper_statuses: false # Determines whether messages from unknown clients (servers, clients not sharing in a -n # channel, etc.) should be forwarded via the PyLink server. If this is disabled, these From 13baef08c1a5925e85d95c7e1d2e4077430d1697 Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 12 Jul 2017 08:37:08 -0700 Subject: [PATCH 18/25] example-conf: roughly sort config options by usefulness Also, remove the example for the deprecated pylink:prefixes option. (cherry picked from commit 1eb274342166bc11d1daa4b9880e7a3990f32df5) Conflicts: example-conf.yml --- example-conf.yml | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/example-conf.yml b/example-conf.yml index b200886..25a41a6 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -17,11 +17,12 @@ pylink: # Sets the fantasy command prefix for the main PyLink bot. To configure fantasy prefixes for # other service bots, add or modify the "prefix:" option in the configuration section of each - # plugin. + # plugin. (see the "games:" block for an example) # Note: prior to PyLink 1.2, defining a prefix here made it global for all service bots. This # was removed because it called all bots in a channel at once (even if they have conflicting - # commands), which usually led to one successful reply and a string of "Command not found" + # commands), which usually leads to one successful reply and a string of "Command not found" # errors. + # Note 2: this option REPLACES the deprecated "prefixes:" option from PyLink 1.1 and earlier. prefix: "&" # Determines whether PyLink service bots will respond to commands prefixed with their nick @@ -29,32 +30,12 @@ pylink: # it was renamed for consistency. This defaults to false. #respond_to_nick: true - # Custom prefixes for other service bots if they are loaded. Note: this is DEPRECATED - # since PyLink 1.2 in favour of adding prefixes into each plugin's configuration block - # itself (see the "prefix:" option in the "games:" block for an example). - #prefixes: - # games: "@" - - # Determines whether hideoper modes should be respected in WHOIS replies. - # Defaults to true if not specified. - #whois_use_hideoper: true - - # Determines whether extended WHOIS replies should be sent to users marked as a - # bot (usually with umode +B). For better security (i.e. with bots that track services - # accounts for authentication), it is recommended to leave this off. - #whois_show_extensions_to_bots: false - # Determines whether PyLink service clients should protect themselves from # kicks, kills, etc. using IRCd-side servprotect modes. For this to work # properly, this usually requires that PyLink be U-Lined. This defaults to # False. #protect_services: false - # Determines how long plugins should wait (in seconds) before flushing their - # databases to disk. Defaults to 300 seconds. Changes here require a reload - # of all database-enabled plugins to take effect. - #save_delay: 300 - # Determines whether services should default to sending command responses as private notices, # even if the command was called in a channel. This defaults to False. #prefer_private_replies: false @@ -72,6 +53,24 @@ pylink: # Determines whether we should show unknown command errors for service bots. Defaults to True. #show_unknown_commands: true + # Determines whether hideoper modes should be respected in WHOIS replies. + # Defaults to true if not specified. + #whois_use_hideoper: true + + # Determines whether extended WHOIS replies should be sent to users marked as a + # bot (usually with umode +B). For better security (i.e. with bots that track services + # accounts for authentication), it is recommended to leave this off. + #whois_show_extensions_to_bots: false + + # Determines whether PyLink should return its time of initial connection when replying to WHOIS + # for service bots. This defaults to true if not set. + #whois_show_startup_time: true + + # Determines how long plugins should wait (in seconds) before flushing their + # databases to disk. Defaults to 300 seconds. Changes here require a reload + # of all database-enabled plugins to take effect. + #save_delay: 300 + login: # NOTE: for users migrating from PyLink < 1.1, the old login:user/login:password settings # have been deprecated. We strongly recommend migrating to the new "accounts:" block below, as From 819aab2248e3db5d39ab02427eb8b8f2df4471cc Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 30 Jul 2017 23:44:27 +0800 Subject: [PATCH 19/25] example-conf: roughly sort the plugins' order by usefulness/popularity (cherry picked from commit b24eefc87375ff81a0218309931cc15c1aa91902) --- example-conf.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/example-conf.yml b/example-conf.yml index 25a41a6..94863b6 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -415,15 +415,9 @@ plugins: # Networks plugin: Allows you to manage connections to networks while PyLink is running. - networks - # Ctcp plugin: handles basic CTCP replies (VERSION, etc). + # Ctcp plugin: handles basic CTCP replies (VERSION, etc) towards service bots. - ctcp - # Oper commands plugin: Provides a handful of network management commands. (KILL, JUPE, etc.) - #- opercmds - - # Bots plugin: Allows you to manipulate PyLink service bots on networks. - #- bots - # Relay plugin: Transparent server-side relay between channels (like Janus). See # the relay: block below for configuration. #- relay @@ -437,18 +431,18 @@ plugins: # with the PyLink service's nick or configurable prefix characters. #- fantasy - # Changehost plugin: Automatically changes the hostmask (i.e. sets vHosts) on - # matching users as they connect. This requires the changehost: block to be - # configured correctly below. - #- changehost + # Oper commands plugin: Provides a handful of network management commands. (KILL, JUPE, etc.) + #- opercmds # Automode plugin: allows assigning channel access to specific hostmasks or # exttargets. See https://github.com/GLolol/PyLink/blob/master/docs/automode.md # for a usage guide. #- automode - # Servermaps plugin: displays network /map's from the PyLink server's perspective. - #- servermaps + # Changehost plugin: Automatically changes the hostmask (i.e. sets vHosts) on + # matching users as they connect. This requires the changehost: block to be + # configured correctly below. + #- changehost # Servprotect plugin: disconnects from networks if too many kills or nick collisions to # PyLink clients are received. @@ -458,6 +452,12 @@ plugins: # client is in. #- global + # Bots plugin: Allows you to manipulate PyLink service bots on networks. + #- bots + + # Servermaps plugin: displays network /map's from the PyLink server's perspective. + #- servermaps + logging: # This configuration block defines targets that PyLink should log commands, # errors, etc., to. From a639efa93ec3694fe211972c2dedf21ce51d3e21 Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 2 Aug 2017 21:57:48 +0800 Subject: [PATCH 20/25] relay: allow overriding tag_nicks per network Closes #494. (cherry picked from commit 1d6b692e1490e538f5c8d9c16542ff45feab1f9f) Conflicts: example-conf.yml --- example-conf.yml | 14 +++++++++----- plugins/relay.py | 5 ++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/example-conf.yml b/example-conf.yml index 94863b6..3a09027 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -168,11 +168,6 @@ servers: # PyLink will disconnect with a ping timeout. This defaults to 90 if not set. #pingfreq: 90 - # If enabled, this opts this network out of relay IP sharing: this network - # will not have its users' IPs sent across the relay, and it will not see any - # IPs of other networks' users. - #relay_no_ips: true - # Sets the max nick length for the network. It is important that this is # set correctly, or PyLink might introduce a nick that is too long and # cause netsplits! This defaults to 30 if not set. @@ -209,6 +204,15 @@ servers: # This setting is EXPERIMENTAL as of PyLink 1.2.x. #encoding: utf-8 + # If enabled, this opts this network out of relay IP sharing: this network + # will not have its users' IPs sent across the relay, and it will not see any + # IPs of other networks' users. + #relay_no_ips: true + + # Determines whether relay will tag nicks on this network. This overrides the relay::tag_nicks + # option on a per network-basis. + #relay_tag_nicks: true + ts6net: ip: ::1 diff --git a/plugins/relay.py b/plugins/relay.py index c63ddc3..07fdb5c 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -100,7 +100,10 @@ def normalize_nick(irc, netname, nick, times_tagged=0, uid=''): # Figure out whether we tag nicks or not. if times_tagged == 0: - if conf.conf.get('relay', {}).get('tag_nicks', True): + # Check the following options in order, before falling back to True: + # 1) servers::::relay_tag_nicks + # 2) relay::tag_nicks + if irc.serverdata.get('relay_tag_nicks', conf.conf.get('relay', {}).get('tag_nicks', True)): times_tagged = 1 else: forcetag_nicks = conf.conf.get('relay', {}).get('forcetag_nicks', []) From dcc171095f122a9601d07f46763f18946eb4c446 Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 2 Aug 2017 22:02:35 +0800 Subject: [PATCH 21/25] example-conf: spacing & comment tweaks (cherry picked from commit a55f60c6dc7c02dcde42b43f751e8083593faeec) Conflicts: example-conf.yml --- example-conf.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example-conf.yml b/example-conf.yml index 3a09027..e25c52e 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -676,7 +676,6 @@ relay: # resets the cache. #age: 10 - automode: # The following options in this block are common to all plugins that spawn service bots (games, # automode, etc.): @@ -722,7 +721,7 @@ stats: # Defaults to "%a, %d %b %Y %H:%M:%S +0000" (the RFC 2812 standard) if not specified. time_format: "%c" -global: +#global: # Sets the text format for the global plugin, if it is loaded. This uses a template string as # documented at https://docs.python.org/3/library/string.html#template-strings, with the # following substitutions: From d734fc3280b671e555dd68f08f656750ba540b74 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 3 Aug 2017 10:10:28 -0700 Subject: [PATCH 22/25] servprotect: bump default conf up to 10 hits/10 seconds --- plugins/servprotect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/servprotect.py b/plugins/servprotect.py index 12ca2a7..4adab69 100644 --- a/plugins/servprotect.py +++ b/plugins/servprotect.py @@ -6,7 +6,7 @@ from pylinkirc.log import log # check for definitions servprotect_conf = conf.conf.get('servprotect', {}) -length = servprotect_conf.get('length', 5) +length = servprotect_conf.get('length', 10) age = servprotect_conf.get('age', 10) savecache = ExpiringDict(max_len=length, max_age_seconds=age) From 0d5afd266fa147753e46eb10b054bda4d4b479ac Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 3 Aug 2017 10:15:29 -0700 Subject: [PATCH 23/25] Irc: stop extraneous queue threads when removing from world.networkobjects --- classes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes.py b/classes.py index 0c033b4..79074c5 100644 --- a/classes.py +++ b/classes.py @@ -187,6 +187,9 @@ class Irc(utils.DeprecatedAttributesObject): if data is None: log.debug('(%s) Stopping queue thread due to getting None as item', self.name) break + elif self not in world.networkobjects.values(): + log.debug('(%s) Stopping stale queue thread; no longer matches world.networkobjects', self.name) + break elif data: self._send(data) else: From a0a295f7d2f04f5adc3e4ab5dd23581ad1c8c411 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 3 Aug 2017 10:22:57 -0700 Subject: [PATCH 24/25] Set Irc.aborted earlier in the disconnect loop This prevents plugins from getting really confused as we remove things. --- classes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes.py b/classes.py index 79074c5..52c3aad 100644 --- a/classes.py +++ b/classes.py @@ -390,6 +390,9 @@ class Irc(utils.DeprecatedAttributesObject): log.debug('(%s) disconnect: Clearing self.connected state.', self.name) self.connected.clear() + log.debug('(%s) disconnect: Setting self.aborted to True.', self.name) + self.aborted.set() + log.debug('(%s) Removing channel logging handlers due to disconnect.', self.name) while self.loghandlers: log.removeHandler(self.loghandlers.pop()) @@ -412,9 +415,6 @@ class Irc(utils.DeprecatedAttributesObject): log.debug('(%s) Canceling pingTimer at %s due to disconnect() call', self.name, time.time()) self.pingTimer.cancel() - log.debug('(%s) disconnect: Setting self.aborted to True.', self.name) - self.aborted.set() - # Internal hook signifying that a network has disconnected. self.callHooks([None, 'PYLINK_DISCONNECT', {'was_successful': was_successful}]) From 7ae22dc848a3dc4988daa67fc1cd095dc5511c49 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 3 Aug 2017 10:44:47 -0700 Subject: [PATCH 25/25] faq: add a note regarding #497 (bans and modes blocking clientbot from relaying) This will be fixed more completely in the future. Thanks to @Ryan-Goldstein for reporting! --- docs/faq.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index 1218a50..25e404d 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -66,6 +66,10 @@ However, if the nick mentioned is legal on IRC, this issue is likely caused by a Load the `relay_clientbot` plugin. https://github.com/GLolol/PyLink/blob/e1fab8c/example-conf.yml#L303-L306 +Also, make sure that nothing is blocking the Clientbot from actually sending text, such as blockcolor/regmoderated modes or bans. Temporarily setting the PyLink log level to DEBUG can assist in debugging. + +Future PyLink versions will have better handling for these errors; see https://github.com/GLolol/PyLink/issues/497. + ### Relay is occasionally dropping users from channels! This usually indicates a serious bug in either Relay or PyLink's protocol modules, and should be reported as an issue. When asking for help, please state which IRCds your PyLink instance is linking to: specifically, which IRCd the missing users are *from* and which IRCd the users are missing *on*. Also, be prepared to send debug logs as you reproduce the issue!