mirror of
https://github.com/znc/znc.git
synced 2026-07-30 13:33:42 +02:00
Move listener config writing into CListener
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
committed by
Uli Schlachter
parent
82d32429d1
commit
b68fbc64a2
@@ -22,6 +22,7 @@
|
||||
|
||||
// Forward Declarations
|
||||
class CRealListener;
|
||||
class CConfig;
|
||||
// !Forward Declarations
|
||||
|
||||
class CListener {
|
||||
@@ -60,6 +61,7 @@ class CListener {
|
||||
|
||||
bool Listen();
|
||||
void ResetRealListener();
|
||||
CConfig ToConfig() const;
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <znc/Listener.h>
|
||||
#include <znc/Config.h>
|
||||
#include <znc/znc.h>
|
||||
|
||||
CListener::~CListener() {
|
||||
@@ -48,6 +49,30 @@ bool CListener::Listen() {
|
||||
m_pListener, 0, m_eAddr);
|
||||
}
|
||||
|
||||
CConfig CListener::ToConfig() const {
|
||||
CConfig listenerConfig;
|
||||
|
||||
listenerConfig.AddKeyValuePair("Host", GetBindHost());
|
||||
listenerConfig.AddKeyValuePair("URIPrefix", GetURIPrefix() + "/");
|
||||
listenerConfig.AddKeyValuePair("Port", CString(GetPort()));
|
||||
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"IPv4", CString(GetAddrType() != ADDR_IPV6ONLY));
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"IPv6", CString(GetAddrType() != ADDR_IPV4ONLY));
|
||||
|
||||
listenerConfig.AddKeyValuePair("SSL", CString(IsSSL()));
|
||||
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"AllowIRC",
|
||||
CString(GetAcceptType() != CListener::ACCEPT_HTTP));
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"AllowWeb",
|
||||
CString(GetAcceptType() != CListener::ACCEPT_IRC));
|
||||
|
||||
return listenerConfig;
|
||||
}
|
||||
|
||||
void CListener::ResetRealListener() { m_pListener = nullptr; }
|
||||
|
||||
CRealListener::~CRealListener() { m_Listener.ResetRealListener(); }
|
||||
|
||||
+1
-22
@@ -497,29 +497,8 @@ bool CZNC::WriteConfig() {
|
||||
|
||||
unsigned int l = 0;
|
||||
for (CListener* pListener : m_vpListeners) {
|
||||
CConfig listenerConfig;
|
||||
|
||||
listenerConfig.AddKeyValuePair("Host", pListener->GetBindHost());
|
||||
listenerConfig.AddKeyValuePair("URIPrefix",
|
||||
pListener->GetURIPrefix() + "/");
|
||||
listenerConfig.AddKeyValuePair("Port", CString(pListener->GetPort()));
|
||||
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"IPv4", CString(pListener->GetAddrType() != ADDR_IPV6ONLY));
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"IPv6", CString(pListener->GetAddrType() != ADDR_IPV4ONLY));
|
||||
|
||||
listenerConfig.AddKeyValuePair("SSL", CString(pListener->IsSSL()));
|
||||
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"AllowIRC",
|
||||
CString(pListener->GetAcceptType() != CListener::ACCEPT_HTTP));
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"AllowWeb",
|
||||
CString(pListener->GetAcceptType() != CListener::ACCEPT_IRC));
|
||||
|
||||
config.AddSubConfig("Listener", "listener" + CString(l++),
|
||||
listenerConfig);
|
||||
pListener->ToConfig());
|
||||
}
|
||||
|
||||
config.AddKeyValuePair("ConnectDelay", CString(m_uiConnectDelay));
|
||||
|
||||
Reference in New Issue
Block a user