Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct Settings {
General_Private,
General_IP,
General_Port,
General_RegisterIPv6,
General_MaxCars,
General_LogChat,
General_ResourceFolder,
Expand Down
6 changes: 4 additions & 2 deletions src/Http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ std::string Http::GET(const std::string& url, unsigned int* status) {
std::string Ret;
CurlLease Lease{};
CURL* curl = Lease.GetHandle();
bool Register_IPv6 = Application::Settings.getAsBool(Settings::Key::General_RegisterIPv6);
if (curl) {
CURLcode res;
char errbuf[CURL_ERROR_SIZE];
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, Register_IPv6 ? CURL_IPRESOLVE_V6 : CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, reinterpret_cast<void*>(&Ret));

Expand Down Expand Up @@ -160,11 +161,12 @@ std::string Http::POST(const std::string& url, const std::string& body, const st
std::string Ret;
CurlLease Lease{};
CURL* curl = Lease.GetHandle();
bool Register_IPv6 = Application::Settings.getAsBool(Settings::Key::General_RegisterIPv6);
if (curl) {
CURLcode res;
char errbuf[CURL_ERROR_SIZE];
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, Register_IPv6 ? CURL_IPRESOLVE_V6 : CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, reinterpret_cast<void*>(&Ret));
curl_easy_setopt(curl, CURLOPT_POST, 1L);
Expand Down
2 changes: 2 additions & 0 deletions src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Settings::Settings() {
{ General_Private, true },
{ General_IP, "::"},
{ General_Port, 30814 },
{ General_RegisterIPv6, false },
{ General_MaxCars, 1 },
{ General_LogChat, true },
{ General_ResourceFolder, std::string("Resources") },
Expand All @@ -50,6 +51,7 @@ Settings::Settings() {
{ { "General", "Private" }, { General_Private, READ_ONLY } },
{ { "General", "IP" }, { General_IP, READ_ONLY } },
{ { "General", "Port" }, { General_Port, READ_ONLY } },
{ { "General", "RegisterIPv6" }, { General_RegisterIPv6, READ_ONLY } },
{ { "General", "MaxCars" }, { General_MaxCars, READ_WRITE } },
{ { "General", "LogChat" }, { General_LogChat, READ_ONLY } },
{ { "General", "ResourceFolder" }, { General_ResourceFolder, READ_ONLY } },
Expand Down
6 changes: 6 additions & 0 deletions src/TConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ static constexpr std::string_view StrIP = "IP";
static constexpr std::string_view EnvStrIP = "BEAMMP_IP";
static constexpr std::string_view StrPort = "Port";
static constexpr std::string_view EnvStrPort = "BEAMMP_PORT";
static constexpr std::string_view StrRegisterIPv6 = "RegisterIPv6";
static constexpr std::string_view EnvStrRegisterIPv6 = "BEAMMP_REGISTER_IPV6";
static constexpr std::string_view StrMaxCars = "MaxCars";
static constexpr std::string_view EnvStrMaxCars = "BEAMMP_MAX_CARS";
static constexpr std::string_view StrMaxPlayers = "MaxPlayers";
Expand Down Expand Up @@ -144,6 +146,8 @@ void TConfig::FlushToFile() {
SetComment(data["General"][StrIP.data()].comments(), " The IP address to bind the server to, this is NOT related to your public IP. Can be used if your machine has multiple network interfaces");
data["General"][StrPort.data()] = Application::Settings.getAsInt(Settings::Key::General_Port);
data["General"][StrName.data()] = Application::Settings.getAsString(Settings::Key::General_Name);
SetComment(data["General"][StrRegisterIPv6.data()].comments(), " If true, connect to and register with your public IPv6 (instead of IPv4) address on the backend");
data["General"][StrRegisterIPv6.data()] = Application::Settings.getAsBool(Settings::Key::General_RegisterIPv6);
SetComment(data["General"][StrTags.data()].comments(), " Add custom identifying tags to your server to make it easier to find. Format should be TagA,TagB,TagC. Note the comma seperation.");
data["General"][StrTags.data()] = Application::Settings.getAsString(Settings::Key::General_Tags);
data["General"][StrMaxCars.data()] = Application::Settings.getAsInt(Settings::Key::General_MaxCars);
Expand Down Expand Up @@ -263,6 +267,7 @@ void TConfig::ParseFromFile(std::string_view name) {
} else {
TryReadValue(data, "General", StrIP, EnvStrIP, Settings::Key::General_IP);
}
TryReadValue(data, "General", StrRegisterIPv6, EnvStrRegisterIPv6, Settings::Key::General_RegisterIPv6);
TryReadValue(data, "General", StrMaxCars, EnvStrMaxCars, Settings::Key::General_MaxCars);
TryReadValue(data, "General", StrMaxPlayers, EnvStrMaxPlayers, Settings::Key::General_MaxPlayers);
TryReadValue(data, "General", StrMap, EnvStrMap, Settings::Key::General_Map);
Expand Down Expand Up @@ -314,6 +319,7 @@ void TConfig::PrintDebug() {
beammp_debug(std::string(StrInformationPacket) + ": " + std::string(Application::Settings.getAsBool(Settings::Key::General_InformationPacket) ? "true" : "false"));
beammp_debug(std::string(StrPort) + ": " + std::to_string(Application::Settings.getAsInt(Settings::Key::General_Port)));
beammp_debug(std::string(StrIP) + ": \"" + Application::Settings.getAsString(Settings::Key::General_IP) + "\"");
beammp_debug(std::string(StrRegisterIPv6) + ": \"" + (Application::Settings.getAsBool(Settings::Key::General_RegisterIPv6) ? "true" : "false") + "\"");
beammp_debug(std::string(StrMaxCars) + ": " + std::to_string(Application::Settings.getAsInt(Settings::Key::General_MaxCars)));
beammp_debug(std::string(StrMaxPlayers) + ": " + std::to_string(Application::Settings.getAsInt(Settings::Key::General_MaxPlayers)));
beammp_debug(std::string(StrMap) + ": \"" + Application::Settings.getAsString(Settings::Key::General_Map) + "\"");
Expand Down