Split CTCPListener from CListener

This splits up CListener into a TCP-specific class and a general class.
The intention is to later add another class inheriting from CListener
that listens on unix sockets.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2017-01-12 10:45:54 +01:00
parent b68fbc64a2
commit 35da5784ca
5 changed files with 93 additions and 55 deletions

View File

@@ -1543,17 +1543,25 @@ void CClient::UserPortCommand(CString& sLine) {
for (const CListener* pListener : vpListeners) {
Table.AddRow();
Table.SetCell("Port", CString(pListener->GetPort()));
Table.SetCell("BindHost", (pListener->GetBindHost().empty()
? CString("*")
: pListener->GetBindHost()));
Table.SetCell("SSL", CString(pListener->IsSSL()));
EAddrType eAddr = pListener->GetAddrType();
Table.SetCell("Proto",
(eAddr == ADDR_ALL
? "All"
: (eAddr == ADDR_IPV4ONLY ? "IPv4" : "IPv6")));
const CTCPListener* pTCPListener = dynamic_cast<const CTCPListener*>(pListener);
if (pTCPListener != nullptr) {
Table.SetCell("Port", CString(pTCPListener->GetPort()));
Table.SetCell("BindHost", (pTCPListener->GetBindHost().empty()
? CString("*")
: pTCPListener->GetBindHost()));
EAddrType eAddr = pTCPListener->GetAddrType();
Table.SetCell("Proto",
(eAddr == ADDR_ALL
? "All"
: (eAddr == ADDR_IPV4ONLY ? "IPv4" : "IPv6")));
} else {
Table.SetCell("Port", "unknown");
}
Table.SetCell("SSL", CString(pListener->IsSSL()));
CListener::EAcceptType eAccept = pListener->GetAcceptType();
Table.SetCell(
@@ -1608,7 +1616,7 @@ void CClient::UserPortCommand(CString& sLine) {
const CString sBindHost = sLine.Token(4);
const CString sURIPrefix = sLine.Token(5);
CListener* pListener = new CListener(uPort, sBindHost, sURIPrefix,
CListener* pListener = new CTCPListener(uPort, sBindHost, sURIPrefix,
bSSL, eAddr, eAccept);
if (!pListener->Listen()) {