[ServerInfo] Add host info to /info

This commit is contained in:
/dev/root 2019-01-09 21:40:56 +01:00
parent 8e69de5083
commit 6176d26fbb
4 changed files with 22 additions and 0 deletions

View File

@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog v0.3.0](http://keepachangelog.com/en/0.3.0/) and this project adheres to [Semantic Versioning](http://semver.org/).
## [unreleased] - xxxx-xx-xx
### Added
- Add host information to /info endpoint (request)
## [0.6.0] - 2018-12-30
### Added

View File

@ -701,9 +701,11 @@ namespace Components
//if (!Download::VerifyPassword(nc, reinterpret_cast<http_message*>(ev_data))) return;
Utils::InfoString status = ServerInfo::GetInfo();
Utils::InfoString host = ServerInfo::GetHostInfo();
std::map<std::string, json11::Json> info;
info["status"] = status.to_json();
info["host"] = host.to_json();
std::vector<json11::Json> players;

View File

@ -110,6 +110,19 @@ namespace Components
}
}
Utils::InfoString ServerInfo::GetHostInfo()
{
Utils::InfoString info;
// TODO: Possibly add all Dvar starting with _
info.set("admin", Dvar::Var("_Admin").get<const char*>());
info.set("website", Dvar::Var("_Website").get<const char*>());
info.set("email", Dvar::Var("_Email").get<const char*>());
info.set("location", Dvar::Var("_Location").get<const char*>());
return info;
}
Utils::InfoString ServerInfo::GetInfo()
{
int maxclientCount = *Game::svs_numclients;

View File

@ -8,6 +8,7 @@ namespace Components
ServerInfo();
~ServerInfo();
static Utils::InfoString GetHostInfo();
static Utils::InfoString GetInfo();
private: