Remove --disable-modules

ZNC without modules is like rain without being inside,
you really don't want that!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1794 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-02-25 12:29:40 +00:00
parent e4f907dc42
commit f72e2f8abd
17 changed files with 9 additions and 185 deletions

View File

@@ -215,13 +215,11 @@ void CChan::ModeChange(const CString& sModes, const CString& sOpNick) {
CString sArgs = sModes.Token(1, true);
bool bAdd = true;
#ifdef _MODULES
CNick* pOpNick = FindNick(sOpNick);
if (pOpNick) {
MODULECALL(OnRawMode(*pOpNick, *this, sModeArg, sArgs), m_pUser, NULL, );
}
#endif
for (unsigned int a = 0; a < sModeArg.size(); a++) {
const unsigned char& uMode = sModeArg[a];
@@ -250,7 +248,6 @@ void CChan::ModeChange(const CString& sModes, const CString& sOpNick) {
RemPerm(uPerm);
}
}
#ifdef _MODULES
bool bNoChange = (pNick->HasPerm(uPerm) == bAdd);
if (uMode && pOpNick) {
@@ -270,7 +267,6 @@ void CChan::ModeChange(const CString& sModes, const CString& sOpNick) {
}
}
}
#endif
}
}
} else {
@@ -295,7 +291,6 @@ void CChan::ModeChange(const CString& sModes, const CString& sOpNick) {
break;
}
#ifdef _MODULES
bool bNoChange;
if (bList) {
bNoChange = false;
@@ -305,7 +300,6 @@ void CChan::ModeChange(const CString& sModes, const CString& sOpNick) {
bNoChange = !HasMode(uMode);
}
MODULECALL(OnMode(*pOpNick, *this, uMode, sArg, bAdd, bNoChange), m_pUser, NULL, );
#endif
if (!bList) {
(bAdd) ? AddMode(uMode, sArg) : RemMode(uMode);

View File

@@ -64,7 +64,6 @@ void CClient::ReadLine(const CString& sData) {
DEBUG("(" << ((m_pUser) ? m_pUser->GetUserName() : GetRemoteIP()) << ") CLI -> ZNC [" << sLine << "]");
#ifdef _MODULES
if (IsAttached()) {
MODULECALL(OnUserRaw(sLine), m_pUser, this, return);
} else {
@@ -91,7 +90,6 @@ void CClient::ReadLine(const CString& sData) {
return;
}
}
#endif
CString sCommand = sLine.Token(0);
if (sCommand.Left(1) == ":") {
@@ -176,12 +174,10 @@ void CClient::ReadLine(const CString& sData) {
else
UserCommand(sModCommand);
} else {
#ifdef _MODULES
if (sModCommand.empty())
CALLMOD(sTarget, this, m_pUser, PutModule("Hello. How may I help you?"))
else
CALLMOD(sTarget, this, m_pUser, OnModCommand(sModCommand))
#endif
}
return;
} else if (sCommand.Equals("DETACH")) {
@@ -332,11 +328,9 @@ void CClient::ReadLine(const CString& sData) {
}
if (sTarget.TrimPrefix(m_pUser->GetStatusPrefix())) {
#ifdef _MODULES
if (!sTarget.Equals("status")) {
CALLMOD(sTarget, this, m_pUser, OnModNotice(sMsg));
}
#endif
return;
}
@@ -348,7 +342,6 @@ void CClient::ReadLine(const CString& sData) {
}
#endif
#ifdef _MODULES
if (sMsg.WildCmp("\001*\001")) {
CString sCTCP = sMsg;
sCTCP.LeftChomp();
@@ -360,7 +353,6 @@ void CClient::ReadLine(const CString& sData) {
} else {
MODULECALL(OnUserNotice(sTarget, sMsg), m_pUser, this, return);
}
#endif
if (!GetIRCSock()) {
// Some lagmeters do a NOTICE to their own nick, ignore those.
@@ -498,9 +490,7 @@ void CClient::ReadLine(const CString& sData) {
if (sTarget.Equals("status")) {
StatusCTCP(sCTCP);
} else {
#ifdef _MODULES
CALLMOD(sTarget, this, m_pUser, OnModCTCP(sCTCP));
#endif
}
return;
}
@@ -540,9 +530,7 @@ void CClient::ReadLine(const CString& sData) {
if (sTarget.Equals("status")) {
UserCommand(sMsg);
} else {
#ifdef _MODULES
CALLMOD(sTarget, this, m_pUser, OnModCommand(sMsg));
#endif
}
return;
}
@@ -622,26 +610,6 @@ bool CClient::SendMotd() {
}
void CClient::AuthUser() {
/*
#ifdef _MODULES
if (CZNC::Get().GetModules().OnLoginAttempt(m_sUser, m_sPass, *this)) {
return;
}
#endif
CUser* pUser = CZNC::Get().GetUser(m_sUser);
if (pUser && pUser->CheckPass(m_sPass)) {
AcceptLogin(*pUser);
} else {
if (pUser) {
pUser->PutStatus("Another client attempted to login as you, with a bad password.");
}
RefuseLogin();
}
*/
m_spAuth = new CClientAuth(this, m_sUser, m_sPass);
CZNC::Get().AuthUser(m_spAuth);
@@ -689,9 +657,7 @@ void CAuthBase::RefuseLogin(const CString& sReason) {
"to login as you, but was rejected [" + sReason + "].");
}
#ifdef _MODULES
CZNC::Get().GetModules().OnFailedLogin(GetUsername(), GetRemoteIP());
#endif
RefusedLogin(sReason);
Invalidate();
}

View File

@@ -547,7 +547,6 @@ void CClient::UserCommand(CString& sLine) {
PutStatus("You have no active DCCs.");
}
} else if (sCommand.Equals("LISTMODS") || sCommand.Equals("LISTMODULES")) {
#ifdef _MODULES
if (m_pUser->IsAdmin()) {
CModules& GModules = CZNC::Get().GetModules();
@@ -587,12 +586,8 @@ void CClient::UserCommand(CString& sLine) {
PutStatus(Table);
}
#else
PutStatus("Modules are not enabled.");
#endif
return;
} else if (sCommand.Equals("LISTAVAILMODS") || sCommand.Equals("LISTAVAILABLEMODULES")) {
#ifdef _MODULES
if (m_pUser->DenyLoadMod()) {
PutStatus("Access Denied.");
return;
@@ -643,9 +638,6 @@ void CClient::UserCommand(CString& sLine) {
PutStatus(Table);
}
#else
PutStatus("Modules are not enabled.");
#endif
return;
} else if (sCommand.Equals("LOADMOD") || sCommand.Equals("LOADMODULE")) {
CString sMod;
@@ -664,7 +656,6 @@ void CClient::UserCommand(CString& sLine) {
return;
}
#ifdef _MODULES
CModInfo ModInfo;
CString sRetMsg;
if (!CZNC::Get().GetModules().GetModInfo(ModInfo, sMod, sRetMsg)) {
@@ -694,9 +685,6 @@ void CClient::UserCommand(CString& sLine) {
}
PutStatus(sModRet);
#else
PutStatus("Unable to load [" + sMod + "] Modules are not enabled.");
#endif
return;
} else if (sCommand.Equals("UNLOADMOD") || sCommand.Equals("UNLOADMODULE")) {
CString sMod;
@@ -706,7 +694,6 @@ void CClient::UserCommand(CString& sLine) {
PutStatus("Unable to unload [" + sMod + "] Access Denied.");
return;
}
#ifdef _MODULES
if (sMod.empty()) {
PutStatus("Usage: UnloadMod <module>");
return;
@@ -723,9 +710,6 @@ void CClient::UserCommand(CString& sLine) {
}
PutStatus(sModRet);
#else
PutStatus("Unable to unload [" + sMod + "] Modules are not enabled.");
#endif
return;
} else if (sCommand.Equals("RELOADMOD") || sCommand.Equals("RELOADMODULE")) {
CString sMod;
@@ -744,7 +728,6 @@ void CClient::UserCommand(CString& sLine) {
return;
}
#ifdef _MODULES
CModInfo ModInfo;
CString sRetMsg;
if (!CZNC::Get().GetModules().GetModInfo(ModInfo, sMod, sRetMsg)) {
@@ -768,14 +751,8 @@ void CClient::UserCommand(CString& sLine) {
}
PutStatus(sModRet);
#else
PutStatus("Unable to unload [" + sMod + "] Modules are not enabled.");
#endif
return;
} else if ((sCommand.Equals("UPDATEMOD") || sCommand.Equals("UPDATEMODULE")) && m_pUser->IsAdmin() ) {
#ifndef _MODULES
PutStatus("Modules are not enabled.");
#else
CString sMod = sLine.Token(1);
if (sMod.empty()) {
@@ -795,7 +772,6 @@ void CClient::UserCommand(CString& sLine) {
PutStatus("Done, but there were errors, some users no longer have ["
+ sMod + "] loaded");
}
#endif
} else if (sCommand.Equals("ADDVHOST") && m_pUser->IsAdmin()) {
CString sVHost = sLine.Token(1);

View File

@@ -6,8 +6,6 @@
* by the Free Software Foundation.
*/
#ifdef _MODULES
#include "Modules.h"
#include "HTTPSock.h"
#include "znc.h"
@@ -459,5 +457,3 @@ void CHTTPSock::ReachedMaxBuffer() {
DEBUG(GetSockName() << " == ReachedMaxBuffer()");
Close();
}
#endif // _MODULES

View File

@@ -6,8 +6,6 @@
* by the Free Software Foundation.
*/
#ifdef _MODULES
#ifndef _HTTPSOCK_H
#define _HTTPSOCK_H
@@ -94,5 +92,3 @@ protected:
};
#endif // !_HTTPSOCK_H
#endif // _MODULES

View File

@@ -32,7 +32,7 @@ DISTCLEAN := Makefile config.log config.status znc-config znc-buildmod .depend \
.PHONY: all man modules clean distclean install
all: znc man @MODTARGET@ $(LIBZNC)
all: znc man modules $(LIBZNC)
ifeq "$(LIBZNC)" ""
OBJS := $(BIN_OBJS) $(LIB_OBJS)
@@ -51,17 +51,11 @@ man:
@$(MAKE) -C man
modules: $(LIBZNC)
@if test -n "@MODTARGET@"; then \
$(MAKE) -C modules; \
else \
echo "Modules are not enabled"; \
fi
$(MAKE) -C modules;
clean:
rm -rf $(CLEAN)
@if test -n "@MODTARGET@"; then \
$(MAKE) -C modules clean; \
fi
@$(MAKE) -C modules clean;
@$(MAKE) -C man clean
distclean: clean
@@ -82,9 +76,7 @@ install: znc $(LIBZNC)
install -m 0755 znc-buildmod $(DESTDIR)$(bindir)
install -m 0644 $(srcdir)/*.h $(DESTDIR)$(includedir)/znc
install -m 0644 znc.pc $(DESTDIR)$(PKGCONFIGDIR)
@if test -n "@MODTARGET@"; then \
$(MAKE) -C modules install DESTDIR=$(DESTDIR); \
fi
@$(MAKE) -C modules install DESTDIR=$(DESTDIR);
if test -n "$(LIBZNC)"; then \
mkdir -p $(DESTDIR)$(LIBZNCDIR) || exit 1 ; \
install -m 0755 $(LIBZNC) $(DESTDIR)$(LIBZNCDIR) || exit 1 ; \

View File

@@ -6,8 +6,6 @@
* by the Free Software Foundation.
*/
#ifdef _MODULES
#include "Modules.h"
#include "User.h"
#include "znc.h"
@@ -990,5 +988,3 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
return p;
}
#endif // _MODULES

View File

@@ -6,8 +6,6 @@
* by the Free Software Foundation.
*/
#ifdef _MODULES
#ifndef _MODULES_H
#define _MODULES_H
@@ -918,5 +916,3 @@ private:
};
#endif // !_MODULES_H
#endif // _MODULES

View File

@@ -28,8 +28,6 @@ unsigned int CSockManager::GetAnonConnectionCount(const CString &sIP) const {
return ret;
}
#ifdef _MODULES
/////////////////// CSocket ///////////////////
CSocket::CSocket(CModule* pModule) : CZNCSock() {
m_pModule = pModule;
@@ -132,5 +130,3 @@ bool CSocket::PutModNotice(const CString& sLine, const CString& sIdent, const CS
void CSocket::SetModule(CModule* p) { m_pModule = p; }
CModule* CSocket::GetModule() const { return m_pModule; }
/////////////////// !CSocket ///////////////////
#endif // _MODULES

View File

@@ -6,8 +6,6 @@
* by the Free Software Foundation.
*/
#ifdef _MODULES
#include "Template.h"
#include "FileUtils.h"
#include <sstream>
@@ -852,5 +850,3 @@ CString CTemplate::GetValue(const CString& sArgs, bool bFromIf) {
return sRet;
}
#endif // _MODULES

View File

@@ -6,8 +6,6 @@
* by the Free Software Foundation.
*/
#ifdef _MODULES
#ifndef _TEMPLATE_H
#define _TEMPLATE_H
@@ -184,5 +182,3 @@ private:
};
#endif // !_TEMPLATE_H
#endif // _MODULES

View File

@@ -59,9 +59,7 @@ CUser::CUser(const CString& sUserName) {
m_uServerIdx = 0;
m_uBytesRead = 0;
m_uBytesWritten = 0;
#ifdef _MODULES
m_pModules = new CModules;
#endif
m_RawBuffer.SetLineCount(100); // This should be more than enough raws, especially since we are buffering the MOTD separately
m_MotdBuffer.SetLineCount(200); // This should be more than enough motd lines
m_bMultiClients = true;
@@ -90,9 +88,7 @@ CUser::CUser(const CString& sUserName) {
CUser::~CUser() {
DelClients();
#ifdef _MODULES
DelModules();
#endif
DelServers();
@@ -110,7 +106,6 @@ CUser::~CUser() {
CZNC::Get().GetManager().DelCronByAddr(m_pUserTimer);
}
#ifdef _MODULES
void CUser::DelModules() {
if (m_pModules) {
delete m_pModules;
@@ -144,7 +139,6 @@ bool CUser::UpdateModule(const CString &sModule) {
return !error;
}
#endif
void CUser::DelClients() {
for (unsigned int c = 0; c < m_vClients.size(); c++) {
@@ -464,7 +458,6 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {
SetTimezoneOffset(User.GetTimezoneOffset());
// !Flags
#ifdef _MODULES
// Modules
set<CString> ssUnloadMods;
CModules& vCurMods = GetModules();
@@ -495,7 +488,6 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {
vCurMods.UnloadModule(*it);
}
// !Modules
#endif // !_MODULES
return true;
}
@@ -682,7 +674,6 @@ bool CUser::WriteConfig(CFile& File) {
File.Write("\n");
}
#ifdef _MODULES
// Modules
CModules& Mods = GetModules();
@@ -699,7 +690,6 @@ bool CUser::WriteConfig(CFile& File) {
File.Write("\n");
}
#endif
// Servers
for (unsigned int b = 0; b < m_vServers.size(); b++) {

6
User.h
View File

@@ -11,9 +11,7 @@
#include "Buffer.h"
#include "FileUtils.h"
#ifdef _MODULES
#include "Modules.h"
#endif
#include "Nick.h"
#include <set>
#include <vector>
@@ -73,7 +71,6 @@ public:
void DelClients();
void DelServers();
#ifdef _MODULES
void DelModules();
// Unloads a module on all users who have it loaded and loads it again.
@@ -83,7 +80,6 @@ public:
CModules& GetModules() { return *m_pModules; }
const CModules& GetModules() const { return *m_pModules; }
// !Modules
#endif
// Buffers
void AddRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.AddLine(sPre, sPost, bIncNick); }
@@ -313,9 +309,7 @@ protected:
map<CString, unsigned int> m_suWebLogoutCounters;
#ifdef _MODULES
CModules* m_pModules;
#endif
};
#endif // !_USER_H

View File

@@ -77,10 +77,6 @@ AC_ARG_ENABLE( [ipv6],
AS_HELP_STRING([--disable-ipv6], [disable ipv6 support]),
[IPV6="$enableval"],
[IPV6="yes"])
AC_ARG_ENABLE( [modules],
AS_HELP_STRING([--disable-modules], [disable modules]),
[MODULES="$enableval"],
[MODULES="yes"])
AC_ARG_ENABLE( [openssl],
AS_HELP_STRING([--disable-openssl], [disable openssl]),
[if test "$enableval" = "no" ; then NOSSL=1; fi],)
@@ -177,7 +173,10 @@ AC_ARG_WITH( [module-data-prefix],
[DATADIR="${datadir}/znc"] )
if test "$MODULES" = "yes"; then
# This used to be
# if test "$MODULES" = "yes"; then
# but I'm too lazy to reindent all of this
if test "yes" = "yes"; then
FOUND_DL=no
# Don't use any libs like -lssl -lcrypto when checking for dlopen(),
@@ -194,14 +193,12 @@ if test "$MODULES" = "yes"; then
AC_MSG_ERROR([could not find dlopen. Try --disable-modules])
fi
appendCXX -D_MODULES
appendMod "$CXXFLAGS"
if test -z "$ISSUN" -a -z "$ISDARWIN"; then
# This is an unknown compiler flag on some OS
appendLD -Wl,--export-dynamic
fi
MODTARGET="modules"
if test -z "$ISCYGWIN" ; then
# cygwin doesn't need -fPIC, everything else does (for modules)
@@ -297,7 +294,6 @@ AC_SUBST([LIBS])
AC_SUBST([LIBZNC])
AC_SUBST([LIBZNCDIR])
AC_SUBST([MODLINK])
AC_SUBST([MODTARGET])
AC_SUBST([NOSSL])
AC_SUBST([EXTRA])
AC_SUBST([PERL])
@@ -311,9 +307,7 @@ AC_CONFIG_FILES([znc-buildmod])
AC_CONFIG_FILES([man/Makefile])
AC_CONFIG_FILES([znc.pc])
AC_CONFIG_FILES([znc-uninstalled.pc])
if test "$MODULES" = "yes"; then
AC_CONFIG_FILES([modules/Makefile])
fi
AC_CONFIG_FILES([modules/Makefile])
AC_OUTPUT
echo
@@ -327,7 +321,6 @@ else
echo "openssl: yes"
fi
echo "c-ares: $ARES"
echo "modules: $MODULES"
if test x"$PERL" = "x" ; then
echo "perl: no"
else

4
main.h
View File

@@ -32,7 +32,6 @@
#define _DATADIR_ "/usr/share/znc"
#endif
#ifdef _MODULES
#define MODULECALL(macFUNC, macUSER, macCLIENT, macEXITER) \
if (macUSER) { \
CGlobalModules& GMods = CZNC::Get().GetModules(); \
@@ -53,9 +52,6 @@
GMods.SetClient(pOldGClient); \
UMods.SetClient(pOldUClient); \
}
#else
#define MODULECALL(macFUNC, macUSER, macCLIENT, macEXITER)
#endif
/** @mainpage
* Welcome to the API documentation for ZNC.

39
znc.cpp
View File

@@ -31,9 +31,7 @@ CZNC::CZNC() {
exit(-1);
}
#ifdef _MODULES
m_pModules = new CGlobalModules();
#endif
m_pISpoofLockFile = NULL;
m_uiConnectDelay = 30;
m_uiAnonIPLimit = 10;
@@ -50,13 +48,11 @@ CZNC::~CZNC() {
if (m_pISpoofLockFile)
ReleaseISpoof();
#ifdef _MODULES
m_pModules->UnloadAll();
for (map<CString,CUser*>::iterator a = m_msUsers.begin(); a != m_msUsers.end(); ++a) {
a->second->GetModules().UnloadAll();
}
#endif
for (size_t b = 0; b < m_vpListeners.size(); b++) {
delete m_vpListeners[b];
@@ -71,9 +67,7 @@ CZNC::~CZNC() {
m_Manager.Cleanup();
DeleteUsers();
#ifdef _MODULES
delete m_pModules;
#endif
ShutdownCsocket();
DeletePidFile();
@@ -108,7 +102,6 @@ CString CZNC::GetUptime() const {
}
bool CZNC::OnBoot() {
#ifdef _MODULES
if (!GetModules().OnBoot()) {
return false;
}
@@ -118,7 +111,6 @@ bool CZNC::OnBoot() {
return false;
}
}
#endif
return true;
}
@@ -200,12 +192,10 @@ bool CZNC::HandleUserDeletion()
CUser* pUser = it->second;
pUser->SetBeingDeleted(true);
#ifdef _MODULES
if (GetModules().OnDeleteUser(*pUser)) {
pUser->SetBeingDeleted(false);
continue;
}
#endif
m_msUsers.erase(pUser->GetUserName());
// Don't use pUser->GetIRCSock(), as that only returns something if the
@@ -217,9 +207,7 @@ bool CZNC::HandleUserDeletion()
}
pUser->DelClients();
#ifdef _MODULES
pUser->DelModules();
#endif
AddBytesRead(pUser->BytesRead());
AddBytesWritten(pUser->BytesWritten());
delete pUser;
@@ -592,7 +580,6 @@ bool CZNC::WriteConfig() {
m_LockFile.Write("VHost = " + m_vsVHosts[v].FirstLine() + "\n");
}
#ifdef _MODULES
CGlobalModules& Mods = GetModules();
for (unsigned int a = 0; a < Mods.size(); a++) {
@@ -605,7 +592,6 @@ bool CZNC::WriteConfig() {
m_LockFile.Write("LoadModule = " + sName.FirstLine() + sArgs + "\n");
}
#endif
for (map<CString,CUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); ++it) {
CString sErr;
@@ -683,7 +669,6 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
vsLines.push_back("Listen" + s6 + " = " + sListenHost + sSSL + CString(uListenPort));
// !Listen
#ifdef _MODULES
set<CModInfo> ssGlobalMods;
GetModules().GetAvailableMods(ssGlobalMods, true);
size_t uNrOtherGlobalMods = FilterUncommonModules(ssGlobalMods);
@@ -731,7 +716,6 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
}
}
}
#endif
// User
CUtils::PrintMessage("");
@@ -791,7 +775,6 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
vsLines.push_back("\tChanModes = " + sAnswer);
}
#ifdef _MODULES
set<CModInfo> ssUserMods;
GetModules().GetAvailableMods(ssUserMods);
size_t uNrOtherUserMods = FilterUncommonModules(ssUserMods);
@@ -840,7 +823,6 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
}
}
}
#endif
vsLines.push_back("");
CUtils::PrintMessage("");
@@ -963,7 +945,6 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
return bFileOpen && CUtils::GetBoolInput("Launch znc now?", true);
}
#ifdef _MODULES
size_t CZNC::FilterUncommonModules(set<CModInfo>& ssModules) {
const char* ns[] = { "webadmin", "admin",
"chansaver", "keepnick", "simple_away", "partyline",
@@ -983,7 +964,6 @@ size_t CZNC::FilterUncommonModules(set<CModInfo>& ssModules) {
return uNrRemoved;
}
#endif
bool CZNC::ParseConfig(const CString& sConfig)
{
@@ -996,13 +976,11 @@ bool CZNC::ParseConfig(const CString& sConfig)
bool CZNC::RehashConfig(CString& sError)
{
#ifdef _MODULES
GetModules().OnPreRehash();
for (map<CString, CUser*>::iterator itb = m_msUsers.begin();
itb != m_msUsers.end(); ++itb) {
itb->second->GetModules().OnPreRehash();
}
#endif
// This clears m_msDelUsers
HandleUserDeletion();
@@ -1012,13 +990,11 @@ bool CZNC::RehashConfig(CString& sError)
m_msUsers.clear();
if (DoRehash(sError)) {
#ifdef _MODULES
GetModules().OnPostRehash();
for (map<CString, CUser*>::iterator it = m_msUsers.begin();
it != m_msUsers.end(); ++it) {
it->second->GetModules().OnPostRehash();
}
#endif
return true;
}
@@ -1094,9 +1070,7 @@ bool CZNC::DoRehash(CString& sError)
CUser* pRealUser = NULL; // If we rehash a user, this is the real one
CChan* pChan = NULL; // Used to keep track of which chan block we are in
unsigned int uLineNum = 0;
#ifdef _MODULES
MCString msModules; // Modules are queued for later loading
#endif
std::list<CGlobalModuleConfigLine> lGlobalModuleConfigLine;
@@ -1429,7 +1403,6 @@ bool CZNC::DoRehash(CString& sError)
} else if (sName.Equals("LoadModule")) {
CString sModName = sValue.Token(0);
CUtils::PrintAction("Loading Module [" + sModName + "]");
#ifdef _MODULES
CString sModRet;
CString sArgs = sValue.Token(1, true);
@@ -1445,10 +1418,6 @@ bool CZNC::DoRehash(CString& sError)
sError = sModRet;
return false;
}
#else
sError = "Modules are not enabled.";
CUtils::PrintStatus(false, sError);
#endif
continue;
}
}
@@ -1544,7 +1513,6 @@ bool CZNC::DoRehash(CString& sError)
continue;
} else if (sName.Equals("LoadModule")) {
#ifdef _MODULES
CString sModName = sValue.Token(0);
CString sArgs = sValue.Token(1, true);
@@ -1555,9 +1523,6 @@ bool CZNC::DoRehash(CString& sError)
return false;
}
msModules[sModName] = sArgs;
#else
CUtils::PrintError("Modules are not enabled.");
#endif
continue;
} else if (sName.Equals("ISpoofFormat")) {
m_sISpoofFormat = sValue;
@@ -1615,7 +1580,6 @@ bool CZNC::DoRehash(CString& sError)
}
}
#ifdef _MODULES
// First step: Load and reload new modules or modules with new arguments
for (MCString::iterator it = msModules.begin(); it != msModules.end(); ++it) {
CString sModName = it->first;
@@ -1684,7 +1648,6 @@ bool CZNC::DoRehash(CString& sError)
CUtils::PrintMessage("unhandled global module config line [GM:" + it->m_sName + "] = [" + it->m_sValue + "]");
}
}
#endif
if (pChan) {
// TODO last <Chan> not closed
@@ -1864,12 +1827,10 @@ CZNC::TrafficStatsMap CZNC::GetTrafficStats(TrafficStatsPair &Users,
}
void CZNC::AuthUser(CSmartPtr<CAuthBase> AuthClass) {
#ifdef _MODULES
// TODO unless the auth module calls it, CUser::IsHostAllowed() is not honoured
if (GetModules().OnLoginAttempt(AuthClass)) {
return;
}
#endif
CUser* pUser = GetUser(AuthClass->GetUsername());

10
znc.h
View File

@@ -11,9 +11,7 @@
#include "Client.h"
#include "FileUtils.h"
#ifdef _MODULES
#include "Modules.h"
#endif
#include "Socket.h"
#include <map>
@@ -92,10 +90,8 @@ public:
enum ConfigState GetConfigState() const { return m_eConfigState; }
CSockManager& GetManager() { return m_Manager; }
const CSockManager& GetManager() const { return m_Manager; }
#ifdef _MODULES
CGlobalModules& GetModules() { return *m_pModules; }
size_t FilterUncommonModules(set<CModInfo>& ssModules);
#endif
CString GetSkinName() const { return m_sSkinName; }
const CString& GetStatusPrefix() const { return m_sStatusPrefix; }
const CString& GetCurPath() const { if (!CFile::Exists(m_sCurPath)) { CDir::MakeDir(m_sCurPath); } return m_sCurPath; }
@@ -170,9 +166,7 @@ protected:
CFile* m_pISpoofLockFile;
unsigned int m_uiConnectDelay;
unsigned int m_uiAnonIPLimit;
#ifdef _MODULES
CGlobalModules* m_pModules;
#endif
unsigned long long m_uBytesRead;
unsigned long long m_uBytesWritten;
CConnectUserTimer *m_pConnectUserTimer;
@@ -192,14 +186,10 @@ public:
virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort) {
CClient *pClient = new CClient(sHost, uPort);
if (CZNC::Get().AllowConnectionFrom(sHost)) {
#ifdef _MODULES
CZNC::Get().GetModules().OnClientConnect(pClient, sHost, uPort);
#endif
} else {
pClient->RefuseLogin("Too many anonymous connections from your IP");
#ifdef _MODULES
CZNC::Get().GetModules().OnFailedLogin("", sHost);
#endif
}
return pClient;
}