mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-21 01:57:57 +01:00
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
This commit is contained in:
parent
55893400c7
commit
592135c0e9
1 changed files with 13 additions and 5 deletions
|
@ -414,24 +414,32 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
public Socks5BytestreamSession establishSession(String targetJID, String sessionID)
|
public Socks5BytestreamSession establishSession(String targetJID, String sessionID)
|
||||||
throws XMPPException, IOException, InterruptedException {
|
throws XMPPException, IOException, InterruptedException {
|
||||||
|
|
||||||
|
XMPPException discoveryException = null;
|
||||||
// check if target supports SOCKS5 Bytestream
|
// check if target supports SOCKS5 Bytestream
|
||||||
if (!supportsSocks5(targetJID)) {
|
if (!supportsSocks5(targetJID)) {
|
||||||
throw new XMPPException(targetJID + " doesn't support SOCKS5 Bytestream");
|
throw new XMPPException(targetJID + " doesn't support SOCKS5 Bytestream");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> proxies = new ArrayList<String>();
|
||||||
// determine SOCKS5 proxies from XMPP-server
|
// determine SOCKS5 proxies from XMPP-server
|
||||||
List<String> 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
|
// determine address and port of each proxy
|
||||||
List<StreamHost> streamHosts = determineStreamHostInfos(proxies);
|
List<StreamHost> streamHosts = determineStreamHostInfos(proxies);
|
||||||
|
|
||||||
|
if (streamHosts.isEmpty()) {
|
||||||
|
throw discoveryException != null ? discoveryException : new XMPPException("no SOCKS5 proxies available");
|
||||||
|
}
|
||||||
|
|
||||||
// compute digest
|
// compute digest
|
||||||
String digest = Socks5Utils.createDigest(sessionID, this.connection.getUser(), targetJID);
|
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
|
// prioritize last working SOCKS5 proxy if exists
|
||||||
if (this.proxyPrioritizationEnabled && this.lastWorkingProxy != null) {
|
if (this.proxyPrioritizationEnabled && this.lastWorkingProxy != null) {
|
||||||
StreamHost selectedStreamHost = null;
|
StreamHost selectedStreamHost = null;
|
||||||
|
|
Loading…
Reference in a new issue