mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: check websocket uris to its own method
parent
3b46860776
commit
705119d15a
|
@ -394,6 +394,9 @@ public class OpenviduConfig {
|
|||
Gson gson = new Gson();
|
||||
JsonArray kmsUrisArray = gson.fromJson(kmsUris, JsonArray.class);
|
||||
this.kmsUrisList = JsonUtils.toStringList(kmsUrisArray);
|
||||
for (String uri : kmsUrisList) {
|
||||
this.checkWebsocketUri(uri);
|
||||
}
|
||||
}
|
||||
|
||||
public void initiateOpenViduWebhookEndpoint(String endpoint) throws Exception {
|
||||
|
@ -451,4 +454,14 @@ public class OpenviduConfig {
|
|||
log.info("OpenVidu Webhook events: {}", this.getOpenViduWebhookEvents().toString());
|
||||
}
|
||||
|
||||
public void checkWebsocketUri(String uri) throws MalformedURLException {
|
||||
try {
|
||||
String parsedUri = uri.replaceAll("^ws://", "http://").replaceAll("^wss://", "https://");
|
||||
new URL(parsedUri);
|
||||
} catch (MalformedURLException e) {
|
||||
log.error("URI {} is not a valid WebSocket endpoint", uri);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,13 +68,15 @@ public class Kms {
|
|||
this.uri = uri;
|
||||
this.id = "KMS-" + RandomStringUtils.randomAlphanumeric(6).toUpperCase();
|
||||
|
||||
String parsedUri = uri.replaceAll("^ws://", "http://").replaceAll("^wss://", "https://");
|
||||
URL url = null;
|
||||
try {
|
||||
String parsedUri = "http://" + uri.replaceAll("^ws://", "").replaceAll("^wss://", "");
|
||||
URL url = new URL(parsedUri);
|
||||
this.ip = url.getHost();
|
||||
url = new URL(parsedUri);
|
||||
} catch (MalformedURLException e) {
|
||||
log.error("KMS uri {} is not a valid WebSocket endpoint", uri);
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
this.ip = url.getHost();
|
||||
|
||||
this.loadManager = loadManager;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue