Ticket #7134: see_other_host.patch

File see_other_host.patch, 3.4 KB (added by asterix, 4 years ago)
  • src/common/connection.py

    diff -r 77bf2919b7ed src/common/connection.py
    a b  
    689689        self.try_connecting_for_foo_secs = 45
    690690        # holds the actual hostname to which we are connected
    691691        self.connected_hostname = None
     692        self.redirected = None
    692693        self.last_time_to_reconnect = None
    693694        self.new_account_info = None
    694695        self.new_account_form = None
     
    10391040                    self.name, 'try_connecting_for_foo_secs')
    10401041            proxy = helpers.get_proxy_info(self.name)
    10411042            use_srv = gajim.config.get_per('accounts', self.name, 'use_srv')
    1042             use_custom = gajim.config.get_per('accounts', self.name,
     1043            if self.redirected:
     1044                use_custom = True
     1045                custom_h = self.redirected['host']
     1046                custom_p = self.redirected['port']
     1047            else:
     1048                use_custom = gajim.config.get_per('accounts', self.name,
    10431049                    'use_custom_host')
    1044             custom_h = gajim.config.get_per('accounts', self.name, 'custom_host')
    1045             custom_p = gajim.config.get_per('accounts', self.name, 'custom_port')
     1050                custom_h = gajim.config.get_per('accounts', self.name,
     1051                    'custom_host')
     1052                custom_p = gajim.config.get_per('accounts', self.name,
     1053                    'custom_port')
    10461054
    10471055        # create connection if it doesn't already exist
    10481056        self.connected = 1
     
    10541062            h = custom_h
    10551063            p = custom_p
    10561064            ssl_p = custom_p
    1057             use_srv = False
     1065            if not self.redirected:
     1066                use_srv = False
    10581067
     1068        self.redirected = None
    10591069        # SRV resolver
    10601070        self._proxy = proxy
    10611071        self._hosts = [ {'host': h, 'port': p, 'ssl_port': ssl_p, 'prio': 10,
  • src/common/connection_handlers.py

    diff -r 77bf2919b7ed src/common/connection_handlers.py
    a b  
    190190        query.setAttr('node', 'http://gajim.org#' + gajim.version.split('-', 1)[
    191191            0])
    192192        for f in (common.xmpp.NS_BYTESTREAM, common.xmpp.NS_SI,
    193         common.xmpp.NS_FILE, common.xmpp.NS_COMMANDS, 
     193        common.xmpp.NS_FILE, common.xmpp.NS_COMMANDS,
    194194        common.xmpp.NS_JINGLE_FILE_TRANSFER, common.xmpp.NS_JINGLE_XTLS,
    195195        common.xmpp.NS_PUBKEY_PUBKEY, common.xmpp.NS_PUBKEY_REVOKE,
    196196        common.xmpp.NS_PUBKEY_ATTEST):
     
    20142014        if obj.getTag('conflict'):
    20152015            # disconnected because of a resource conflict
    20162016            self.dispatch('RESOURCE_CONFLICT', ())
     2017        other_host = obj.getTag('see-other-host')
     2018        if other_host and self.last_connection_type in ('ssl', 'tls'):
     2019            host = other_host.getData()
     2020            if ':' in host:
     2021                host_l = host.split(':', 1)
     2022                h = host_l[0]
     2023                p = host_l[1]
     2024            else:
     2025                h = host
     2026                p = 5222
     2027            if h.startswith('[') and h.endswith(']'):
     2028                h = h[1:-1]
     2029            self.redirected = {'host': h, 'port': p}
     2030            self.disconnect(on_purpose=True)
     2031            self.connect()
    20172032
    20182033    def _register_handlers(self, con, con_type):
    20192034        # try to find another way to register handlers in each class