mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-04 23:06:08 +00:00
add GetServerVersion
This commit is contained in:
@@ -24,6 +24,10 @@ void Application::GracefullyShutdown() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string Application::ServerVersionString() {
|
||||
return mVersion.AsString();
|
||||
}
|
||||
|
||||
std::string Comp(std::string Data) {
|
||||
std::array<char, Biggest> C {};
|
||||
// obsolete
|
||||
@@ -86,3 +90,14 @@ std::string ThreadName() {
|
||||
void RegisterThread(const std::string str) {
|
||||
threadNameMap[std::this_thread::get_id()] = str;
|
||||
}
|
||||
|
||||
Version::Version(uint8_t major, uint8_t minor, uint8_t patch)
|
||||
: major(major)
|
||||
, minor(minor)
|
||||
, patch(patch) { }
|
||||
|
||||
std::string Version::AsString() {
|
||||
std::stringstream ss {};
|
||||
ss << major << "." << minor << "." << patch;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ std::string THeartbeatThread::GenerateCall() {
|
||||
<< "&port=" << Application::Settings.Port
|
||||
<< "&map=" << Application::Settings.MapName
|
||||
<< "&private=" << (Application::Settings.Private ? "true" : "false")
|
||||
<< "&version=" << Application::ServerVersion()
|
||||
<< "&clientversion=" << Application::ClientVersion()
|
||||
<< "&version=" << Application::ServerVersionString()
|
||||
<< "&clientversion=" << Application::ClientVersionString()
|
||||
<< "&name=" << Application::Settings.ServerName
|
||||
<< "&modlist=" << mResourceManager.TrimmedList()
|
||||
<< "&modstotalsize=" << mResourceManager.MaxModSize()
|
||||
|
||||
@@ -782,6 +782,14 @@ int lua_GetOSName(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lua_GetServerVersion(lua_State* L) {
|
||||
const auto& ver = Application::ServerVersion();
|
||||
lua_pushinteger(L, ver.major);
|
||||
lua_pushinteger(L, ver.minor);
|
||||
lua_pushinteger(L, ver.patch);
|
||||
return 3;
|
||||
}
|
||||
|
||||
// status, body = HttpsGET(host, port, target)
|
||||
// example usage:
|
||||
// send a GET https://example.com:443/index.html:
|
||||
@@ -911,6 +919,7 @@ void TLuaFile::Load() {
|
||||
LuaTable::InsertFunction(mLuaState, "GetOSName", lua_GetOSName);
|
||||
LuaTable::InsertFunction(mLuaState, "HttpsGET", lua_HttpsGET);
|
||||
LuaTable::InsertFunction(mLuaState, "HttpsPOST", lua_HttpsPOST);
|
||||
LuaTable::InsertFunction(mLuaState, "GetServerVersion", lua_GetServerVersion);
|
||||
LuaTable::End(mLuaState, "MP");
|
||||
|
||||
lua_register(mLuaState, "print", lua_Print);
|
||||
|
||||
@@ -263,7 +263,7 @@ void TNetwork::Authentication(const TConnection& ClientConnection) {
|
||||
|
||||
if (Rc.size() > 3 && Rc.substr(0, 2) == "VC") {
|
||||
Rc = Rc.substr(2);
|
||||
if (Rc.length() > 4 || Rc != Application::ClientVersion()) {
|
||||
if (Rc.length() > 4 || Rc != Application::ClientVersionString()) {
|
||||
ClientKick(*Client, "Outdated Version!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace json = rapidjson;
|
||||
|
||||
TServer::TServer(int argc, char** argv) {
|
||||
info("BeamMP Server v" + Application::ServerVersion());
|
||||
info("BeamMP Server v" + Application::ServerVersionString());
|
||||
if (argc > 1) {
|
||||
Application::Settings.CustomIP = argv[1];
|
||||
size_t n = std::count(Application::Settings.CustomIP.begin(), Application::Settings.CustomIP.end(), '.');
|
||||
|
||||
Reference in New Issue
Block a user