diff --git a/.env.example b/.env.example index 15385906..462fb17f 100644 --- a/.env.example +++ b/.env.example @@ -14,4 +14,4 @@ EXTERNAL_IP=localhost MARIADB_USER=darkflame MARIADB_PASSWORD=SECRET_VALUE_CHANGE_ME MARIADB_ROOT_PASSWORD=SECRET_VALUE_CHANGE_ME -MARIADB_DATABASE=darkflame \ No newline at end of file +MARIADB_DATABASE=darkflame diff --git a/CMakeVariables.txt b/CMakeVariables.txt index 02173ba7..67b78aac 100644 --- a/CMakeVariables.txt +++ b/CMakeVariables.txt @@ -1,12 +1,8 @@ PROJECT_VERSION_MAJOR=1 -PROJECT_VERSION_MINOR=1 -PROJECT_VERSION_PATCH=0 +PROJECT_VERSION_MINOR=0 +PROJECT_VERSION_PATCH=1 # LICENSE LICENSE=AGPL-3.0 -# The network version. -# 171023 - Darkflame Universe client -# 171022 - Unmodded client -NET_VERSION=171022 # Debugging # Set __dynamic to 1 to enable the -rdynamic flag for the linker, yielding some symbols in crashlogs. __dynamic=1 diff --git a/README.md b/README.md index b7e2a101..b51fa4b0 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ If you would like to build the server faster, append `-j` where number i ### Notes Depending on your operating system, you may need to adjust some pre-processor defines in [CMakeVariables.txt](./CMakeVariables.txt) before building: * If you are on MacOS, ensure OPENSSL_ROOT_DIR is pointing to the openssl root directory. -* If you are using a Darkflame Universe client, ensure NET_VERSION is changed to 171023. +* If you are using a Darkflame Universe client, ensure `client_net_version` in `build/sharedconfig.ini` is changed to 171023. ## Configuring your server This server has a few steps that need to be taken to configure the server for your use case. diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index ce237eac..f56cad7f 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -113,6 +113,17 @@ int main(int argc, char** argv) { Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0"); Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); + uint32_t clientNetVersion = 0; + if (!GeneralUtils::TryParse(Game::config->GetValue("client_net_version"), clientNetVersion)) { + Game::logger->Log("MasterServer", "Failed to parse (%s) as net version. Cannot start server as no clients could connect.",Game::config->GetValue("client_net_version").c_str()); + Game::logger->Log("MasterServer", "As of version 1.1.1, client_net_version is required to be defined in sharedconfig.ini as opposed to in CMakeVariables.txt as NET_VERSION."); + Game::logger->Log("MasterServer", "Rerun cmake to ensure all config values exist. If client_net_version already exists in sharedconfig.ini, please ensure it is a valid number."); + Game::logger->Log("MasterServer", "like 171022"); + return EXIT_FAILURE; + } + + Game::logger->Log("MasterServer", "Using net version %s", Game::config->GetValue("client_net_version").c_str()); + Game::logger->Log("MasterServer", "Starting Master server..."); Game::logger->Log("MasterServer", "Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); Game::logger->Log("MasterServer", "Compiled on: %s", __TIMESTAMP__); diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index 978540c1..4d0d2fad 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -40,7 +40,12 @@ void AuthPackets::HandleHandshake(dServer* server, Packet* packet) { void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, const std::string& nextServerIP, uint16_t nextServerPort, const ServerType serverType) { RakNet::BitStream bitStream; PacketUtils::WriteHeader(bitStream, eConnectionType::SERVER, eServerMessageType::VERSION_CONFIRM); - bitStream.Write(NET_VERSION); + uint32_t netVersion; + if (!GeneralUtils::TryParse(Game::config->GetValue("client_net_version"), netVersion)) { + Game::logger->Log("AuthPackets", "Failed to parse client_net_version. Cannot authenticate to %s:%i", nextServerIP.c_str(), nextServerPort); + return; + } + bitStream.Write(netVersion); bitStream.Write(uint32_t(0x93)); if (serverType == ServerType::Auth) bitStream.Write(uint32_t(1)); //Conn: auth diff --git a/docker-compose.yml b/docker-compose.yml index 4b997e53..d8c3c40a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,7 @@ services: - DATABASE_USER=${MARIADB_USER:-darkflame} - DATABASE_PASSWORD=${MARIADB_PASSWORD:-darkflame} - EXTERNAL_IP=${EXTERNAL_IP:-darkflame} + - BUILD_VERSION=${BUILD_VERSION:?171022} volumes: - ${CLIENT_PATH:?missing_client_path}:/client - shared_configs:/docker/ diff --git a/docker/Dockerfile b/docker/Dockerfile index c5638a20..39153110 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -32,13 +32,12 @@ COPY .clang-* CMake* LICENSE /build/ ARG BUILD_THREADS=1 ARG BUILD_VERSION=171022 -RUN echo "Build server" && \ - mkdir -p cmake_build && \ - cd cmake_build && \ - sed -i -e "s/NET_VERSION=.*/NET_VERSION=${BUILD_VERSION}/g" ../CMakeVariables.txt && \ - sed -i -e "s/__maria_db_connector_compile_jobs__=.*/__maria_db_connector_compile_jobs__=${BUILD_THREADS}/g" ../CMakeVariables.txt && \ - cmake .. -DCMAKE_BUILD_RPATH_USE_ORIGIN=TRUE && \ - make -j $BUILD_THREADS +RUN echo "Build server" +RUN sed -i -e "s/__maria_db_connector_compile_jobs__=.*/__maria_db_connector_compile_jobs__=${BUILD_THREADS}/g" CMakeVariables.txt +RUN mkdir -p cmake_build +RUN cd cmake_build && \ + cmake .. -DCMAKE_BUILD_RPATH_USE_ORIGIN=TRUE && \ + make -j$BUILD_THREADS FROM gcc:12 as runtime diff --git a/docker/setup.sh b/docker/setup.sh index ade67d2e..1944bbba 100755 --- a/docker/setup.sh +++ b/docker/setup.sh @@ -17,9 +17,8 @@ function update_database_ini_values_for() { update_ini $INI_FILE mysql_database $DATABASE update_ini $INI_FILE mysql_username $DATABASE_USER update_ini $INI_FILE mysql_password $DATABASE_PASSWORD - if [[ "$INI_FILE" != "worldconfig.ini" ]]; then - update_ini $INI_FILE external_ip $EXTERNAL_IP - fi + update_ini $INI_FILE client_net_version $BUILD_VERSION + update_ini $INI_FILE external_ip $EXTERNAL_IP } function update_ini_values() { diff --git a/resources/sharedconfig.ini b/resources/sharedconfig.ini index d2c43d11..ad587b18 100644 --- a/resources/sharedconfig.ini +++ b/resources/sharedconfig.ini @@ -36,3 +36,10 @@ maximum_outgoing_bandwidth=80000 # from 512 <= maximum_mtu_size <= 1492 so make sure to keep this # value within that range. maximum_mtu_size=1228 + +# The client network version to allow to connect to this server. +# Client's that do not match this value will be kicked from the server. +# If you are using a Darkflame Universe client, set this value to 171023. +# This cannot just be any arbitrary number. This has to match the same value that is in your client. +# If you do not know what this value is, default it to 171022. +client_net_version=171022