mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: optional IPv4 or IPv6
parent
0d426feb22
commit
5ce57dcc7e
|
@ -18,7 +18,9 @@
|
|||
package io.openvidu.server.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -429,8 +431,6 @@ public class OpenviduConfig {
|
|||
|
||||
protected void checkConfigurationProperties() {
|
||||
|
||||
|
||||
|
||||
serverPort = getValue("server.port");
|
||||
|
||||
coturnRedisDbname = getValue("coturn.redis.dbname");
|
||||
|
@ -490,7 +490,8 @@ public class OpenviduConfig {
|
|||
}
|
||||
|
||||
private void checkCoturnIp() {
|
||||
coturnIp = getValue("coturn.ip");
|
||||
String property = "coturn.ip";
|
||||
coturnIp = asOptionalIPv4OrIPv6(property);
|
||||
|
||||
if (coturnIp == null || this.coturnIp.isEmpty()) {
|
||||
try {
|
||||
|
@ -741,6 +742,26 @@ public class OpenviduConfig {
|
|||
return inetAddress;
|
||||
}
|
||||
|
||||
protected String asOptionalIPv4OrIPv6(String property) {
|
||||
String ip = getValue(property);
|
||||
if (ip != null && !ip.isEmpty()) {
|
||||
boolean isIP;
|
||||
try {
|
||||
final InetAddress inet = InetAddress.getByName(ip);
|
||||
isIP = inet instanceof Inet4Address || inet instanceof Inet6Address;
|
||||
if (isIP) {
|
||||
ip = inet.getHostAddress();
|
||||
}
|
||||
} catch (final UnknownHostException e) {
|
||||
isIP = false;
|
||||
}
|
||||
if (!isIP) {
|
||||
addError(property, "Is not a valid IP Address (IPv4 or IPv6)");
|
||||
}
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
protected String asFileSystemPath(String property) {
|
||||
try {
|
||||
String stringPath = this.asNonEmptyString(property);
|
||||
|
|
Loading…
Reference in New Issue