From e918ac85fee48f01d2caac26a966e244b155378f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sat, 7 Jul 2018 20:00:09 +0200 Subject: [PATCH] Remove streamhost redirect After asking around this is a dead feature. Because servers cannot be sure if clients support redirection, a server using this feature would essentially risk that his users are not able to connect at all. --- gajim/common/connection.py | 51 ++++++++-------------- gajim/common/connection_handlers.py | 10 ----- gajim/common/connection_handlers_events.py | 22 ---------- 3 files changed, 17 insertions(+), 66 deletions(-) diff --git a/gajim/common/connection.py b/gajim/common/connection.py index 6825ce117..22a4e235b 100644 --- a/gajim/common/connection.py +++ b/gajim/common/connection.py @@ -593,7 +593,6 @@ class Connection(CommonConnection, ConnectionHandlers): self.connected_hostname = None # Holds the full jid we received on the bind event self.registered_name = None - self.redirected = None self.last_time_to_reconnect = None self.new_account_info = None self.new_account_form = None @@ -794,12 +793,7 @@ class Connection(CommonConnection, ConnectionHandlers): # show error dialog self._connection_lost() else: - if self.redirected: - self.disconnect(on_purpose=True) - self.connect() - return - else: - self.disconnect() + self.disconnect() self.on_purpose = False # END disconnectedReconnCB @@ -988,25 +982,21 @@ class Connection(CommonConnection, ConnectionHandlers): self.name, 'try_connecting_for_foo_secs') proxy = helpers.get_proxy_info(self.name) use_srv = app.config.get_per('accounts', self.name, 'use_srv') - if self.redirected: - use_custom = True - custom_h = self.redirected['host'] - custom_p = self.redirected['port'] - else: - use_custom = app.config.get_per('accounts', self.name, - 'use_custom_host') - if use_custom: - custom_h = app.config.get_per('accounts', self.name, - 'custom_host') - custom_p = app.config.get_per('accounts', self.name, - 'custom_port') - try: - helpers.idn_to_ascii(custom_h) - except Exception: - app.nec.push_incoming_event(InformationEvent( - None, dialog_name='invalid-custom-hostname', - args=custom_h)) - use_custom = False + + use_custom = app.config.get_per('accounts', self.name, + 'use_custom_host') + if use_custom: + custom_h = app.config.get_per('accounts', self.name, + 'custom_host') + custom_p = app.config.get_per('accounts', self.name, + 'custom_port') + try: + helpers.idn_to_ascii(custom_h) + except Exception: + app.nec.push_incoming_event(InformationEvent( + None, dialog_name='invalid-custom-hostname', + args=custom_h)) + use_custom = False # create connection if it doesn't already exist self.connected = 1 @@ -1018,10 +1008,8 @@ class Connection(CommonConnection, ConnectionHandlers): h = custom_h p = custom_p ssl_p = custom_p - if not self.redirected: - use_srv = False + use_srv = False - self.redirected = None # SRV resolver self._proxy = proxy self._hosts = [ @@ -1148,11 +1136,6 @@ class Connection(CommonConnection, ConnectionHandlers): self._current_host = host - if self.redirected: - self.disconnect(on_purpose=True) - self.connect() - return - self._current_type = self._current_host['type'] port = self._current_host['port'] diff --git a/gajim/common/connection_handlers.py b/gajim/common/connection_handlers.py index 3dcddc855..c70211e47 100644 --- a/gajim/common/connection_handlers.py +++ b/gajim/common/connection_handlers.py @@ -774,7 +774,6 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): self.privacy_default_list = None app.nec.register_incoming_event(StreamConflictReceivedEvent) - app.nec.register_incoming_event(StreamOtherHostReceivedEvent) app.nec.register_incoming_event(MessageReceivedEvent) app.nec.register_incoming_event(ArchivingErrorReceivedEvent) app.nec.register_incoming_event( @@ -799,8 +798,6 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): ged.POSTGUI, self._nec_unsubscribed_presence_received_end) app.ged.register_event_handler('agent-removed', ged.CORE, self._nec_agent_removed) - app.ged.register_event_handler('stream-other-host-received', ged.CORE, - self._nec_stream_other_host_received) app.ged.register_event_handler('blocking', ged.CORE, self._nec_blocking) @@ -826,8 +823,6 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): ged.POSTGUI, self._nec_unsubscribed_presence_received_end) app.ged.remove_event_handler('agent-removed', ged.CORE, self._nec_agent_removed) - app.ged.remove_event_handler('stream-other-host-received', ged.CORE, - self._nec_stream_other_host_received) app.ged.remove_event_handler('blocking', ged.CORE, self._nec_blocking) def add_sha(self, p, send_caps=True): @@ -1383,11 +1378,6 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream): probe = nbxmpp.Presence(jid, 'probe', frm=self.get_own_jid()) self.connection.send(probe) - def _nec_stream_other_host_received(self, obj): - if obj.conn.name != self.name: - return - self.redirected = obj.redirected - def _StreamCB(self, con, obj): log.debug('StreamCB') app.nec.push_incoming_event(StreamReceivedEvent(None, diff --git a/gajim/common/connection_handlers_events.py b/gajim/common/connection_handlers_events.py index f5afcd06f..cbb7013bc 100644 --- a/gajim/common/connection_handlers_events.py +++ b/gajim/common/connection_handlers_events.py @@ -331,28 +331,6 @@ class StreamConflictReceivedEvent(nec.NetworkIncomingEvent): self.conn = self.base_event.conn return True -class StreamOtherHostReceivedEvent(nec.NetworkIncomingEvent): - name = 'stream-other-host-received' - base_network_events = ['stream-received'] - - def generate(self): - 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) - 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} - return True - class PresenceHelperEvent: def _generate_show(self): self.show = self.stanza.getShow()