1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-26 04:28:00 +01:00

Websocket implicit discovery should use common ports

When enabled, the websocket implementation will attempt to use two implicit endpoints, using these URLs:
- `wss://[host]:5443/ws`
- `ws://[host]:5443/ws`

These endpoints should include ports that are used by default by known implementations, such as 5280/5281 (Prosody) and 7070/7443 (Openfire).
This commit is contained in:
Guus der Kinderen 2023-01-19 12:31:58 +01:00
parent f65cf45b5c
commit 3f13d90a56

View file

@ -223,16 +223,17 @@ public final class XmppWebSocketTransportModule
} }
if (moduleDescriptor.isImplicitWebSocketEndpointEnabled()) { if (moduleDescriptor.isImplicitWebSocketEndpointEnabled()) {
String urlWithoutScheme = "://" + host + ":5443/ws"; for (final int securePort : new int[] {5443, 5281, 7443}) {
SecureWebSocketRemoteConnectionEndpoint implicitSecureEndpoint = SecureWebSocketRemoteConnectionEndpoint.from( SecureWebSocketRemoteConnectionEndpoint implicitSecureEndpoint = SecureWebSocketRemoteConnectionEndpoint.from(
WebSocketRemoteConnectionEndpoint.SECURE_WEB_SOCKET_SCHEME + urlWithoutScheme); WebSocketRemoteConnectionEndpoint.SECURE_WEB_SOCKET_SCHEME + "://" + host + ":" + securePort + "/ws");
result.discoveredSecureEndpoints.add(implicitSecureEndpoint); result.discoveredSecureEndpoints.add(implicitSecureEndpoint);
}
for (final int insecurePort : new int[] {5443, 5280, 7070}) {
InsecureWebSocketRemoteConnectionEndpoint implicitInsecureEndpoint = InsecureWebSocketRemoteConnectionEndpoint.from( InsecureWebSocketRemoteConnectionEndpoint implicitInsecureEndpoint = InsecureWebSocketRemoteConnectionEndpoint.from(
WebSocketRemoteConnectionEndpoint.INSECURE_WEB_SOCKET_SCHEME + urlWithoutScheme); WebSocketRemoteConnectionEndpoint.INSECURE_WEB_SOCKET_SCHEME + "://" + host + ":" + insecurePort + "/ws");
result.discoveredInsecureEndpoints.add(implicitInsecureEndpoint); result.discoveredInsecureEndpoints.add(implicitInsecureEndpoint);
} }
}
final LookupConnectionEndpointsResult endpointsResult; final LookupConnectionEndpointsResult endpointsResult;
if (result.isEmpty()) { if (result.isEmpty()) {