diff options
Diffstat (limited to '')
-rw-r--r-- | src/WebAdmin.cpp | 75 |
1 files changed, 43 insertions, 32 deletions
diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index dbf600c25..13cf3cc41 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -19,7 +19,16 @@ -/// Helper class - appends all player names together in a HTML list +static const char DEFAULT_WEBADMIN_PORTS[] = "8080"; + + + + + +//////////////////////////////////////////////////////////////////////////////// +// cPlayerAccum: + +/** Helper class - appends all player names together in an HTML list */ class cPlayerAccum : public cPlayerListCallback { @@ -40,11 +49,12 @@ public: +//////////////////////////////////////////////////////////////////////////////// +// cWebAdmin: + cWebAdmin::cWebAdmin(void) : m_IsInitialized(false), m_IsRunning(false), - m_PortsIPv4("8080"), - m_PortsIPv6(""), m_TemplateScript("<webadmin_template>") { } @@ -91,8 +101,7 @@ bool cWebAdmin::Init(void) m_IniFile.AddHeaderComment(" Password format: Password=*password*; for example:"); m_IniFile.AddHeaderComment(" [User:admin]"); m_IniFile.AddHeaderComment(" Password=admin"); - m_IniFile.SetValue("WebAdmin", "Port", m_PortsIPv4); - m_IniFile.SetValue("WebAdmin", "PortsIPv6", m_PortsIPv6); + m_IniFile.SetValue("WebAdmin", "Ports", DEFAULT_WEBADMIN_PORTS); m_IniFile.WriteFile("webadmin.ini"); } @@ -104,32 +113,6 @@ bool cWebAdmin::Init(void) LOGD("Initialising WebAdmin..."); - m_PortsIPv4 = m_IniFile.GetValueSet("WebAdmin", "Port", m_PortsIPv4); - m_PortsIPv6 = m_IniFile.GetValueSet("WebAdmin", "PortsIPv6", m_PortsIPv6); - - if (!m_HTTPServer.Initialize(m_PortsIPv4, m_PortsIPv6)) - { - return false; - } - m_IsInitialized = true; - m_IniFile.WriteFile("webadmin.ini"); - return true; -} - - - - - -bool cWebAdmin::Start(void) -{ - if (!m_IsInitialized) - { - // Not initialized - return false; - } - - LOGD("Starting WebAdmin..."); - // Initialize the WebAdmin template script and load the file m_TemplateScript.Create(); m_TemplateScript.RegisterAPILibs(); @@ -141,6 +124,7 @@ bool cWebAdmin::Start(void) return false; } + // Load the login template, provide a fallback default if not found: if (!LoadLoginTemplate()) { LOGWARN("Could not load WebAdmin login template \"%s\", using fallback template.", FILE_IO_PREFIX "webadmin/login_template.html"); @@ -155,7 +139,34 @@ bool cWebAdmin::Start(void) "</center>"; } - m_IsRunning = m_HTTPServer.Start(*this); + // Read the ports to be used: + // Note that historically the ports were stored in the "Port" and "PortsIPv6" values + m_Ports = ReadUpgradeIniPorts(m_IniFile, "WebAdmin", "Ports", "Port", "PortsIPv6", DEFAULT_WEBADMIN_PORTS); + + if (!m_HTTPServer.Initialize()) + { + return false; + } + m_IsInitialized = true; + m_IniFile.WriteFile("webadmin.ini"); + return true; +} + + + + + +bool cWebAdmin::Start(void) +{ + if (!m_IsInitialized) + { + // Not initialized + return false; + } + + LOGD("Starting WebAdmin..."); + + m_IsRunning = m_HTTPServer.Start(*this, m_Ports); return m_IsRunning; } |