Commit Graph

106 Commits

Author SHA1 Message Date
psychon
b25e65dbb6 Add a limit of 10 unidentified connections per IP
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
2009-07-10 13:27:55 +00:00
psychon
442aee2baf Add and use CZNCSock instead of Csock everywhere
This class will be used to implement async DNS in a later commit.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1550 726aef4b-f618-498e-8847-2d620e286838
2009-06-29 11:26:19 +00:00
psychon
5678220d34 Remove some useless casts
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
2009-06-26 18:13:40 +00:00
psychon
7f7341dc2a CSocket: Close sockets which cause a EMFILE
This now closes listening sockets if we hit some fd limit like we are already
doing in CRealListener.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1544 726aef4b-f618-498e-8847-2d620e286838
2009-06-18 19:32:12 +00:00
prozacx
dd6c9a07f5 Added module hooks for when the buffer is being played back
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1494 726aef4b-f618-498e-8847-2d620e286838
2009-04-22 21:48:58 +00:00
psychon
f991274789 Fix a crash bug with recursion in module calls
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
2009-03-22 19:05:34 +00:00
psychon
27a51fcec7 Some minor stuff, again found via icc's "remarks"
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1436 726aef4b-f618-498e-8847-2d620e286838
2009-03-21 09:32:50 +00:00
psychon
bcf072e3cc Check if the version of a module matches when querying info about it
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
2009-03-10 19:15:08 +00:00
psychon
994da49638 Remove a mostly unused flag from CModInfo
Nobody cares if a module is found in ~/.znc/modules or in /usr/lib/znc/, right?


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1417 726aef4b-f618-498e-8847-2d620e286838
2009-03-09 17:21:01 +00:00
psychon
26fa234e05 Remove some completely unused code in Modules.cpp
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
2009-02-16 17:36:52 +00:00
psychon
3f00b9ef60 Just. Do. Not. Ask.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1359 726aef4b-f618-498e-8847-2d620e286838
2009-01-29 19:59:02 +00:00
psychon
ed43e95216 Change the names of all the module entry points to be more ZNC specific
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
2009-01-29 19:39:21 +00:00
psychon
235b10c200 Use that new define everywhere
Now there are no uses of DEBUG_ONLY() left :(


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1349 726aef4b-f618-498e-8847-2d620e286838
2009-01-25 16:51:54 +00:00
psychon
620c72a2ac Add a ModHandle typedef instead of using void* directly
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
2009-01-24 09:11:50 +00:00
psychon
c44d3f1751 Use RTLD_NOW instead of RTLD_LAZY when dlopen()ing modules
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
2009-01-15 18:56:36 +00:00
silverleo
45ae051e58 Move SetArgs above the OnLoad module calls so a module can reset the args.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1329 726aef4b-f618-498e-8847-2d620e286838
2009-01-12 16:15:29 +00:00
psychon
08ad0291ea Happy New Year 2009 everyone!
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1317 726aef4b-f618-498e-8847-2d620e286838
2009-01-01 12:22:21 +00:00
silverleo
d84b9c6e9e Add OnUnknownUserRaw() global module call.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1314 726aef4b-f618-498e-8847-2d620e286838
2008-12-31 12:22:38 +00:00
psychon
1312e6512b Make watch save its settings and add CModule::ClearNV()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1304 726aef4b-f618-498e-8847-2d620e286838
2008-12-26 15:12:25 +00:00
psychon
08088be7d6 Add traffic tracking support to CSocket
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
2008-12-06 19:56:38 +00:00
psychon
da4181617e Use RTLD_LOCAL instead of RTLD_GLOBAL when reading module descriptions
This might save some work for the libc and at least I can't see
how this would break anything.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1279 726aef4b-f618-498e-8847-2d620e286838
2008-12-06 14:39:48 +00:00
silverleo
9952e8d2c5 Added OnTimerAutoJoin(). Patch from Freman. Thanks :)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1272 726aef4b-f618-498e-8847-2d620e286838
2008-11-25 10:53:40 +00:00
silverleo
c71565103c Added OnIRCRegistration(). Patch from Freman. Thanks :)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1271 726aef4b-f618-498e-8847-2d620e286838
2008-11-24 17:56:34 +00:00
psychon
db21f88584 Rename OnUserAttached and OnUserDetached and add OnClientConnect
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
2008-10-29 17:26:30 +00:00
silverleo
94f6e2cf79 Change OnStatusCommand to use non-const variable like most of the EModRet modulecalls
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1262 726aef4b-f618-498e-8847-2d620e286838
2008-10-26 19:47:17 +00:00
psychon
2216c93e40 Catch 'throw UNLOAD' in the OnBoot module hook
Before this ZNC died because of an uncaught exception :(


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1249 726aef4b-f618-498e-8847-2d620e286838
2008-10-13 18:53:43 +00:00
kroimon
5237a24747 Use CString::Equals() everywhere.
* (CString::CaseCmp() == 0) became CString::Equals()
* (CString::CaseCmp() != 0) became !CString::Equals()
* replaced some occurrences of strn?casecmp

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1234 726aef4b-f618-498e-8847-2d620e286838
2008-09-30 15:15:59 +00:00
psychon
18ce52e32d Limit the maximal read buffer space that is used for every socket
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
2008-09-30 14:43:51 +00:00
psychon
3014ae5dcb Remove CSocket::m_sLabel since it isn't really used at all
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
2008-09-29 13:34:42 +00:00
psychon
fd92e65b70 Add CClient::PutStatus(const CTable&) and use it everywhere
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1222 726aef4b-f618-498e-8847-2d620e286838
2008-09-28 12:05:49 +00:00
psychon
219ae6a572 Add new module call OnMode()
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
2008-09-04 10:28:19 +00:00
psychon
0316c6a1df Add OnUserTopicRequest() for topic requests
OnUserTopic() used to try to handle this, but it really failed to...


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1185 726aef4b-f618-498e-8847-2d620e286838
2008-09-02 12:39:18 +00:00
psychon
5fa8d03d2b Handle clients in CModules the same way users are
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
2008-08-30 19:46:28 +00:00
psychon
b70a115a28 Add a new function CModule::PutModule(const CTable&)
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
2008-08-24 12:49:40 +00:00
psychon
87d062a5c5 Unify some of the preprocessor macros in Modules.cpp
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
2008-08-24 06:25:11 +00:00
psychon
b0903c0208 Handle a theoretically possible 'throw UNLOAD' in CModule::OnLoad()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1164 726aef4b-f618-498e-8847-2d620e286838
2008-08-23 20:20:36 +00:00
psychon
10210e4619 Don't throw any exceptions in CModules::LoadModule() on version mismatch
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
2008-07-17 12:01:44 +00:00
psychon
442ef47c56 Add OnUserTopic module call
Patch by SilverLeo


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1086 726aef4b-f618-498e-8847-2d620e286838
2008-06-06 14:27:57 +00:00
psychon
8e3f1ef77d Module query (like *shell) now uses the module name as prefix, not 'znc'
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
2008-06-03 12:07:49 +00:00
psychon
dde7921e6c Remove OnRehashDone and add OnPre/PostRehash
This patch is from SilverLeo.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1046 726aef4b-f618-498e-8847-2d620e286838
2008-05-09 14:48:06 +00:00
psychon
0a5d3013d2 Add OnTopic() module call
Thanks to SilverLeo, again.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1011 726aef4b-f618-498e-8847-2d620e286838
2008-04-01 09:03:17 +00:00
psychon
cbdfaf0ed3 Make CModule::DelNV() return false if it didn't remove anything
This fixes e.g. <*crypt> Target [543534532] deleted

Thanks to SilverLeo for the patch.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1006 726aef4b-f618-498e-8847-2d620e286838
2008-04-01 08:55:44 +00:00
imaginos
835e78fdec added back in global module functionality of handling config lines dynamically
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@979 726aef4b-f618-498e-8847-2d620e286838
2008-03-17 04:20:35 +00:00
psychon
cb066e2425 Add OnRehashDone() module call
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@969 726aef4b-f618-498e-8847-2d620e286838
2008-02-29 16:47:34 +00:00
psychon
f74ab87e19 And fix a shitload of trailing whitespaces and space / tab mixups in ZNC
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@959 726aef4b-f618-498e-8847-2d620e286838
2008-02-16 12:52:11 +00:00
psychon
0adf4e5af3 Remove OnConfigLine() module call
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@945 726aef4b-f618-498e-8847-2d620e286838
2008-02-07 22:25:58 +00:00
psychon
e72c445694 Clean up includes
All the headers are now self-contained (g++ Header.h -o /dev/null).

Some system headers where moved to the .cpp they are actually needed in,
some of our own headers are includes less. (Especially MD5.h)

Headers are sorted alphabetically while in e.g. FileUtils.cpp FileUtils.h
is the first file included.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@915 726aef4b-f618-498e-8847-2d620e286838
2008-01-07 21:31:16 +00:00
psychon
eeec633e30 Update copyright header for 2008
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@910 726aef4b-f618-498e-8847-2d620e286838
2008-01-07 21:13:07 +00:00
psychon
55a3fa0e05 Remove OnFinishedConfig() module call
No one used it anyway


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@909 726aef4b-f618-498e-8847-2d620e286838
2008-01-03 21:00:25 +00:00
psychon
1360effd31 This covers the code changes for the datadir move (which is now finished)
Based on darix' patch I wrote this. Modperl's changes were not tested since I
didn't find someone who could test it. Well...

Ah and btw it regenerates configure


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@902 726aef4b-f618-498e-8847-2d620e286838
2007-12-12 21:15:44 +00:00