Enable websocket port overwrite in advertiser

*Advertises port 80 if the AO Server is behind a reverse proxy, like cloudflare tunnels.
This commit is contained in:
Salanto 2022-06-09 23:55:18 +02:00 committed by Rosemary Witchaven
parent bbd55263df
commit d39f93926f
4 changed files with 22 additions and 1 deletions

View File

@ -73,6 +73,9 @@ ms_ip=https://servers.aceattorneyonline.com/servers
; Optional hostname of your server. Can either be an IP or a DNS name. Disables automatic IP detection of ms3. ; Optional hostname of your server. Can either be an IP or a DNS name. Disables automatic IP detection of ms3.
hostname= hostname=
; Wether or not the server overwrites the advertised webao port to port 80 in order to utilise Cloudflare tunnels.
cloudflare_enabled=false
[Dice] [Dice]
; The maximum number of sides dice can be rolled with. ; The maximum number of sides dice can be rolled with.
max_value=100 max_value=100

View File

@ -449,6 +449,12 @@ class ConfigManager
*/ */
static QString advertiserHostname(); static QString advertiserHostname();
/**
* @brief Returns a dummy port instead of the real port
* @return
*/
static bool advertiserCloudflareMode();
/** /**
* @brief Returns the uptime of the server in miliseconds. * @brief Returns the uptime of the server in miliseconds.
*/ */

View File

@ -29,7 +29,14 @@ Advertiser::Advertiser()
m_hostname = ConfigManager::advertiserHostname(); m_hostname = ConfigManager::advertiserHostname();
m_description = ConfigManager::serverDescription(); m_description = ConfigManager::serverDescription();
m_port = ConfigManager::serverPort(); m_port = ConfigManager::serverPort();
m_ws_port = ConfigManager::webaoPort();
// Cheap workaround to correctly advertise when Cloudflare tunnel is used.
if (ConfigManager::advertiserCloudflareMode()) {
m_ws_port = 80;
}
else {
m_ws_port = ConfigManager::webaoPort();
}
m_masterserver = ConfigManager::advertiserIP(); m_masterserver = ConfigManager::advertiserIP();
m_debug = ConfigManager::advertiserDebug(); m_debug = ConfigManager::advertiserDebug();
} }

View File

@ -610,6 +610,11 @@ QString ConfigManager::advertiserHostname()
return m_settings->value("Advertiser/hostname", "").toString(); return m_settings->value("Advertiser/hostname", "").toString();
} }
bool ConfigManager::advertiserCloudflareMode()
{
return m_settings->value("Advertiser/cloudflare_enabled", "false").toBool();
}
qint64 ConfigManager::uptime() qint64 ConfigManager::uptime()
{ {
return m_uptimeTimer->elapsed(); return m_uptimeTimer->elapsed();