diff --git a/CMakeLists.txt b/CMakeLists.txt index b687318d8..9631613dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,10 +66,7 @@ option(USE_CPPCHECK "Enable cppcheck" OFF) option(USE_CLANG_TIDY "Enable Clang Tidy" OFF) set(PKGDATADIR "" CACHE STRING "System directory to search for data files") set(DB_PW "engine" CACHE STRING "The database password") -set(SERVER_DOMAIN "localdomain") -set(SERVER_HOST "localhost.${SERVER_DOMAIN}" CACHE STRING "Host where the server is running on") set(SERVER_PORT "11337" CACHE STRING "Port where the server is listening on") -set(HTTP_SERVER_HOST "${SERVER_HOST}" CACHE STRING "Host where the http server is running on") set(HTTP_SERVER_PORT "8080" CACHE STRING "Port where the http server is listening on") set(DOCKER_REGISTRY "" CACHE STRING "Docker registry") diff --git a/src/engine-config.h.in b/src/engine-config.h.in index a396cd651..550cad765 100644 --- a/src/engine-config.h.in +++ b/src/engine-config.h.in @@ -9,7 +9,6 @@ #define PROJECT_VERSION_MINOR "@PROJECT_VERSION_MINOR@" #define PROJECT_VERSION_PATCH "@PROJECT_VERSION_PATCH@" -#define HTTP_SERVER_HOST "@HTTP_SERVER_HOST@" #define HTTP_SERVER_PORT "@HTTP_SERVER_PORT@" #define SERVER_HOST "@SERVER_HOST@" #define SERVER_PORT "@SERVER_PORT@" diff --git a/src/modules/core/Var.h b/src/modules/core/Var.h index be50966b6..97bce9690 100644 --- a/src/modules/core/Var.h +++ b/src/modules/core/Var.h @@ -121,7 +121,7 @@ public: static VarPtr getSafe(const core::String& name); /** - * @return @c empty string if var with given name wasn't found, otherwise the value of the var + * @return empty string if var with given name wasn't found, otherwise the value of the var */ static core::String str(const core::String& name); diff --git a/src/server/Server.cpp b/src/server/Server.cpp index 65771900e..9a5415d93 100644 --- a/src/server/Server.cpp +++ b/src/server/Server.cpp @@ -51,12 +51,23 @@ core::AppState Server::onConstruct() { core::Var::get(cfg::ServerHost, "0.0.0.0"); core::Var::get(cfg::ServerMaxClients, "1024"); core::Var::get(cfg::ServerHttpPort, HTTP_SERVER_PORT, core::CV_REPLICATE); - core::Var::get(cfg::ServerChunkBaseUrl, "http://" HTTP_SERVER_HOST ":" HTTP_SERVER_PORT "/chunk", core::CV_REPLICATE); core::Var::get(cfg::ServerSeed, "1", core::CV_REPLICATE); core::Var::get(cfg::VoxelMeshSize, "16", core::CV_READONLY); core::Var::get(cfg::DatabaseMinConnections, "2"); core::Var::get(cfg::DatabaseMaxConnections, "100"); + const core::VarPtr& chunkUrl = core::Var::get(cfg::ServerChunkBaseUrl, "", core::CV_REPLICATE); + if (chunkUrl->strVal().empty()) { + char hostname[256]; + size_t size = sizeof(hostname); + if (uv_os_gethostname(hostname, &size) == 0) { + const core::String& url = core::string::format("http://%s:" HTTP_SERVER_PORT "/chunk", hostname); + chunkUrl->setVal(url); + } else { + chunkUrl->setVal("http://localhost:" HTTP_SERVER_PORT "/chunk"); + } + } + _serverLoop->construct(); return state; diff --git a/src/server/deployment/server-ingress.yaml.in b/src/server/deployment/server-ingress.yaml.in index eb27b56df..5851e26a6 100644 --- a/src/server/deployment/server-ingress.yaml.in +++ b/src/server/deployment/server-ingress.yaml.in @@ -8,11 +8,11 @@ spec: issuerRef: name: ca-issuer kind: ClusterIssuer - commonName: @HTTP_SERVER_HOST@ + commonName: server.domain.todo organization: - - @SERVER_DOMAIN@ + - domain.todo dnsNames: - - @HTTP_SERVER_HOST@ + - server.domain.todo --- apiVersion: "networking.k8s.io/v1beta1" kind: "Ingress" @@ -21,7 +21,7 @@ metadata: name: "@PROJECT_NAME@" spec: rules: - - host: @HTTP_SERVER_HOST@ + - host: server.domain.todo http: paths: - path: /