handle see-other-host stream error. Fixes #7134

This commit is contained in:
Yann Leboulanger 2012-04-15 23:42:53 +02:00
parent 6d178205fd
commit 2ac8607ed6
2 changed files with 30 additions and 5 deletions

View File

@ -689,6 +689,7 @@ class Connection(CommonConnection, ConnectionHandlers):
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 @@ class Connection(CommonConnection, ConnectionHandlers):
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 @@ class Connection(CommonConnection, ConnectionHandlers):
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,

View File

@ -190,7 +190,7 @@ class ConnectionDisco:
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 @@ ConnectionJingle, ConnectionIBBytestream):
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