From 92f1fe647bbbe2b1e8de8c7ffccc3a390dd8e459 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 3 Feb 2023 20:57:27 +0100 Subject: [PATCH] [websocket] Factor out known websocket ports in private static fields --- .../smack/websocket/XmppWebSocketTransportModule.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModule.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModule.java index be4a5675b..9cfa8fe2f 100644 --- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModule.java +++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/XmppWebSocketTransportModule.java @@ -1,6 +1,6 @@ /** * - * Copyright 2020 Aditya Borikar, 2020-2021 Florian Schmaus + * Copyright 2020 Aditya Borikar, 2020-2023 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,6 +68,9 @@ public final class XmppWebSocketTransportModule private static final int WEBSOCKET_NORMAL_CLOSURE = 1000; + private static final int[] KNOWN_SECURE_PORTS = new int[] {5443, 5281, 7443}; + private static final int[] KNOWN_INSECURE_PORTS = new int[] {5443, 5280, 7070}; + private final XmppWebSocketTransport websocketTransport; private AbstractWebSocket websocket; @@ -223,12 +226,12 @@ public final class XmppWebSocketTransportModule } if (moduleDescriptor.isImplicitWebSocketEndpointEnabled()) { - for (final int securePort : new int[] {5443, 5281, 7443}) { + for (final int securePort : KNOWN_SECURE_PORTS) { SecureWebSocketRemoteConnectionEndpoint implicitSecureEndpoint = SecureWebSocketRemoteConnectionEndpoint.from( WebSocketRemoteConnectionEndpoint.SECURE_WEB_SOCKET_SCHEME + "://" + host + ":" + securePort + "/ws"); result.discoveredSecureEndpoints.add(implicitSecureEndpoint); } - for (final int insecurePort : new int[] {5443, 5280, 7070}) { + for (final int insecurePort : KNOWN_INSECURE_PORTS) { InsecureWebSocketRemoteConnectionEndpoint implicitInsecureEndpoint = InsecureWebSocketRemoteConnectionEndpoint.from( WebSocketRemoteConnectionEndpoint.INSECURE_WEB_SOCKET_SCHEME + "://" + host + ":" + insecurePort + "/ws"); result.discoveredInsecureEndpoints.add(implicitInsecureEndpoint);