correctly handle see-other-host (earlier in the connection process). Fixes #7179
This commit is contained in:
parent
a51bf035cd
commit
449f137dd7
6 changed files with 23 additions and 7 deletions
|
@ -1134,6 +1134,10 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
self._disconnectedReconnCB()
|
||||
|
||||
def connect_to_next_type(self, retry=False):
|
||||
if self.redirected:
|
||||
self.disconnect(on_purpose=True)
|
||||
self.connect()
|
||||
return
|
||||
if len(self._connection_types):
|
||||
self._current_type = self._connection_types.pop(0)
|
||||
if self.last_connection:
|
||||
|
@ -1194,6 +1198,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
on_connect=self.on_connect_success,
|
||||
on_proxy_failure=self.on_proxy_failure,
|
||||
on_connect_failure=self.connect_to_next_type,
|
||||
on_stream_error_cb=self._StreamCB,
|
||||
proxy=self._proxy,
|
||||
secure_tuple = secure_tuple)
|
||||
|
||||
|
|
|
@ -1257,6 +1257,7 @@ ConnectionJingle, ConnectionIBBytestream):
|
|||
PrivateStorageRosternotesReceivedEvent)
|
||||
gajim.nec.register_incoming_event(RosternotesReceivedEvent)
|
||||
gajim.nec.register_incoming_event(StreamConflictReceivedEvent)
|
||||
gajim.nec.register_incoming_event(StreamOtherHostReceivedEvent)
|
||||
gajim.nec.register_incoming_event(MessageReceivedEvent)
|
||||
gajim.nec.register_incoming_event(ArchivingErrorReceivedEvent)
|
||||
gajim.nec.register_incoming_event(
|
||||
|
@ -2018,8 +2019,6 @@ ConnectionJingle, ConnectionIBBytestream):
|
|||
if obj.conn.name != self.name:
|
||||
return
|
||||
self.redirected = obj.redirected
|
||||
self.disconnect(on_purpose=True)
|
||||
self.connect()
|
||||
|
||||
def _StreamCB(self, con, obj):
|
||||
log.debug('StreamCB')
|
||||
|
|
|
@ -680,8 +680,10 @@ class StreamOtherHostReceivedEvent(nec.NetworkIncomingEvent):
|
|||
base_network_events = ['stream-received']
|
||||
|
||||
def generate(self):
|
||||
other_host = obj.getTag('see-other-host')
|
||||
if other_host and self.conn.last_connection_type in ('ssl', 'tls'):
|
||||
self.conn = self.base_event.conn
|
||||
self.stanza = self.base_event.stanza
|
||||
other_host = self.stanza.getTag('see-other-host')
|
||||
if other_host and self.conn._current_type in ('ssl', 'tls'):
|
||||
host = other_host.getData()
|
||||
if ':' in host:
|
||||
host_l = host.split(':', 1)
|
||||
|
|
|
@ -63,6 +63,7 @@ class CommonResolver():
|
|||
self.handlers = {}
|
||||
|
||||
def resolve(self, host, on_ready, type='srv'):
|
||||
host = host.lower()
|
||||
log.debug('resolve %s type=%s' % (host, type))
|
||||
assert(type in ['srv', 'txt'])
|
||||
if not host:
|
||||
|
@ -88,6 +89,7 @@ class CommonResolver():
|
|||
|
||||
def _on_ready(self, host, type, result_list):
|
||||
# practically it is impossible to be the opposite, but who knows :)
|
||||
host = host.lower()
|
||||
log.debug('Resolving result for %s: %s' % (host, result_list))
|
||||
if not self.resolved_hosts.has_key(host+type):
|
||||
self.resolved_hosts[host+type] = result_list
|
||||
|
|
|
@ -67,6 +67,7 @@ class NonBlockingClient:
|
|||
self.on_connect_failure = None
|
||||
self.proxy = None
|
||||
self.got_features = False
|
||||
self.got_see_other_host = None
|
||||
self.stream_started = False
|
||||
self.disconnecting = False
|
||||
self.protocol_type = 'XMPP'
|
||||
|
@ -138,8 +139,8 @@ class NonBlockingClient:
|
|||
self.disconnecting = False
|
||||
|
||||
def connect(self, on_connect, on_connect_failure, hostname=None, port=5222,
|
||||
on_proxy_failure=None, proxy=None, secure_tuple=('plain', None,
|
||||
None)):
|
||||
on_proxy_failure=None, on_stream_error_cb=None, proxy=None,
|
||||
secure_tuple=('plain', None, None)):
|
||||
"""
|
||||
Open XMPP connection (open XML streams in both directions)
|
||||
|
||||
|
@ -161,6 +162,7 @@ class NonBlockingClient:
|
|||
self.on_connect = on_connect
|
||||
self.on_connect_failure=on_connect_failure
|
||||
self.on_proxy_failure = on_proxy_failure
|
||||
self.on_stream_error_cb = on_stream_error_cb
|
||||
self.desired_security, self.cacerts, self.mycerts = secure_tuple
|
||||
self.Connection = None
|
||||
self.Port = port
|
||||
|
@ -350,7 +352,10 @@ class NonBlockingClient:
|
|||
# sometimes <features> are received together with document
|
||||
# attributes and sometimes on next receive...
|
||||
self.Dispatcher.ProcessNonBlocking(data)
|
||||
if not self.got_features:
|
||||
if self.got_see_other_host:
|
||||
log.info('got see-other-host')
|
||||
self.on_stream_error_cb(self, self.got_see_other_host)
|
||||
elif not self.got_features:
|
||||
self._xmpp_connect_machine(
|
||||
mode='FAILURE',
|
||||
data='Missing <features> in 1.0 stream')
|
||||
|
|
|
@ -415,6 +415,9 @@ class XMPPDispatcher(PlugIn):
|
|||
if name == 'features':
|
||||
self._owner.got_features = True
|
||||
session.Stream.features = stanza
|
||||
if name == 'error':
|
||||
if stanza.getTag('see-other-host'):
|
||||
self._owner.got_see_other_host = stanza
|
||||
|
||||
xmlns = stanza.getNamespace()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue