summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-07-20 18:15:54 -0700
committerLance Stout <lancestout@gmail.com>2012-07-20 18:15:54 -0700
commit5492e9028df8d1d2a064693b4dd06bd92cc9f60a (patch)
tree9d3a2b7da94454e994fa76aec6c2e0699a0b6453 /sleekxmpp
parent060c9ab6794cbe6c62c312b1f42bd3767ff66b80 (diff)
parent474390fa00a4c2ddf63976bdaf95468248ddd12b (diff)
downloadslixmpp-5492e9028df8d1d2a064693b4dd06bd92cc9f60a.tar.gz
slixmpp-5492e9028df8d1d2a064693b4dd06bd92cc9f60a.tar.bz2
slixmpp-5492e9028df8d1d2a064693b4dd06bd92cc9f60a.tar.xz
slixmpp-5492e9028df8d1d2a064693b4dd06bd92cc9f60a.zip
Merge branch 'master' into develop
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/basexmpp.py20
-rw-r--r--sleekxmpp/plugins/xep_0153/vcard_avatar.py1
2 files changed, 21 insertions, 0 deletions
diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py
index d81be016..90134c4d 100644
--- a/sleekxmpp/basexmpp.py
+++ b/sleekxmpp/basexmpp.py
@@ -72,6 +72,11 @@ class BaseXMPP(XMLStream):
self.boundjid = JID(jid)
self._expected_server_name = self.boundjid.host
+ self._redirect_attempts = 0
+
+ #: The maximum number of consecutive see-other-host
+ #: redirections that will be followed before quitting.
+ self.max_redirects = 5
self.session_bind_event = threading.Event()
@@ -144,6 +149,8 @@ class BaseXMPP(XMLStream):
MatchXPath("{%s}error" % self.stream_ns),
self._handle_stream_error))
+ self.add_event_handler('session_start',
+ self._handle_session_start)
self.add_event_handler('disconnected',
self._handle_disconnected)
self.add_event_handler('presence_available',
@@ -656,6 +663,10 @@ class BaseXMPP(XMLStream):
def getjidbare(self, fulljid):
return fulljid.split('/', 1)[0]
+ def _handle_session_start(self, event):
+ """Reset redirection attempt count."""
+ self._redirect_attempts = 0
+
def _handle_disconnected(self, event):
"""When disconnected, reset the roster"""
self.roster.reset()
@@ -666,6 +677,15 @@ class BaseXMPP(XMLStream):
if error['condition'] == 'see-other-host':
other_host = error['see_other_host']
+ if not other_host:
+ log.warning("No other host specified.")
+ return
+
+ if self._redirect_attempts > self.max_redirects:
+ log.error("Exceeded maximum number of redirection attempts.")
+ return
+
+ self._redirect_attempts += 1
host = other_host
port = 5222
diff --git a/sleekxmpp/plugins/xep_0153/vcard_avatar.py b/sleekxmpp/plugins/xep_0153/vcard_avatar.py
index 1e32595a..6b70e33e 100644
--- a/sleekxmpp/plugins/xep_0153/vcard_avatar.py
+++ b/sleekxmpp/plugins/xep_0153/vcard_avatar.py
@@ -106,6 +106,7 @@ class XEP_0153(BasePlugin):
return
elif data == '' or data != self.api['get_hash'](pres['to']):
self._reset_hash(pres['from'])
+ self.xmpp.event('vcard_avatar_update', pres)
# =================================================================