From ee60431396a5269d94dd1fcc50be1509c06d0e5f Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 29 Jul 2022 10:03:39 +0200 Subject: [PATCH] Add debug logging when skipping SASL mechanisms It is useful to figure out what you forgot to configure --- src/irclib.py | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/src/irclib.py b/src/irclib.py index dcd4ba2c0..c95458485 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -1731,20 +1731,41 @@ class Irc(IrcCommandDispatcher, log.Firewalled): self.sasl_current_mechanism = None for mechanism in network_config.sasl.mechanisms(): - if mechanism == 'ecdsa-nist256p-challenge' and \ - crypto and self.sasl_username and \ - self.sasl_ecdsa_key: - self.sasl_next_mechanisms.append(mechanism) - elif mechanism == 'external' and ( - network_config.certfile() or - conf.supybot.protocols.irc.certfile()): - self.sasl_next_mechanisms.append(mechanism) - elif mechanism.startswith('scram-') and scram and \ - self.sasl_username and self.sasl_password: - self.sasl_next_mechanisms.append(mechanism) - elif mechanism == 'plain' and \ - self.sasl_username and self.sasl_password: - self.sasl_next_mechanisms.append(mechanism) + if mechanism == 'ecdsa-nist256p-challenge': + if not crypto: + log.debug('Skipping SASL %s, crypto module ' + 'is not available', + mechanism) + elif not self.sasl_username or not self.sasl_ecdsa_key: + log.debug('Skipping SASL %s, missing username and/or key', + mechanism) + else: + self.sasl_next_mechanisms.append(mechanism) + elif mechanism == 'external': + if not network_config.certfile() and \ + not conf.supybot.protocols.irc.certfile(): + log.debug('Skipping SASL %s, missing cert file', + mechanism) + else: + self.sasl_next_mechanisms.append(mechanism) + elif mechanism.startswith('scram-'): + if not scram: + log.debug('Skipping SASL %s, scram module ' + 'is not available', + mechanism) + elif not self.sasl_username or not self.sasl_password: + log.debug('Skipping SASL %s, missing username and/or ' + 'password', + mechanism) + else: + self.sasl_next_mechanisms.append(mechanism) + elif mechanism == 'plain': + if not self.sasl_username or not self.sasl_password: + log.debug('Skipping SASL %s, missing username and/or ' + 'password', + mechanism) + else: + self.sasl_next_mechanisms.append(mechanism) if self.sasl_next_mechanisms: self.REQUEST_CAPABILITIES.add('sasl')