diff --git a/src/common/config.py b/src/common/config.py index 33ef7be85..9b4e0cee7 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -290,6 +290,7 @@ class Config: 'use_stun_server': [opt_bool, False, _('If True, Gajim will try to use a STUN server when using jingle. The one in "stun_server" option, or the one given by the jabber server.')], 'stun_server': [opt_str, '', _('STUN server to use when using jingle')], 'show_affiliation_in_groupchat': [opt_bool, True, _('If True, Gajim will show affiliation of groupchat occupants by adding a colored square to the status icon')], + 'test_ft_proxies_on_startup': [opt_bool, True, _('If True, Gajim will test file transfer proxies on startup to be sure it works. Openfire\'s proxies are known to fail this test even if they work.')], } __options_per_key = { diff --git a/src/common/connection.py b/src/common/connection.py index 380534c5d..0179edd38 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1707,8 +1707,10 @@ class Connection(CommonConnection, ConnectionHandlers): gajim.config.get_per('accounts', self.name, 'use_ft_proxies'): our_fjid = helpers.parse_jid(our_jid + '/' + \ self.server_resource) + testit = gajim.config.get_per('accounts', self.name, + 'test_ft_proxies_on_startup') gajim.proxy65_manager.resolve(obj.fjid, self.connection, - our_fjid, self.name) + our_fjid, default=self.name, testit=testit) if common.xmpp.NS_MUC in obj.features and is_muc: type_ = transport_type or 'jabber' self.muc_jid[type_] = obj.fjid diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 3a5f43534..a0030d850 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1888,10 +1888,13 @@ ConnectionJingle, ConnectionIBBytestream): 'file_transfer_proxies') our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name) + \ '/' + self.server_resource) + testit = gajim.config.get_per('accounts', self.name, + 'test_ft_proxies_on_startup') if cfg_proxies: proxies = [e.strip() for e in cfg_proxies.split(',')] for proxy in proxies: - gajim.proxy65_manager.resolve(proxy, self.connection, our_jid) + gajim.proxy65_manager.resolve(proxy, self.connection, our_jid, + testit=testit) def _on_roster_set(self, roster): gajim.nec.push_incoming_event(RosterReceivedEvent(None, conn=self, diff --git a/src/common/proxy65_manager.py b/src/common/proxy65_manager.py index 5176b460d..80d402e95 100644 --- a/src/common/proxy65_manager.py +++ b/src/common/proxy65_manager.py @@ -55,15 +55,17 @@ class Proxy65Manager: # dict {account: proxy} default proxy for account self.default_proxies = {} - def resolve(self, proxy, connection, sender_jid, default=None): + def resolve(self, proxy, connection, sender_jid, default=None, + testit=True): """ Start + if testit=False, Gajim won't try to resolve it """ if proxy in self.proxies: resolver = self.proxies[proxy] else: # proxy is being ressolved for the first time - resolver = ProxyResolver(proxy, sender_jid) + resolver = ProxyResolver(proxy, sender_jid, testit) self.proxies[proxy] = resolver resolver.add_connection(connection) if default: @@ -115,6 +117,9 @@ class ProxyResolver: self.host = str(host) self.port = int(port) self.jid = unicode(jid) + if not self.testit: + self.state = S_FINISHED + return self.state = S_INITIAL log.info('start resolving %s:%s' % (self.host, self.port)) self.receiver_tester = ReceiverTester(self.host, self.port, self.jid, @@ -209,7 +214,10 @@ class ProxyResolver: query.setNamespace(common.xmpp.NS_BYTESTREAM) connection.send(iq) - def __init__(self, proxy, sender_jid): + def __init__(self, proxy, sender_jid, testit): + """ + if testit is False, don't test it, only get IP/port + """ self.proxy = proxy self.state = S_INITIAL self.active_connection = None @@ -221,6 +229,7 @@ class ProxyResolver: self.port = None self.sid = helpers.get_random_string_16() self.sender_jid = sender_jid + self.testit = testit class HostTester(Socks5, IdleObject): """