Add preliminary work for HTTP health endpoint (#68)

* Add preliminary work for HTTP health endpoint

* Http: Fix infinite loop bug in Tx509KeypairGenerator::generateKey()

* update commandline

* Add TLS Support class for use with http server

* Add preliminary HTTP Server; TLS still broken; fix in later commit

* Fix TLS handshake, due to server being unable to serve key/certfile in 'Http.h/Http.cpp'; Cause was httlib not being threadsafe due to being a blocking http library

* Run clang format

* Add option to configure http server port via ServerConfig

* TConfig: add HTTPServerPort to config parsing step

* Fix SSL Cert / Key path not auto generating when not existing

* Add health endpoint; Fix SSL Cert serial no. not refreshing when regenerating

* Switch arround status codes in /health route

* Run clang format

Co-authored-by: Lion Kortlepel <development@kortlepel.com>
This commit is contained in:
awesome_milou
2021-12-05 18:24:55 +01:00
committed by GitHub
parent b33d50361c
commit 9d283738aa
11 changed files with 273 additions and 18 deletions

View File

@@ -40,6 +40,9 @@ public:
, ServerDesc("BeamMP Default Description")
, Resource("Resources")
, MapName("/levels/gridmap_v2/info.json")
, SSLKeyPath("./.ssl/HttpServer/key.pem")
, SSLCertPath("./.ssl/HttpServer/cert.pem")
, HTTPServerPort(8080)
, MaxPlayers(10)
, Private(true)
, MaxCars(1)
@@ -52,6 +55,8 @@ public:
std::string Resource;
std::string MapName;
std::string Key;
std::string SSLKeyPath;
std::string SSLCertPath;
int MaxPlayers;
bool Private;
int MaxCars;
@@ -61,6 +66,7 @@ public:
bool SendErrors;
bool SendErrorsMessageEnabled;
[[nodiscard]] bool HasCustomIP() const { return !CustomIP.empty(); }
int HTTPServerPort;
};
using TShutdownHandler = std::function<void()>;
@@ -162,6 +168,12 @@ void RegisterThread(const std::string& str);
Application::Console().Write(_this_location + std::string("[DEBUG] ") + (x)); \
} \
} while (false)
#define beammp_event(x) \
do { \
if (Application::Settings.DebugModeEnabled) { \
Application::Console().Write(_this_location + std::string("[EVENT] ") + (x)); \
} \
}while(false)
// for those times when you just need to ignore something :^)
// explicity disables a [[nodiscard]] warning
#define beammp_ignore(x) (void)x