mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: HTTPS_PORT check and appended to public URL
parent
2976ecc443
commit
f4155292d5
|
@ -159,7 +159,7 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
private String openviduRecordingComposedUrl;
|
private String openviduRecordingComposedUrl;
|
||||||
|
|
||||||
private String serverPort;
|
private int serverPort;
|
||||||
|
|
||||||
private String coturnRedisDbname;
|
private String coturnRedisDbname;
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
// Plain config properties getters
|
// Plain config properties getters
|
||||||
|
|
||||||
public String getServerPort() {
|
public int getServerPort() {
|
||||||
return this.serverPort;
|
return this.serverPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,29 +385,29 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getValue(String property) {
|
private String getValue(String property) {
|
||||||
|
return this.getValue(property, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getValue(String property, boolean storeInConfigProps) {
|
||||||
String value = null;
|
String value = null;
|
||||||
|
|
||||||
if (propertiesSource != null) {
|
if (propertiesSource != null) {
|
||||||
|
|
||||||
Object valueObj = propertiesSource.get(property);
|
Object valueObj = propertiesSource.get(property);
|
||||||
if (valueObj != null) {
|
if (valueObj != null) {
|
||||||
value = valueObj.toString();
|
value = valueObj.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
value = env.getProperty(property);
|
value = env.getProperty(property);
|
||||||
}
|
}
|
||||||
|
if (storeInConfigProps) {
|
||||||
this.configProps.put(property, value);
|
this.configProps.put(property, value);
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPropertyName(String propertyName) {
|
public String getPropertyName(String propertyName) {
|
||||||
if (SHOW_PROPERTIES_AS_ENV_VARS) {
|
if (SHOW_PROPERTIES_AS_ENV_VARS) {
|
||||||
return propertyName.replace('.', '_').toUpperCase();
|
return propertyName.replace('.', '_').replace('-', '_').toUpperCase();
|
||||||
} else {
|
} else {
|
||||||
return propertyName;
|
return propertyName;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> getNonUserProperties() {
|
protected List<String> getNonUserProperties() {
|
||||||
return Arrays.asList("server.port", "DOTENV_PATH", "COTURN_IP", "COTURN_REDIS_IP", "KMS_URIS",
|
return Arrays.asList("server.port", "SERVER_PORT", "DOTENV_PATH", "COTURN_IP", "COTURN_REDIS_IP", "KMS_URIS",
|
||||||
"COTURN_REDIS_DBNAME", "COTURN_REDIS_PASSWORD", "COTURN_REDIS_CONNECT_TIMEOUT");
|
"COTURN_REDIS_DBNAME", "COTURN_REDIS_PASSWORD", "COTURN_REDIS_CONNECT_TIMEOUT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +454,8 @@ public class OpenviduConfig {
|
||||||
this.populatePropertySourceFromDotenv();
|
this.populatePropertySourceFromDotenv();
|
||||||
}
|
}
|
||||||
|
|
||||||
serverPort = getValue("server.port");
|
checkHttpsPort();
|
||||||
|
checkOpenviduPublicurl();
|
||||||
|
|
||||||
coturnRedisDbname = getValue("COTURN_REDIS_DBNAME");
|
coturnRedisDbname = getValue("COTURN_REDIS_DBNAME");
|
||||||
|
|
||||||
|
@ -464,8 +465,6 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
openviduSecret = asNonEmptyString("OPENVIDU_SECRET");
|
openviduSecret = asNonEmptyString("OPENVIDU_SECRET");
|
||||||
|
|
||||||
checkOpenviduPublicurl();
|
|
||||||
|
|
||||||
openviduCdr = asBoolean("OPENVIDU_CDR");
|
openviduCdr = asBoolean("OPENVIDU_CDR");
|
||||||
openviduCdrPath = openviduCdr ? asWritableFileSystemPath("OPENVIDU_CDR_PATH")
|
openviduCdrPath = openviduCdr ? asWritableFileSystemPath("OPENVIDU_CDR_PATH")
|
||||||
: asFileSystemPath("OPENVIDU_CDR_PATH");
|
: asFileSystemPath("OPENVIDU_CDR_PATH");
|
||||||
|
@ -532,8 +531,7 @@ public class OpenviduConfig {
|
||||||
webhookEventsList = getWebhookEvents();
|
webhookEventsList = getWebhookEvents();
|
||||||
|
|
||||||
if (openviduWebhookEnabled && (openviduWebhookEndpoint == null || openviduWebhookEndpoint.isEmpty())) {
|
if (openviduWebhookEnabled && (openviduWebhookEndpoint == null || openviduWebhookEndpoint.isEmpty())) {
|
||||||
addError("OPENVIDU_WEBHOOK_ENDPOINT",
|
addError("OPENVIDU_WEBHOOK_ENDPOINT", "With OPENVIDU_WEBHOOK=true, this property cannot be empty");
|
||||||
"With " + getPropertyName("OPENVIDU_WEBHOOK") + "=true, this property cannot be empty");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,6 +551,9 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
if (domain != null && !domain.isEmpty()) {
|
if (domain != null && !domain.isEmpty()) {
|
||||||
this.openviduPublicUrl = "https://" + domain;
|
this.openviduPublicUrl = "https://" + domain;
|
||||||
|
if (this.serverPort != 443) {
|
||||||
|
this.openviduPublicUrl += (":" + this.serverPort);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final String urlProperty = "OPENVIDU_PUBLICURL";
|
final String urlProperty = "OPENVIDU_PUBLICURL";
|
||||||
String publicurl = getValue(urlProperty);
|
String publicurl = getValue(urlProperty);
|
||||||
|
@ -575,6 +576,38 @@ public class OpenviduConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkHttpsPort() {
|
||||||
|
String property = "HTTPS_PORT";
|
||||||
|
String httpsPort = getValue(property);
|
||||||
|
if (httpsPort == null) {
|
||||||
|
// This should only occur on dev container
|
||||||
|
property = "SERVER_PORT";
|
||||||
|
httpsPort = getValue(property);
|
||||||
|
if (httpsPort == null) {
|
||||||
|
property = "server.port";
|
||||||
|
httpsPort = getValue(property, false);
|
||||||
|
if (httpsPort == null || httpsPort.isEmpty()) {
|
||||||
|
addError(property, "Cannot be undefined");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int httpsPortNumber = 0;
|
||||||
|
try {
|
||||||
|
httpsPortNumber = Integer.parseInt(httpsPort);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
addError(property, "Is not a valid port. Must be an integer. " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (httpsPortNumber > 0 && httpsPortNumber <= 65535) {
|
||||||
|
serverPort = httpsPortNumber;
|
||||||
|
} else {
|
||||||
|
addError(property, "Is not a valid port. Valid port range exceeded with value " + httpsPortNumber);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void calculatePublicUrl() {
|
private void calculatePublicUrl() {
|
||||||
String publicUrl = this.getOpenViduPublicUrl();
|
String publicUrl = this.getOpenViduPublicUrl();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue