mirror of
https://github.com/znc/znc.git
synced 2026-08-05 16:33:46 +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;
|
||||
|
||||
@@ -119,6 +119,11 @@ public:
|
||||
bool AddUser(CUser* pUser, CString& sErrorRet);
|
||||
const map<CString,CUser*> & GetUserMap() const { return(m_msUsers); }
|
||||
|
||||
// Listener yummy
|
||||
CListener* FindListener(u_short uPort, const CString& BindHost, EAddrType eAddr);
|
||||
bool AddListener(CListener*);
|
||||
bool DelListener(CListener*);
|
||||
|
||||
// Message of the Day
|
||||
void SetMotd(const CString& sMessage) { ClearMotd(); AddMotd(sMessage); }
|
||||
void AddMotd(const CString& sMessage) { if (!sMessage.empty()) { m_vsMotd.push_back(sMessage); } }
|
||||
|
||||
Reference in New Issue
Block a user