1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-19 02:22:05 +01:00

[websocket] Factor out known websocket ports in private static fields

This commit is contained in:
Florian Schmaus 2023-02-03 20:57:27 +01:00
parent ae2c53f78c
commit 92f1fe647b

View file

@ -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);