From 592135c0e951cdc5c5f978bce4d7c5676e2dc48f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 4 Feb 2013 21:36:39 +0000 Subject: [PATCH] SMACK-395 Socks5BytestreamManager.establishConnection(): Don't bail out with an Exception uf the local XMPP service does not support Service Discovery (e.g. talk.google.com). Instead remember the Exception and give the local proxy (if enabled) a chance. Also compute the digest only if it's really needed, that is when streamHosts is not empty. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13440 b35dd754-fafc-0310-a699-88a17e54d16e --- .../socks5/Socks5BytestreamManager.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java b/source/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java index 41826df13..f9cfdb1ec 100644 --- a/source/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java +++ b/source/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java @@ -414,24 +414,32 @@ public final class Socks5BytestreamManager implements BytestreamManager { public Socks5BytestreamSession establishSession(String targetJID, String sessionID) throws XMPPException, IOException, InterruptedException { + XMPPException discoveryException = null; // check if target supports SOCKS5 Bytestream if (!supportsSocks5(targetJID)) { throw new XMPPException(targetJID + " doesn't support SOCKS5 Bytestream"); } + List proxies = new ArrayList(); // determine SOCKS5 proxies from XMPP-server - List proxies = determineProxies(); + try { + determineProxies(); + } catch (XMPPException e) { + // don't abort here, just remember the exception thrown by determineProxies() + // determineStreamHostInfos() will at least add the local Socks5 proxy (if enabled) + discoveryException = e; + } // determine address and port of each proxy List streamHosts = determineStreamHostInfos(proxies); + if (streamHosts.isEmpty()) { + throw discoveryException != null ? discoveryException : new XMPPException("no SOCKS5 proxies available"); + } + // compute digest String digest = Socks5Utils.createDigest(sessionID, this.connection.getUser(), targetJID); - if (streamHosts.isEmpty()) { - throw new XMPPException("no SOCKS5 proxies available"); - } - // prioritize last working SOCKS5 proxy if exists if (this.proxyPrioritizationEnabled && this.lastWorkingProxy != null) { StreamHost selectedStreamHost = null;