# HG changeset patch # User Goffi # Date 1497857815 -7200 # Node ID f51315500eb1a1463ebae05570acbde02457ff42 # Parent 074c2f157dc97cec13dcc042cae9a6b7de0a28ff core: added hosts_dict handling in general config: A way to force host was already available through hosts_dict, but for Android only in [android] section. It has now be moved in general conf as it can be useful in other cases, and improved to handle port too. This way if something like this is present in sat.conf: [DEFAULT] hosts_dict = {"example.net": {"host": "127.0.0.1", "port": 7777}} these values will be used and DNS check will be bypassed. A string can also be used for values, in this case only host is changed. diff -r 074c2f157dc9 -r f51315500eb1 src/core/xmpp.py --- a/src/core/xmpp.py Sat Jun 03 22:24:53 2017 +0200 +++ b/src/core/xmpp.py Mon Jun 19 09:36:55 2017 +0200 @@ -467,12 +467,26 @@ # TODO: remove this hack and fix SRV log.info(u"FIXME: Android hack, ignoring SRV") host = user_jid.host - hosts_map = host_app.memory.getConfig("android", "hosts_dict", {}) - if host in hosts_map: - log.info(u"using {host_to_use} for host {host_ori} as requested in config".format( - host_ori = host, - host_to_use = hosts_map[host])) - host = hosts_map[host] + + hosts_map = host_app.memory.getConfig(None, "hosts_dict", {}) + if host is None and user_jid.host in hosts_map: + host_data = hosts_map[user_jid.host] + if isinstance(host_data, basestring): + host = host_data + elif isinstance(host_data, dict): + if u'host' in host_data: + host = host_data[u'host'] + if u'port' in host_data: + port = host_data[u'port'] + else: + log.warning(_(u"invalid data used for host: {data}").format(data=host_data)) + host_data = None + if host_data is not None: + log.info(u"using {host}:{port} for host {host_ori} as requested in config".format( + host_ori = user_jid.host, + host = host, + port = port)) + wokkel_client.XMPPClient.__init__(self, user_jid, password, host or None, port or C.XMPP_C2S_PORT) SatXMPPEntity.__init__(self, host_app, profile, max_retries) self._progress_cb = {} # callback called when a progress is requested (key = progress id)