![]() |
Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <WebAdmin.h>
Classes | |
class | abstract |
Interface for getting the content of a single WebTab. | |
class | cWebTab |
Container for a single web tab. More... | |
Public Types | |
typedef std::shared_ptr< cWebTab > | cWebTabPtr |
typedef std::vector< cWebTabPtr > | cWebTabPtrs |
Public Member Functions | |
void | AddWebTab (const AString &a_Title, const AString &a_UrlPath, const AString &a_PluginName, std::shared_ptr< cWebTabCallback > a_Callback) |
Adds a new WebTab handler. More... | |
cWebAdmin (void) | |
bool | DelWebTab (const AString &a_UrlPath) |
Removes the WebTab with the specified URL path. More... | |
cWebTabPtrs | GetAllWebTabs (void) |
Returns a copy of all the registered web tabs. More... | |
sWebAdminPage | GetPage (const HTTPRequest &a_Request) |
Returns the (inner) page contents for the specified request. More... | |
AString | GetPorts (void) const |
Returns the list of ports on which the webadmin is configured to listen. More... | |
bool | Init (void) |
Initializes the object. More... | |
bool | LoadLoginPage (void) |
Loads the login template into m_LoginPage. More... | |
void | Reload (void) |
Reloads m_IniFile, m_LoginPage and m_TemplateScript. More... | |
void | RemoveAllPluginWebTabs (const AString &a_PluginName) |
Removes all WebTabs registered by the specified plugin. More... | |
bool | Start (void) |
Starts the HTTP server taking care of the webadmin. More... | |
void | Stop (void) |
Stops the HTTP server, if it was started. More... | |
virtual | ~cWebAdmin () override |
![]() | |
virtual | ~cCallbacks () |
Static Public Member Functions | |
static AString | GetBaseURL (const AString &a_URL) |
Returns the prefix needed for making a link point to the webadmin root from the given URL ("../../../webadmin"-style). More... | |
static AString | GetBaseURL (const AStringVector &a_URLSplit) |
Returns the prefix needed for making a link point to the webadmin root from the given URL ("../../../webadmin"-style) More... | |
static AString | GetContentTypeFromFileExt (const AString &a_FileExtension) |
Returns the content type from the file extension. More... | |
static AString | GetHTMLEscapedString (const AString &a_Input) |
Escapes text passed into it, so it can be embedded into html. More... | |
static AString | GetURLEncodedString (const AString &a_Input) |
Escapes the string for use in an URL Exported to Lua in ManualBindings.cpp. More... | |
Protected Member Functions | |
void | HandleFileRequest (cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request) |
Handles requests for a file. More... | |
void | HandleRootRequest (cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request) |
Handles requests for the root page. More... | |
void | HandleWebadminRequest (cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request) |
Handles requests coming to the "/webadmin" or "/~webadmin" URLs. More... | |
bool | HasUsers () |
Checks inside the webadmin.ini file if there are users configured. More... | |
bool | LoadIniFile (void) |
Loads webadmin.ini into m_IniFile. More... | |
virtual void | OnRequestBegun (cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request) override |
Called when a new request arrives over a connection and all its headers have been parsed. More... | |
virtual void | OnRequestBody (cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request, const char *a_Data, size_t a_Size) override |
Called when another part of request body has arrived. More... | |
virtual void | OnRequestFinished (cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request) override |
Called when the request body has been fully received in previous calls to OnRequestBody() More... | |
Protected Attributes | |
cCriticalSection | m_CS |
Protects m_WebTabs, m_TemplateScript, m_LoginTemplate and m_IniFile against multithreaded access. More... | |
cHTTPServer | m_HTTPServer |
The HTTP server which provides the underlying HTTP parsing, serialization and events. More... | |
cIniFile | m_IniFile |
The webadmin.ini file, used for the settings and allowed logins. More... | |
bool | m_IsInitialized |
Set to true if Init() succeeds and the webadmin isn't to be disabled. More... | |
bool | m_IsRunning |
Set to true if Start() succeeds in starting the server, reset back to false in Stop(). More... | |
AString | m_LoginPage |
The HTML page that provides the login. More... | |
AStringVector | m_Ports |
The ports on which the webadmin is running. More... | |
cLuaState | m_TemplateScript |
The Lua template script to provide templates. More... | |
cWebTabPtrs | m_WebTabs |
All registered WebTab handlers. More... | |
Definition at line 98 of file WebAdmin.h.
typedef std::shared_ptr<cWebTab> cWebAdmin::cWebTabPtr |
Definition at line 147 of file WebAdmin.h.
typedef std::vector<cWebTabPtr> cWebAdmin::cWebTabPtrs |
Definition at line 148 of file WebAdmin.h.
cWebAdmin::cWebAdmin | ( | void | ) |
Definition at line 61 of file WebAdmin.cpp.
|
overridevirtual |
Definition at line 72 of file WebAdmin.cpp.
void cWebAdmin::AddWebTab | ( | const AString & | a_Title, |
const AString & | a_UrlPath, | ||
const AString & | a_PluginName, | ||
std::shared_ptr< cWebTabCallback > | a_Callback | ||
) |
Adds a new WebTab handler.
a_Title is the display title of the tab a_UrlPath is the part of the URL that uniquely identifies this tab. a_PluginName is the display name of the plugin creating this tab. a_Callback is used to provide the actual WebTab contents, when requested. Exported in ManualBindings.cpp.
Definition at line 538 of file WebAdmin.cpp.
bool cWebAdmin::DelWebTab | ( | const AString & | a_UrlPath | ) |
Removes the WebTab with the specified URL path.
Returns true if WebTab was found and removed, false if not found. Exported in ManualBindings.cpp
Definition at line 553 of file WebAdmin.cpp.
|
inline |
Returns a copy of all the registered web tabs.
Exported to Lua in ManualBindings.cpp.
Definition at line 169 of file WebAdmin.h.
Returns the prefix needed for making a link point to the webadmin root from the given URL ("../../../webadmin"-style).
Definition at line 529 of file WebAdmin.cpp.
|
static |
Returns the prefix needed for making a link point to the webadmin root from the given URL ("../../../webadmin"-style)
Definition at line 613 of file WebAdmin.cpp.
Returns the content type from the file extension.
If the extension isn't in the list, the function returns an empty string.
Definition at line 439 of file WebAdmin.cpp.
Escapes text passed into it, so it can be embedded into html.
Definition at line 573 of file WebAdmin.cpp.
sWebAdminPage cWebAdmin::GetPage | ( | const HTTPRequest & | a_Request | ) |
Returns the (inner) page contents for the specified request.
Calls the appropriate WebTab handler to get the contents. Exported to Lua in ManualBindings.cpp.
Definition at line 478 of file WebAdmin.cpp.
|
inline |
Returns the list of ports on which the webadmin is configured to listen.
Definition at line 186 of file WebAdmin.h.
Escapes the string for use in an URL Exported to Lua in ManualBindings.cpp.
Definition at line 604 of file WebAdmin.cpp.
|
protected |
Handles requests for a file.
Definition at line 387 of file WebAdmin.cpp.
|
protected |
Handles requests for the root page.
Definition at line 372 of file WebAdmin.cpp.
|
protected |
Handles requests coming to the "/webadmin" or "/~webadmin" URLs.
Definition at line 275 of file WebAdmin.cpp.
|
protected |
Checks inside the webadmin.ini file if there are users configured.
Definition at line 258 of file WebAdmin.cpp.
bool cWebAdmin::Init | ( | void | ) |
Initializes the object.
Returns true if successfully initialized and ready to start
Definition at line 81 of file WebAdmin.cpp.
|
protected |
Loads webadmin.ini into m_IniFile.
Creates a default file if it doesn't exist. Returns true if webadmin is enabled, false if disabled.
Definition at line 234 of file WebAdmin.cpp.
bool cWebAdmin::LoadLoginPage | ( | void | ) |
Loads the login template into m_LoginPage.
Returns true if the loading succeeds, false if not.
Definition at line 144 of file WebAdmin.cpp.
|
overrideprotectedvirtual |
Called when a new request arrives over a connection and all its headers have been parsed.
The request body needn't have arrived yet.
Implements cHTTPServer::cCallbacks.
Definition at line 631 of file WebAdmin.cpp.
|
overrideprotectedvirtual |
Called when another part of request body has arrived.
May be called multiple times for a single request.
Implements cHTTPServer::cCallbacks.
Definition at line 655 of file WebAdmin.cpp.
|
overrideprotectedvirtual |
Called when the request body has been fully received in previous calls to OnRequestBody()
Implements cHTTPServer::cCallbacks.
Definition at line 670 of file WebAdmin.cpp.
void cWebAdmin::Reload | ( | void | ) |
Reloads m_IniFile, m_LoginPage and m_TemplateScript.
Note that reloading will not change the "enabled" state of the server, and it will not update listening ports.
Definition at line 182 of file WebAdmin.cpp.
void cWebAdmin::RemoveAllPluginWebTabs | ( | const AString & | a_PluginName | ) |
Removes all WebTabs registered by the specified plugin.
Definition at line 167 of file WebAdmin.cpp.
bool cWebAdmin::Start | ( | void | ) |
Starts the HTTP server taking care of the webadmin.
Returns true if successful
Definition at line 110 of file WebAdmin.cpp.
void cWebAdmin::Stop | ( | void | ) |
Stops the HTTP server, if it was started.
Definition at line 128 of file WebAdmin.cpp.
|
protected |
Protects m_WebTabs, m_TemplateScript, m_LoginTemplate and m_IniFile against multithreaded access.
Definition at line 227 of file WebAdmin.h.
|
protected |
The HTTP server which provides the underlying HTTP parsing, serialization and events.
Definition at line 255 of file WebAdmin.h.
|
protected |
The webadmin.ini file, used for the settings and allowed logins.
Protected against multithreaded access by m_CS.
Definition at line 243 of file WebAdmin.h.
|
protected |
Set to true if Init() succeeds and the webadmin isn't to be disabled.
Definition at line 246 of file WebAdmin.h.
|
protected |
Set to true if Start() succeeds in starting the server, reset back to false in Stop().
Definition at line 249 of file WebAdmin.h.
|
protected |
The HTML page that provides the login.
Protected against multithreaded access by m_CS.
Definition at line 239 of file WebAdmin.h.
|
protected |
The ports on which the webadmin is running.
Definition at line 252 of file WebAdmin.h.
|
protected |
The Lua template script to provide templates.
Protected against multithreaded access by m_CS.
Definition at line 235 of file WebAdmin.h.
|
protected |
All registered WebTab handlers.
Protected against multithreaded access by m_CS.
Definition at line 231 of file WebAdmin.h.