changeset 6763cf2504e6 in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=6763cf2504e6
description: handle see-other-host stream error. Fixes #7134

diffstat:

 src/common/connection.py          |  18 ++++++++++++++----
 src/common/connection_handlers.py |  17 ++++++++++++++++-
 2 files changed, 30 insertions(+), 5 deletions(-)

diffs (78 lines):

diff -r 77bf2919b7ed -r 6763cf2504e6 src/common/connection.py
--- a/src/common/connection.py  Sat Apr 14 13:40:55 2012 +0200
+++ b/src/common/connection.py  Sun Apr 15 23:42:53 2012 +0200
@@ -689,6 +689,7 @@
         self.try_connecting_for_foo_secs = 45
         # holds the actual hostname to which we are connected
         self.connected_hostname = None
+        self.redirected = None
         self.last_time_to_reconnect = None
         self.new_account_info = None
         self.new_account_form = None
@@ -1039,10 +1040,17 @@
                     self.name, 'try_connecting_for_foo_secs')
             proxy = helpers.get_proxy_info(self.name)
             use_srv = gajim.config.get_per('accounts', self.name, 'use_srv')
-            use_custom = gajim.config.get_per('accounts', self.name,
+            if self.redirected:
+                use_custom = True
+                custom_h = self.redirected['host']
+                custom_p = self.redirected['port']
+            else:
+                use_custom = gajim.config.get_per('accounts', self.name,
                     'use_custom_host')
-            custom_h = gajim.config.get_per('accounts', self.name, 
'custom_host')
-            custom_p = gajim.config.get_per('accounts', self.name, 
'custom_port')
+                custom_h = gajim.config.get_per('accounts', self.name,
+                    'custom_host')
+                custom_p = gajim.config.get_per('accounts', self.name,
+                    'custom_port')
 
         # create connection if it doesn't already exist
         self.connected = 1
@@ -1054,8 +1062,10 @@
             h = custom_h
             p = custom_p
             ssl_p = custom_p
-            use_srv = False
+            if not self.redirected:
+                use_srv = False
 
+        self.redirected = None
         # SRV resolver
         self._proxy = proxy
         self._hosts = [ {'host': h, 'port': p, 'ssl_port': ssl_p, 'prio': 10,
diff -r 77bf2919b7ed -r 6763cf2504e6 src/common/connection_handlers.py
--- a/src/common/connection_handlers.py Sat Apr 14 13:40:55 2012 +0200
+++ b/src/common/connection_handlers.py Sun Apr 15 23:42:53 2012 +0200
@@ -190,7 +190,7 @@
         query.setAttr('node', 'http://gajim.org#' + gajim.version.split('-', 
1)[
             0])
         for f in (common.xmpp.NS_BYTESTREAM, common.xmpp.NS_SI,
-        common.xmpp.NS_FILE, common.xmpp.NS_COMMANDS, 
+        common.xmpp.NS_FILE, common.xmpp.NS_COMMANDS,
         common.xmpp.NS_JINGLE_FILE_TRANSFER, common.xmpp.NS_JINGLE_XTLS,
         common.xmpp.NS_PUBKEY_PUBKEY, common.xmpp.NS_PUBKEY_REVOKE,
         common.xmpp.NS_PUBKEY_ATTEST):
@@ -2014,6 +2014,21 @@
         if obj.getTag('conflict'):
             # disconnected because of a resource conflict
             self.dispatch('RESOURCE_CONFLICT', ())
+        other_host = obj.getTag('see-other-host')
+        if other_host and self.last_connection_type in ('ssl', 'tls'):
+            host = other_host.getData()
+            if ':' in host:
+                host_l = host.split(':', 1)
+                h = host_l[0]
+                p = host_l[1]
+            else:
+                h = host
+                p = 5222
+            if h.startswith('[') and h.endswith(']'):
+                h = h[1:-1]
+            self.redirected = {'host': h, 'port': p}
+            self.disconnect(on_purpose=True)
+            self.connect()
 
     def _register_handlers(self, con, con_type):
         # try to find another way to register handlers in each class
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to