From 8ae5ef1f513d4b3b24c291991215d04f96016453 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 13 Sep 2021 09:55:15 +0200 Subject: [PATCH 1/3] [socks5] Ensure that the local SOCKS5 proxy is running (if enabled) In 9352225f444b ("Rework SOCKS5 unit tests so that they can be run in parallel") the call to getSocks5Proxy() in Socks5BytestreamManager.getLocalStreamHost() was removed. Since getSocks5Proxy() does also start the local proxy, if it is not already running, this caused Smack to no longer automatically start the local proxy. This commit re-adds the call to getSocks5Proxy() and fixes SMACK-912. --- .../smackx/bytestreams/socks5/Socks5BytestreamManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java index f257efa6e..46b438d72 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java @@ -658,6 +658,9 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream * is not running */ public List getLocalStreamHost() { + // Ensure that the local SOCKS5 proxy is running (if enabled). + Socks5Proxy.getSocks5Proxy(); + List streamHosts = new ArrayList<>(); XMPPConnection connection = connection(); From 09710b3203ef7110d1566f1cc8d58b70678a8ae0 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 13 Sep 2021 18:23:59 +0200 Subject: [PATCH 2/3] [socks5] Fix javadoc of getLocalStreamHost() The method does no longer return null. Reported-by: Simon Abykov --- .../smackx/bytestreams/socks5/Socks5BytestreamManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java index 46b438d72..573a7cb42 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java @@ -652,10 +652,9 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream /** * Returns the stream host information of the local SOCKS5 proxy containing the IP address and - * the port or null if local SOCKS5 proxy is not running. + * the port. The returned list may be empty if the local SOCKS5 proxy is not running. * - * @return the stream host information of the local SOCKS5 proxy or null if local SOCKS5 proxy - * is not running + * @return the stream host information of the local SOCKS5 proxy */ public List getLocalStreamHost() { // Ensure that the local SOCKS5 proxy is running (if enabled). From b57cf8375f38d609ec6c6d9597585d1b49d3f806 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 13 Sep 2021 18:25:44 +0200 Subject: [PATCH 3/3] [socks5] Remove stale null check The method getLocalStreamHost() does no longer return 'null', hence the null check is unnecessary. --- .../smackx/bytestreams/socks5/Socks5BytestreamManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java index 573a7cb42..7d8b1a12b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java @@ -615,9 +615,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream if (annouceLocalStreamHost) { // add local proxy on first position if exists List localProxies = getLocalStreamHost(); - if (localProxies != null) { - streamHosts.addAll(localProxies); - } + streamHosts.addAll(localProxies); } // query SOCKS5 proxies for network settings