Add functions for modifing the ports on which znc listens

Patch is based on a patch from BrianC, thanks a lot.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1866 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-04-01 08:39:10 +00:00
parent 260c42fbe0
commit cac29752cf
2 changed files with 48 additions and 0 deletions
+43
View File
@@ -1821,6 +1821,49 @@ bool CZNC::AddUser(CUser* pUser, CString& sErrorRet) {
return true;
}
CListener* CZNC::FindListener(u_short uPort, const CString& sBindHost, EAddrType eAddr) {
vector<CListener*>::iterator it;
for (it = m_vpListeners.begin(); it < m_vpListeners.end(); ++it) {
if ((*it)->GetPort() != uPort)
continue;
if ((*it)->GetBindHost() != sBindHost)
continue;
if ((*it)->GetAddrType() != eAddr)
continue;
return *it;
}
return NULL;
}
bool CZNC::AddListener(CListener* pListener) {
if (!pListener->GetRealListener()) {
// Listener doesnt actually listen
delete pListener;
return false;
}
// We don't check if there is an identical listener already listening
// since one can't listen on e.g. the same port multiple times
m_vpListeners.push_back(pListener);
return true;
}
bool CZNC::DelListener(CListener* pListener) {
vector<CListener*>::iterator it;
for (it = m_vpListeners.begin(); it < m_vpListeners.end(); ++it) {
if (*it == pListener) {
m_vpListeners.erase(it);
delete *it;
return true;
}
}
return false;
}
CZNC& CZNC::Get() {
static CZNC* pZNC = new CZNC;
return *pZNC;