Merge remote-tracking branch 'origin/master' into 226-allow-env-to-override-serverconfig

This commit is contained in:
Lion Kortlepel 2023-12-28 13:49:02 +01:00
commit 8cccbe8542
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
11 changed files with 57 additions and 84 deletions

View File

@ -1,7 +1,6 @@
--- ---
name: Bug report name: Bug report
about: Create a report to help us improve about: Create a report to help us improve
title: "[Bug] Enter issue title here"
labels: bug labels: bug
assignees: '' assignees: ''

View File

@ -1,8 +1,7 @@
--- ---
name: Feature request name: Feature request
about: Suggest an idea for this project about: Suggest an idea for this project
title: "[Feature Request]" labels: feature
labels: enhancement
assignees: '' assignees: ''
--- ---

View File

@ -47,14 +47,20 @@ jobs:
name: BeamMP-Server-debian name: BeamMP-Server-debian
path: ./bin/BeamMP-Server path: ./bin/BeamMP-Server
- name: Archive server debug info artifact
uses: actions/upload-artifact@v2
with:
name: BeamMP-Server-debian.debug
path: ./bin/BeamMP-Server.debug
- name: Build Tests - name: Build Tests
run: bash ./scripts/debian-11/3-build-tests.sh run: bash ./scripts/debian-11/3-build-tests.sh
- name: Archive server tests artifact - name: Install Runtime Dependencies
uses: actions/upload-artifact@v2 run: bash ./scripts/debian-11/4-install-runtime-deps.sh
with:
name: BeamMP-Server-debian-tests - name: Test
path: ./bin/BeamMP-Server-tests run: ./bin/BeamMP-Server-tests
ubuntu-22-04-build: ubuntu-22-04-build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -101,51 +107,17 @@ jobs:
name: BeamMP-Server-ubuntu name: BeamMP-Server-ubuntu
path: ./bin/BeamMP-Server path: ./bin/BeamMP-Server
- name: Archive server debug info artifact
uses: actions/upload-artifact@v2
with:
name: BeamMP-Server-ubuntu.debug
path: ./bin/BeamMP-Server.debug
- name: Build Tests - name: Build Tests
run: bash ./scripts/ubuntu-22.04/3-build-tests.sh run: bash ./scripts/ubuntu-22.04/3-build-tests.sh
- name: Archive server tests artifact
uses: actions/upload-artifact@v2
with:
name: BeamMP-Server-ubuntu-tests
path: ./bin/BeamMP-Server-tests
run-debian-11-tests:
needs: debian-11-build
runs-on: ubuntu-latest
container:
image: debian:11
steps:
- uses: actions/download-artifact@master
with:
name: BeamMP-Server-debian-tests
- name: Install Runtime Dependencies - name: Install Runtime Dependencies
run: | run: bash ./scripts/ubuntu-22.04/4-install-runtime-deps.sh
apt-get update -y
apt-get install -y liblua5.3-0
- name: Test - name: Test
run: | run: ./bin/BeamMP-Server-tests
chmod +x ./BeamMP-Server-tests
./BeamMP-Server-tests
run-ubuntu-22-04-tests:
needs: ubuntu-22-04-build
runs-on: ubuntu-latest
container:
image: ubuntu:22.04
steps:
- uses: actions/download-artifact@master
with:
name: BeamMP-Server-ubuntu-tests
- name: Install Runtime Dependencies
run: |
apt-get update -y
apt-get install -y liblua5.3-0
- name: Test
run: |
chmod +x ./BeamMP-Server-tests
./BeamMP-Server-tests

View File

