Skip to content

Commit

Permalink
Setup SSL on the masterserver
Browse files Browse the repository at this point in the history
  • Loading branch information
geneotech committed Apr 11, 2024
1 parent 20accd9 commit 9b8e46a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions hypersomnia/default_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
18 changes: 17 additions & 1 deletion src/application/masterserver/masterserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<httplib::Server> 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<httplib::SSLServer>(cert_path.c_str(), key_path.c_str());
}
else {
LOG("Starting HTTP server. Cert or key file unspecified.");

http_ptr = std::make_unique<httplib::Server>();
}

auto& http = *http_ptr;

const auto masterserver_dump_path = USER_DIR / "masterserver.dump";

Expand Down
2 changes: 2 additions & 0 deletions src/application/masterserver/masterserver_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 9b8e46a

Please sign in to comment.