From d5229979927b5ca3d7de0d4386397618b99e8d5f Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 17 Sep 2018 11:49:23 +0100 Subject: [PATCH] Don't just listen for 'sasl=PLAIN' in IRCv3 CAP 3.2 --- modules/sasl.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/sasl.py b/modules/sasl.py index bdc4eb1d..967fb551 100644 --- a/modules/sasl.py +++ b/modules/sasl.py @@ -20,13 +20,18 @@ class Module(object): def on_cap(self, event): has_sasl = "sasl" in event["capabilities"] - has_mechanisms = has_sasl and not event["capabilities"]["sasl" - ] == None - has_plaintext = has_mechanisms and "PLAIN" in event["capabilities" - ]["sasl"].split(",") + our_sasl = event["server"].get_setting("sasl", None) - if has_sasl and (has_plaintext or not has_mechanisms) and event[ - "server"].get_setting("sasl", None): + do_sasl = False + if has_sasl and our_sasl: + if not event["capabilities"]["sasl"] == None: + our_mechanism = our_sasl["mechanism"].upper() + do_sasl = our_mechanism in event["capabilities" + ]["sasl"].split(",") + else: + do_sasl = False + + if do_sasl: event["server"].queue_capability("sasl") def on_cap_ack(self, event):