@ -84,6 +84,17 @@ jobs:
asset_name: BeamMP-Server-debian asset_name: BeamMP-Server-debian
asset_content_type: application/x-elf asset_content_type: application/x-elf
- name: Upload Debug Info
id: upload-debug-info
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./bin/BeamMP-Server.debug
asset_name: debuginfo-debian.debug
asset_content_type: application/x-elf
upload-release-files-ubuntu-22-04: upload-release-files-ubuntu-22-04:
name: Build and upload Ubuntu 22.04 Release Files name: Build and upload Ubuntu 22.04 Release Files
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
@ -131,6 +142,17 @@ jobs:
asset_name: BeamMP-Server-ubuntu asset_name: BeamMP-Server-ubuntu
asset_content_type: application/x-elf asset_content_type: application/x-elf
- name: Upload Debug Info
id: upload-debug-info
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./bin/BeamMP-Server.debug
asset_name: debuginfo-ubuntu.debug
asset_content_type: application/x-elf
upload-release-files-windows: upload-release-files-windows:
name: Build and upload Windows Release Files name: Build and upload Windows Release Files
runs-on: windows-latest runs-on: windows-latest

View File

@ -133,7 +133,7 @@ private:
static inline std::mutex mShutdownHandlersMutex {}; static inline std::mutex mShutdownHandlersMutex {};
static inline std::deque<TShutdownHandler> mShutdownHandlers {}; static inline std::deque<TShutdownHandler> mShutdownHandlers {};
static inline Version mVersion { 3, 1, 3 }; static inline Version mVersion { 3, 2, 0 };
}; };
std::string ThreadName(bool DebugModeOverride = false); std::string ThreadName(bool DebugModeOverride = false);

View File

@ -2,4 +2,4 @@
set -ex set -ex
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -s -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON

View File

@ -3,3 +3,8 @@
set -ex set -ex
cmake --build bin --parallel -t BeamMP-Server cmake --build bin --parallel -t BeamMP-Server
objcopy --only-keep-debug bin/BeamMP-Server bin/BeamMP-Server.debug
objcopy --add-gnu-debuglink bin/BeamMP-Server bin/BeamMP-Server.debug
strip -s bin/BeamMP-Server

View File

@ -2,4 +2,4 @@
set -ex set -ex
cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -s -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON cmake . -B bin $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON

View File

@ -3,3 +3,8 @@
set -ex set -ex
cmake --build bin --parallel -t BeamMP-Server cmake --build bin --parallel -t BeamMP-Server
objcopy --only-keep-debug bin/BeamMP-Server bin/BeamMP-Server.debug
objcopy --add-gnu-debuglink bin/BeamMP-Server bin/BeamMP-Server.debug
strip -s bin/BeamMP-Server

View File

