diff --git a/hypersomnia/default_config.lua b/hypersomnia/default_config.lua index dbc3739c8..700090cde 100644 --- a/hypersomnia/default_config.lua +++ b/hypersomnia/default_config.lua @@ -35,6 +35,8 @@ return { masterserver = { ip = "0.0.0.0", + ssl_cert_path = "", + ssl_key_path = "", suppress_community_server_webhooks_after_launch_for_secs = 20, server_entry_timeout_secs = 65, diff --git a/src/application/masterserver/masterserver.cpp b/src/application/masterserver/masterserver.cpp index 1f3a22e22..9e4b4aec4 100644 --- a/src/application/masterserver/masterserver.cpp +++ b/src/application/masterserver/masterserver.cpp @@ -180,7 +180,23 @@ void perform_masterserver(const config_lua_table& cfg) try { std::shared_mutex serialized_list_mutex; - httplib::Server http; + std::unique_ptr http_ptr; + + const auto& cert_path = settings.ssl_cert_path; + const auto& key_path = settings.ssl_private_key_path; + + if (!cert_path.empty() && !key_path.empty()) { + LOG("Starting HTTPS server."); + + http_ptr = std::make_unique(cert_path.c_str(), key_path.c_str()); + } + else { + LOG("Starting HTTP server. Cert or key file unspecified."); + + http_ptr = std::make_unique(); + } + + auto& http = *http_ptr; const auto masterserver_dump_path = USER_DIR / "masterserver.dump"; diff --git a/src/application/masterserver/masterserver_settings.h b/src/application/masterserver/masterserver_settings.h index d8c68855a..9ebbcfc4e 100644 --- a/src/application/masterserver/masterserver_settings.h +++ b/src/application/masterserver/masterserver_settings.h @@ -4,6 +4,8 @@ struct masterserver_settings { // GEN INTROSPECTOR struct masterserver_settings std::string ip = "127.0.0.1"; + augs::path_type ssl_cert_path; + augs::path_type ssl_private_key_path; unsigned server_entry_timeout_secs = 60; unsigned suppress_community_server_webhooks_after_launch_for_secs = 20;