mirror of
https://github.com/znc/znc.git
synced 2026-07-30 05:23:53 +02:00
Implement CListener::ToConfig()
This will later reduce some code duplication. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
@@ -53,7 +53,7 @@ class CListener {
|
||||
|
||||
virtual bool Listen() = 0;
|
||||
void ResetRealListener();
|
||||
virtual CConfig ToConfig() const = 0;
|
||||
virtual CConfig ToConfig() const;
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
+18
-11
@@ -22,6 +22,23 @@ CListener::~CListener() {
|
||||
if (m_pListener) CZNC::Get().GetManager().DelSockByAddr(m_pListener);
|
||||
}
|
||||
|
||||
CConfig CListener::ToConfig() const {
|
||||
CConfig listenerConfig;
|
||||
|
||||
listenerConfig.AddKeyValuePair("URIPrefix", GetURIPrefix() + "/");
|
||||
|
||||
listenerConfig.AddKeyValuePair("SSL", CString(IsSSL()));
|
||||
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"AllowIRC",
|
||||
CString(GetAcceptType() != CListener::ACCEPT_HTTP));
|
||||
listenerConfig.AddKeyValuePair(
|
||||
"AllowWeb",
|
||||
CString(GetAcceptType() != CListener::ACCEPT_IRC));
|
||||
|
||||
return listenerConfig;
|
||||
}
|
||||
|
||||
CTCPListener::~CTCPListener() {
|
||||
}
|
||||
|
||||
@@ -53,10 +70,9 @@ bool CTCPListener::Listen() {
|
||||
}
|
||||
|
||||
CConfig CTCPListener::ToConfig() const {
|
||||
CConfig listenerConfig;
|
||||
CConfig listenerConfig = CListener::ToConfig();
|
||||
|
||||
listenerConfig.AddKeyValuePair("Host", GetBindHost());
|
||||
listenerConfig.AddKeyValuePair("URIPrefix", GetURIPrefix() + "/");
|
||||
listenerConfig.AddKeyValuePair("Port", CString(GetPort()));
|
||||
|
||||
listenerConfig.AddKeyValuePair(
|
||||
@@ -64,15 +80,6 @@ CConfig CTCPListener::ToConfig() const {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user