@ -37,14 +37,6 @@ static constexpr std::string_view StrSendErrors = "SendErrors";
static constexpr std::string_view StrSendErrorsMessageEnabled = "SendErrorsShowMessage"; static constexpr std::string_view StrSendErrorsMessageEnabled = "SendErrorsShowMessage";
static constexpr std::string_view StrHideUpdateMessages = "ImScaredOfUpdates"; static constexpr std::string_view StrHideUpdateMessages = "ImScaredOfUpdates";
// HTTP
static constexpr std::string_view StrHTTPServerEnabled = "HTTPServerEnabled";
static constexpr std::string_view StrHTTPServerUseSSL = "UseSSL";
static constexpr std::string_view StrSSLKeyPath = "SSLKeyPath";
static constexpr std::string_view StrSSLCertPath = "SSLCertPath";
static constexpr std::string_view StrHTTPServerPort = "HTTPServerPort";
static constexpr std::string_view StrHTTPServerIP = "HTTPServerIP";
TEST_CASE("TConfig::TConfig") { TEST_CASE("TConfig::TConfig") {
const std::string CfgFile = "beammp_server_testconfig.toml"; const std::string CfgFile = "beammp_server_testconfig.toml";
fs::remove(CfgFile); fs::remove(CfgFile);
@ -68,7 +60,6 @@ TEST_CASE("TConfig::TConfig") {
const auto table = toml::parse(CfgFile); const auto table = toml::parse(CfgFile);
CHECK(table.at("General").is_table()); CHECK(table.at("General").is_table());
CHECK(table.at("Misc").is_table()); CHECK(table.at("Misc").is_table());
CHECK(table.at("HTTP").is_table());
fs::remove(CfgFile); fs::remove(CfgFile);
} }
@ -128,16 +119,6 @@ void TConfig::FlushToFile() {
SetComment(data["Misc"][StrSendErrors.data()].comments(), " You can turn on/off the SendErrors message you get on startup here"); SetComment(data["Misc"][StrSendErrors.data()].comments(), " You can turn on/off the SendErrors message you get on startup here");
data["Misc"][StrSendErrorsMessageEnabled.data()] = Application::Settings.SendErrorsMessageEnabled; data["Misc"][StrSendErrorsMessageEnabled.data()] = Application::Settings.SendErrorsMessageEnabled;
SetComment(data["Misc"][StrSendErrorsMessageEnabled.data()].comments(), " If SendErrors is `true`, the server will send helpful info about crashes and other issues back to the BeamMP developers. This info may include your config, who is on your server at the time of the error, and similar general information. This kind of data is vital in helping us diagnose and fix issues faster. This has no impact on server performance. You can opt-out of this system by setting this to `false`"); SetComment(data["Misc"][StrSendErrorsMessageEnabled.data()].comments(), " If SendErrors is `true`, the server will send helpful info about crashes and other issues back to the BeamMP developers. This info may include your config, who is on your server at the time of the error, and similar general information. This kind of data is vital in helping us diagnose and fix issues faster. This has no impact on server performance. You can opt-out of this system by setting this to `false`");
// HTTP
data["HTTP"][StrSSLKeyPath.data()] = Application::Settings.SSLKeyPath;
data["HTTP"][StrSSLCertPath.data()] = Application::Settings.SSLCertPath;
data["HTTP"][StrHTTPServerPort.data()] = Application::Settings.HTTPServerPort;
SetComment(data["HTTP"][StrHTTPServerIP.data()].comments(), " Which IP to listen on. Pick 0.0.0.0 for a public-facing server with no specific IP, and 127.0.0.1 or 'localhost' for a local server.");
data["HTTP"][StrHTTPServerIP.data()] = Application::Settings.HTTPServerIP;
data["HTTP"][StrHTTPServerUseSSL.data()] = Application::Settings.HTTPServerUseSSL;
SetComment(data["HTTP"][StrHTTPServerUseSSL.data()].comments(), " Recommended to have enabled for servers which face the internet. With SSL the server will serve https and requires valid key and cert files");
data["HTTP"][StrHTTPServerEnabled.data()] = Application::Settings.HTTPServerEnabled;
SetComment(data["HTTP"][StrHTTPServerEnabled.data()].comments(), " Enables the internal HTTP server");
std::stringstream Ss; std::stringstream Ss;
Ss << "# This is the BeamMP-Server config file.\n" Ss << "# This is the BeamMP-Server config file.\n"
"# Help & Documentation: `https://wiki.beammp.com/en/home/server-maintenance`\n" "# Help & Documentation: `https://wiki.beammp.com/en/home/server-maintenance`\n"
@ -228,13 +209,6 @@ void TConfig::ParseFromFile(std::string_view name) {
TryReadValue(data, "Misc", StrSendErrors, "", Application::Settings.SendErrors); TryReadValue(data, "Misc", StrSendErrors, "", Application::Settings.SendErrors);
TryReadValue(data, "Misc", StrHideUpdateMessages, "", Application::Settings.HideUpdateMessages); TryReadValue(data, "Misc", StrHideUpdateMessages, "", Application::Settings.HideUpdateMessages);
TryReadValue(data, "Misc", StrSendErrorsMessageEnabled, "", Application::Settings.SendErrorsMessageEnabled); TryReadValue(data, "Misc", StrSendErrorsMessageEnabled, "", Application::Settings.SendErrorsMessageEnabled);
// HTTP
TryReadValue(data, "HTTP", StrSSLKeyPath, "", Application::Settings.SSLKeyPath);
TryReadValue(data, "HTTP", StrSSLCertPath, "", Application::Settings.SSLCertPath);
TryReadValue(data, "HTTP", StrHTTPServerPort, "", Application::Settings.HTTPServerPort);
TryReadValue(data, "HTTP", StrHTTPServerIP, "", Application::Settings.HTTPServerIP);
TryReadValue(data, "HTTP", StrHTTPServerEnabled, "", Application::Settings.HTTPServerEnabled);
TryReadValue(data, "HTTP", StrHTTPServerUseSSL, "", Application::Settings.HTTPServerUseSSL);
} catch (const std::exception& err) { } catch (const std::exception& err) {
beammp_error("Error parsing config file value: " + std::string(err.what())); beammp_error("Error parsing config file value: " + std::string(err.what()));
mFailed = true; mFailed = true;
@ -269,10 +243,6 @@ void TConfig::PrintDebug() {
beammp_debug(std::string(StrDescription) + ": \"" + Application::Settings.ServerDesc + "\""); beammp_debug(std::string(StrDescription) + ": \"" + Application::Settings.ServerDesc + "\"");
beammp_debug(std::string(StrLogChat) + ": \"" + (Application::Settings.LogChat ? "true" : "false") + "\""); beammp_debug(std::string(StrLogChat) + ": \"" + (Application::Settings.LogChat ? "true" : "false") + "\"");
beammp_debug(std::string(StrResourceFolder) + ": \"" + Application::Settings.Resource + "\""); beammp_debug(std::string(StrResourceFolder) + ": \"" + Application::Settings.Resource + "\"");
beammp_debug(std::string(StrSSLKeyPath) + ": \"" + Application::Settings.SSLKeyPath + "\"");
beammp_debug(std::string(StrSSLCertPath) + ": \"" + Application::Settings.SSLCertPath + "\"");
beammp_debug(std::string(StrHTTPServerPort) + ": \"" + std::to_string(Application::Settings.HTTPServerPort) + "\"");
beammp_debug(std::string(StrHTTPServerIP) + ": \"" + Application::Settings.HTTPServerIP + "\"");
// special! // special!
beammp_debug("Key Length: " + std::to_string(Application::Settings.Key.length()) + ""); beammp_debug("Key Length: " + std::to_string(Application::Settings.Key.length()) + "");
beammp_debug("Password Protected: " + std::string(Application::Settings.Password.empty() ? "false" : "true")); beammp_debug("Password Protected: " + std::string(Application::Settings.Password.empty() ? "false" : "true"));

View File

@ -1,6 +1,7 @@
#include "TPluginMonitor.h" #include "TPluginMonitor.h"
#include "TLuaEngine.h" #include "TLuaEngine.h"
#include <filesystem>
TPluginMonitor::TPluginMonitor(const fs::path& Path, std::shared_ptr<TLuaEngine> Engine) TPluginMonitor::TPluginMonitor(const fs::path& Path, std::shared_ptr<TLuaEngine> Engine)
: mEngine(Engine) : mEngine(Engine)
@ -9,7 +10,7 @@ TPluginMonitor::TPluginMonitor(const fs::path& Path, std::shared_ptr<TLuaEngine>
if (!fs::exists(mPath)) { if (!fs::exists(mPath)) {
fs::create_directories(mPath); fs::create_directories(mPath);
} }
for (const auto& Entry : fs::recursive_directory_iterator(mPath)) { for (const auto& Entry : fs::recursive_directory_iterator(mPath, fs::directory_options::follow_directory_symlink)) {
// TODO: trigger an event when a subfolder file changes // TODO: trigger an event when a subfolder file changes
if (Entry.is_regular_file()) { if (Entry.is_regular_file()) {
mFileTimes[Entry.path().string()] = fs::last_write_time(Entry.path()); mFileTimes[Entry.path().string()] = fs::last_write_time(Entry.path());