From 18d0dbdc5f6633ceb2996a7ac06eba687f8020df Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 23 Mar 2014 14:57:18 +0100 Subject: [PATCH] Fix Socks5BytestreamManager.determineProxies() We need to catch XMPPErrorException and *NoResponseException* and blacklist those entities. --- .../socks5/Socks5BytestreamManager.java | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java b/extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java index e9fe6c36d..247abd192 100644 --- a/extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java +++ b/extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java @@ -557,7 +557,7 @@ public final class Socks5BytestreamManager implements BytestreamManager { List proxies = new ArrayList(); - // get all items form XMPP server + // get all items from XMPP server DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(this.connection.getServiceName()); Iterator itemIterator = discoverItems.getItems(); @@ -570,32 +570,38 @@ public final class Socks5BytestreamManager implements BytestreamManager { continue; } + DiscoverInfo proxyInfo; try { - DiscoverInfo proxyInfo; proxyInfo = serviceDiscoveryManager.discoverInfo(item.getEntityID()); - Iterator identities = proxyInfo.getIdentities(); - - // item must have category "proxy" and type "bytestream" - while (identities.hasNext()) { - Identity identity = identities.next(); - - if ("proxy".equalsIgnoreCase(identity.getCategory()) - && "bytestreams".equalsIgnoreCase(identity.getType())) { - proxies.add(item.getEntityID()); - break; - } - - /* - * server is not a SOCKS5 proxy, blacklist server to skip next time a Socks5 - * bytestream should be established - */ - this.proxyBlacklist.add(item.getEntityID()); - - } } - catch (XMPPException e) { + catch (NoResponseException e) { // blacklist errornous server + proxyBlacklist.add(item.getEntityID()); + continue; } + catch (XMPPErrorException e) { + // blacklist errornous server + proxyBlacklist.add(item.getEntityID()); + continue; + } + + Iterator identities = proxyInfo.getIdentities(); + + // item must have category "proxy" and type "bytestream" + while (identities.hasNext()) { + Identity identity = identities.next(); + + if ("proxy".equalsIgnoreCase(identity.getCategory()) + && "bytestreams".equalsIgnoreCase(identity.getType())) { + proxies.add(item.getEntityID()); + break; + } + + /* + * server is not a SOCKS5 proxy, blacklist server to skip next time a Socks5 + * bytestream should be established + */ this.proxyBlacklist.add(item.getEntityID()); + } }