From d0db485c2496c8889d174da386621b523c876080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Wed, 18 May 2022 08:08:47 -0500 Subject: [PATCH 1/3] fix: Bosh configuration when bosh URI contains IP address. --- .../java/org/jivesoftware/smack/bosh/BOSHConfiguration.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java index f6fe91544..c310c25b3 100644 --- a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java +++ b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java @@ -77,7 +77,9 @@ public final class BOSHConfiguration extends ConnectionConfiguration { } public URI getURI() throws URISyntaxException { - return new URI((https ? "https://" : "http://") + this.host + ":" + this.port + file); + return new URI((https ? "https://" : "http://") + + (this.host != null ? this.host : this.hostAddress) + + ":" + this.port + file); } public Map getHttpHeaders() { From 00bcbff5ee8a499f00325a64dc057fcfc1309a96 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 18 May 2022 21:45:00 +0200 Subject: [PATCH 2/3] [core] Add ConnectionConfiguration.getHostString() --- .../jivesoftware/smack/ConnectionConfiguration.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java b/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java index e8689d24f..9561a158d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java @@ -302,6 +302,16 @@ public abstract class ConnectionConfiguration { return new SmackTlsContext(context, daneVerifier); } + public String getHostString() { + if (hostAddress != null) { + return hostAddress.toString(); + } + if (host != null) { + return host.toString(); + } + return xmppServiceDomain.toString(); + } + public DnsName getHost() { return host; } From aa441d743cb0fd2b9fdbdb5848479c5cc37d6223 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 18 May 2022 21:45:32 +0200 Subject: [PATCH 3/3] [bosh] Use ConnectionConfiguration.getHostString() in BOSHConfiguration --- .../java/org/jivesoftware/smack/bosh/BOSHConfiguration.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java index c310c25b3..680e37975 100644 --- a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java +++ b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java @@ -77,9 +77,8 @@ public final class BOSHConfiguration extends ConnectionConfiguration { } public URI getURI() throws URISyntaxException { - return new URI((https ? "https://" : "http://") - + (this.host != null ? this.host : this.hostAddress) - + ":" + this.port + file); + String uri = https ? "https://" : "http://" + getHostString() + ":" + this.port + file; + return new URI(uri); } public Map getHttpHeaders() {