(aka: Brown Paper Bag commit)
When I tested it, it did work. I swear!
Thanks to everyone who pointed out that I broke his znc.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1662 726aef4b-f618-498e-8847-2d620e286838
CModule::RemTimer(const CString& sLabel) now uses FindTimer() and
RemTimer(CTimer *) to do the work instead of doing all of this by itself.
Thanks to KiNgMaR again.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1651 726aef4b-f618-498e-8847-2d620e286838
CModule::RemTimer(CTimer* pTimer) only removed the timer from CModule's own list
of timers but didn't actually destroy the timer. This meant that the timer could
continue to run after it was supposed to be deleted.
Because CModule's destructor used this function this means that all timers
active when a module is unloaded where leaked. When these timers where then
later destroyed this caused a crash because their vtable points inside the
module which was already unloaded (not good!).
Thanks to KiNgMaR for finding and reporting this crash bug.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1650 726aef4b-f618-498e-8847-2d620e286838
CModule has two vectors: A list of timers and a list of sockets for this
module. Since one shouldn't be able to add items multiple times it makes sense
to use a set here instead.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1643 726aef4b-f618-498e-8847-2d620e286838
A queue is a FIFO while a stack is a LIFO. The code which added paths to the
list of available paths expected them to be checked in the order they were
added, but instead they were checked in reverse order. This meant that one could
no longer replace "system modules" with a .so in ~/.znc/modules.
Thanks to DarthGandalf for noticing and reporting this.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1629 726aef4b-f618-498e-8847-2d620e286838
This function works like GetModInfo(), but takes the full path to the module,
too.
This is used to speed up GetAvailableMods(). Before it created a list of module
paths, extracted the names and then called GetModInfo() on those module names
which looked up the path for the modules again. This extra step is now skipped
and the module's path is used directly.
To make this work, the call to FindModPath() was moved from OpenModule() into
its two callers LoadModule() and GetModInfo().
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1613 726aef4b-f618-498e-8847-2d620e286838
This function returns a list of <module dir, data dir> pairs which lists all
places in which modules should be looked for.
FindModPath() and GetAvailableMods() are changed to use this new function.
The list of places to look at is the same that was used before, but this now
also adds ./modules/extra so that modules enabled via --enable-extra are found
before 'make install'.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1612 726aef4b-f618-498e-8847-2d620e286838
Ever since r1505 our error messages when loading modules all were the same:
"Unable to find modinfo"
Improve this by giving the user all the information we offered before again. The
most useful one here is most likely the result from dlerror(). This is done by
adding a helper function CModules::OpenModule(). Most of its code is from
CModules::LoadModule() and this function and CModules::GetModInfo() now both use
this helper function for generating error messages.
This commit adds a "#warning", don't worry I'm working on it.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1596 726aef4b-f618-498e-8847-2d620e286838
Everything which isn't a CClient with a successful login counts as an
unidentified connection in this context. Modules who don't want this kind of
limit on their listening sockets can override CSocket::ConnectionFrom(), but
their sockets will still count towards this limit.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1561 726aef4b-f618-498e-8847-2d620e286838
Classes derived from Csock* can be casted implicitly to their base class, this
explicit casts are rather pointless.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1548 726aef4b-f618-498e-8847-2d620e286838
This was found via partyline and notify_connect. notify_connect calls
CZNC::Broadcast() in OnClientLogin() which calls the OnBroadcast() module call.
When returning from this module calls, m_pUser and m_pClient was reset to NULL
and all the following modules got their OnClientLogin() called with m_pUser and
m_pClient set to NULL.
This patch fixes this by resetting those vars to their old values instead to
NULL when returning from a module call.
This patch also fixes the bug that m_pUser and m_pClient in modules were reset
to NULL after they caused a module call which called back into the current
module. The fix looks similar to the other one (this one is the Modules.h part).
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1438 726aef4b-f618-498e-8847-2d620e286838
When the module was compiled for a wrong ZNC version it's description will
say so. Everything which displays a list of available modules together with
their description will display this (--makeconf, /msg *status listavailmods,
webadmin).
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1420 726aef4b-f618-498e-8847-2d620e286838
Modules.cpp is capsuled in a huge #ifdef _MODULES block (see r767), but some
code in there still uses #ifndef _MODULES, which is never going to be used.
Thanks to Sebastinas for finding this.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1381 726aef4b-f618-498e-8847-2d620e286838
Some of them (eg. GetVersion) where so generic that we even had symbol
clashes (well, on no real worls OS (only windows), but still that's not nice).
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1358 726aef4b-f618-498e-8847-2d620e286838
This makes it clearer what this variable is and it makes porting to windows
easier, because we can just change the typedef to HMODULE.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1344 726aef4b-f618-498e-8847-2d620e286838
Now a module with unresolved symbols will fail to load instead of
potentially getting ZNC killed when an undefined symbol was used.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1332 726aef4b-f618-498e-8847-2d620e286838
Now every module that uses CSocket automatically gets its generated traffic
counted. Those which use Csock directly should be shot and burried anyway ;)
This adds CModule::IsGlobal().
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1283 726aef4b-f618-498e-8847-2d620e286838
OnUserAttached is renamed to OnClientLogin and
OnUserDetached to OnClientDisconnect.
This adds some new function with different arguments for the old names to cause
warnings from -Woverloaded-virtual while compiling.
This patch also adds OnClientConnect() which is called when the low-level
raw connection is established. (No SSL-handshake was done at this point yet!)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1266 726aef4b-f618-498e-8847-2d620e286838
CSocket caches the data read from a socket and then looks for lines in there.
If there is no line end, this buffer can grow quite large. This patch now
closes sockets if they get a huge read buffer.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1233 726aef4b-f618-498e-8847-2d620e286838
It doesn't really make much sense either, because Csock already has contains
a socket name member which can be used for this. This is exactly what this
patch does.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1229 726aef4b-f618-498e-8847-2d620e286838
It's basically OnRawMode() but once per single mode.
Oh and this also fixes a problem where ZNC lost track of chan modes with params
(See hunk in CChan::AddMode).
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1189 726aef4b-f618-498e-8847-2d620e286838
This should remove some additional complexity, but I doubt one can
benchmark these savings...
BTW: Here is what I found out on how this works:
The user module manager (CModules) always has m_pUser set to NULL which means
that it never touches its module's user pointer. That way, the modules
always have the correct pointer.
For global modules, m_pUser is set on some calls. This pointer is then
passed on to the modules and reset afterwards.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1182 726aef4b-f618-498e-8847-2d620e286838
This function displays a CTable via PutModule(), something that is often
needed. The function returns the number of lines displayed.
The idea for this function is from the user-contributed admin module
by Sebastian Ramacher. Thanks.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1168 726aef4b-f618-498e-8847-2d620e286838
The only difference between MODUNLOADCHK and GLOBALMODCALL and between
MODHALTCHK and GLOBALMODHALTCHK was that the one used CModule while the other
one used CGlobalModule.
Create two new macros that expects the class name as an extra parameter and
make all those other macros just call these two.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1166 726aef4b-f618-498e-8847-2d620e286838
This also removes all the code catching those exceptions. There was nothing
which justified these exceptions and removing them doesn't hurt.
ByeBye CException::EX_BadModVersion
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1137 726aef4b-f618-498e-8847-2d620e286838
This hopefully avoids some ugly stuff. Namely, irssi pretending *status changed
its nick to *shell etc because they have the same ident and host and are in no
common channel.
This patch is based on a patch from SilverLeo. If this breaks it's his fault!
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1084 726aef4b-f618-498e-8847-2d620e286838