mirror of
https://github.com/znc/znc.git
synced 2026-06-25 20:42:15 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user