summaryrefslogtreecommitdiff
path: root/sleekxmpp/features/feature_mechanisms/mechanisms.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-07-02 22:30:34 -0700
committerLance Stout <lancestout@gmail.com>2011-07-02 22:30:55 -0700
commitb898b14b77d739cb1c118c9e3648aa268348d293 (patch)
treef57d3675b65b5338d9f260629faa03be953fc9fe /sleekxmpp/features/feature_mechanisms/mechanisms.py
parentfba235a801a3a1c06d1769cdc944b72dce33f88a (diff)
downloadslixmpp-b898b14b77d739cb1c118c9e3648aa268348d293.tar.gz
slixmpp-b898b14b77d739cb1c118c9e3648aa268348d293.tar.bz2
slixmpp-b898b14b77d739cb1c118c9e3648aa268348d293.tar.xz
slixmpp-b898b14b77d739cb1c118c9e3648aa268348d293.zip
Use a set to track negotiated features.
Added guards to prevent renegotiating STARTTLS or SASL in cases where servers don't behave properly.
Diffstat (limited to 'sleekxmpp/features/feature_mechanisms/mechanisms.py')
-rw-r--r--sleekxmpp/features/feature_mechanisms/mechanisms.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/sleekxmpp/features/feature_mechanisms/mechanisms.py b/sleekxmpp/features/feature_mechanisms/mechanisms.py
index a8a046e4..011010fb 100644
--- a/sleekxmpp/features/feature_mechanisms/mechanisms.py
+++ b/sleekxmpp/features/feature_mechanisms/mechanisms.py
@@ -90,6 +90,11 @@ class feature_mechanisms(base_plugin):
Arguments:
features -- The stream features stanza.
"""
+ if 'mechanisms' in self.xmpp.features:
+ # SASL authentication has already succeeded, but the
+ # server has incorrectly offered it again.
+ return False
+
for priority, mech in self._mechanism_priorities:
if mech in features['mechanisms']:
log.debug('Attempt to use SASL %s' % mech)
@@ -105,7 +110,7 @@ class feature_mechanisms(base_plugin):
def _handle_success(self, stanza):
"""SASL authentication succeeded. Restart the stream."""
self.xmpp.authenticated = True
- self.xmpp.features.append('mechanisms')
+ self.xmpp.features.add('mechanisms')
raise RestartStream()
def _handle_fail(self, stanza):