Commit Graph

58 Commits

Author SHA1 Message Date
psychon
5e070e7881 Turn CChan::m_msNicks into a map<CString, CNick>
Saving a pointer in a map seems like a bad idea and means we have to delete all
the contained stuff by hand when the channel is destroyed. This requires us to
loop through the channel which is slow. A map is meant as a container, so use it
as one and directly save the stuff we want it to save in there.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2175 726aef4b-f618-498e-8847-2d620e286838
2010-11-06 19:41:40 +00:00
psychon
cce5824439 Add a list of znc features to /znc version
/znc version now also tells you something like this:

 <*status> IPv6: yes, SSL: yes, c-ares: yes


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2173 726aef4b-f618-498e-8847-2d620e286838
2010-11-06 16:04:51 +00:00
psychon
b359f96886 Avoid a possibly expensive FindSockByName() for finding IRC socks
While a user is connecting to an IRC server, the CUser instance didn't know
about the CIRCSock instance (due to historic reasons). This meant that we needed
to use FindSockByName() when we had to check if there is any CIRCSock associated
with this user. However, this is a bad idea since FindSockByName() is O(n) on
the number of sockets that the socket manager is managing.

Instead, we now already set CUser::m_pIRCSock when the CIRCSock is created so
that checking for an irc socket becomes O(1).

This was inspired by the results of profiling a znc instance with 900 users.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2171 726aef4b-f618-498e-8847-2d620e286838
2010-11-06 15:21:59 +00:00
psychon
341263f9ec Rename "vhost" to "bindhost"
"virtual host" seems to be confusing to users since they wonder why
i.am.superman doesn't work. Let's rename this to "bindhost" and perhaps it
becomes clearer what this setting does.

Thanks to SilverLeo!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2113 726aef4b-f618-498e-8847-2d620e286838
2010-08-30 08:58:29 +00:00
psychon
2becac12ba Add an optional argument to /znc jump
If you have 10 servers in your server list and you want to directly jump to e.g.
irc.foo.bar, you can now do "/znc jump irc.foo.bar".

Thanks to PsWii60 for constantly bugging me for this.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2109 726aef4b-f618-498e-8847-2d620e286838
2010-08-22 12:09:47 +00:00
psychon
e62ca4112d Add new global setting MaxBufferSize
Previously, /znc setbuffer had a hardcoded limit of 500, other ways of setting
the buffer size didn't have any limit built-in.

This patch makes that limit configurable and makes sure the various places
honour it.

Thanks to DarthGandalf for the idea with the bForce argument, I were too
small-minded to come up with it myself. :(


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2020 726aef4b-f618-498e-8847-2d620e286838
2010-06-12 20:20:33 +00:00
cflakes
f68b10e0d9 Fixed /znc addport arguments in /znc help.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1992 726aef4b-f618-498e-8847-2d620e286838
2010-05-16 10:20:49 +00:00
cflakes
ee692c88ed Improved looks of /znc listports output.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1991 726aef4b-f618-498e-8847-2d620e286838
2010-05-15 22:37:39 +00:00
cflakes
bbca3e3254 Add "setting"/argument for adding web and IRC only ports via /znc addport.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1990 726aef4b-f618-498e-8847-2d620e286838
2010-05-15 22:33:19 +00:00
cflakes
fc62aaab4a Moved port/listener modifying *status commands to their own
method (UserPortCommand). This removes some previous dupe
code (HI BRIAN) and prepares for web only/IRC only port
support.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1976 726aef4b-f618-498e-8847-2d620e286838
2010-05-09 20:22:23 +00:00
cflakes
16ad0950ea Add support for an optional user-specified quit message to the DISCONNECT command that would be used instead of the message specified in the config file.
Patch by reed! Thanks!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1926 726aef4b-f618-498e-8847-2d620e286838
2010-04-23 09:09:07 +00:00
psychon
eb44919005 Move CListener and CRealListener into their own files
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1924 726aef4b-f618-498e-8847-2d620e286838
2010-04-15 16:52:30 +00:00
cflakes
4bc058109b Minor "all vs both" addport help fix.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1913 726aef4b-f618-498e-8847-2d620e286838
2010-04-14 19:04:21 +00:00
psychon
2443c22a83 Add {List,Add,Del}Port to *status
Patch by BrianC, thanks a lot. (With some minor modifications)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1899 726aef4b-f618-498e-8847-2d620e286838
2010-04-08 16:04:56 +00:00
psychon
f72e2f8abd 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
2010-02-25 12:29:40 +00:00
psychon
1d88f564dc Fix a bunch of style suggestions from cppcheck[1]
Thanks to DarthGandalf for this patch. You must be bored. :P

[1] cppcheck.sf.net


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1776 726aef4b-f618-498e-8847-2d620e286838
2010-02-19 16:21:07 +00:00
cflakes
c144870459 Added a missing error message to UpdateMod plus cleaned up two more lines of /znc help.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1772 726aef4b-f618-498e-8847-2d620e286838
2010-02-18 14:15:39 +00:00
cflakes
3b8671d0d1 Cleanup for "/znc help".
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1771 726aef4b-f618-498e-8847-2d620e286838
2010-02-18 14:03:07 +00:00
cflakes
94c1569d4e Added an optional [User] argument to /znc ListChans for admin users.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1770 726aef4b-f618-498e-8847-2d620e286838
2010-02-18 13:50:48 +00:00
cflakes
007503dba9 Added a "number of channels" column to the LISTUSERS output. The number also includes disabled channels.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1769 726aef4b-f618-498e-8847-2d620e286838
2010-02-18 13:42:32 +00:00
psychon
291ad47907 Use empty() instead of size() == 0 where appropriate
This was found by cppcheck (cppcheck.sf.net).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1761 726aef4b-f618-498e-8847-2d620e286838
2010-02-18 12:39:41 +00:00
cflakes
0ff25fc532 Reloadmod command: Moved check for empty module name argument to a place where it actually works.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1749 726aef4b-f618-498e-8847-2d620e286838
2010-02-08 22:55:26 +00:00
cflakes
2594111e75 Added a summary line to LISTCHANS output. Suggested by bigpresh, basic patch by Efreak. Thanks!
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1729 726aef4b-f618-498e-8847-2d620e286838
2010-02-02 17:36:18 +00:00
psychon
f99e5190cd CClient: Use CUser's IRC Socket pointer
CUser already saves the pointer to the IRC socket, so why would CClient's have
to do the same?


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1725 726aef4b-f618-498e-8847-2d620e286838
2010-01-28 19:44:37 +00:00
psychon
b50d944bb9 Use GetIRCSock() instead of m_pIRCSock directly
This patch makes the code in CClient use a wrapper function for accessing the
IRC socket. Wait and see for why I do this. ;)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1724 726aef4b-f618-498e-8847-2d620e286838
2010-01-28 19:40:38 +00:00
silverleo
07d7477dec It's 2010, where's my hoverboard?
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1693 726aef4b-f618-498e-8847-2d620e286838
2010-01-06 09:37:05 +00:00
psychon
24978bd0eb Write the config file on restart and shutdown
ZNC now writes its config file just before it shuts down. If this fails it
aborts the shutdown. One can then either fix whatever went wrong or force a
shutdown.

This also cleans the code up a little by unifying shutdown and restart.

Patch by flakes, thanks!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1641 726aef4b-f618-498e-8847-2d620e286838
2009-10-04 17:15:05 +00:00
psychon
4d35bd482e delserver: Allow selecting the server more exactly
Before this you could only give the hostname of a server and delserver would
delete the first server with that hostname. Now you can also specify port and
password to select the server to remove more exactly.

One can't specify the ssl flag for delserver since this would be a little ugly,
but since you can't do ssl/plain-text on the same port anyway this shouldn't be
a big problem.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1640 726aef4b-f618-498e-8847-2d620e286838
2009-09-26 18:41:24 +00:00
psychon
ab71a24bba Micro-Optimizations
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1639 726aef4b-f618-498e-8847-2d620e286838
2009-09-26 15:04:08 +00:00
psychon
411373307f Fix unloading of /bin/rm'd modules
The old code first tried to dlopen() the module again to find out if it's a
global or a user module. This could have lots of weird effects.

Now we just unload the user module and if that fails retry with the global
module (if the user got the appropriate privileges).

This removes and fixes the #warning added in the last commit.

P.S.: Oh and this is less LOCs now!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1597 726aef4b-f618-498e-8847-2d620e286838
2009-08-10 19:17:33 +00:00
psychon
f680f242ff Improve the error message from /msg *status loadmod
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
2009-08-10 18:58:55 +00:00
psychon
c7583c4946 Fix a low impact directory traversal bug
A common pattern for checking directories in ZNC is the following:

	sAbsolutePath = CDir::ChangeDir(sAllowedPath, sFile);
	if (sAbsolutePath.Left(sAllowedPath.length()) != sAllowedPath)
		Error;

But there is a problem: If sAllowedPath doesn't end with a slash, we are
vulnerable to an attack. If e.g. sAllowedPath = "/foo/bar", then
sFile = "../bartender" would result in sAbsolutePath = "/foo/bartender". Since
this path does begin with sAllowedPath, the code allowed it.

There shouldn't be any places where this can be exploited currently, but it is
still a security bug (path traversal).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1569 726aef4b-f618-498e-8847-2d620e286838
2009-07-21 18:36:33 +00:00
psychon
b03bc3cac9 Make sure OnStatusCommand() is always called when it should be
We didn't call the module hook for commands executed via /znc instead of /msg *status.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1562 726aef4b-f618-498e-8847-2d620e286838
2009-07-11 18:04:25 +00:00
psychon
aae356c8d5 Let everyone use /msg *status uptime, not only admins
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1526 726aef4b-f618-498e-8847-2d620e286838
2009-05-27 13:28:58 +00:00
psychon
85dce87d6a Traffic API breakage again
The last commit broke the order in which the traffic stats used to be displayed
and it turns out that KiNgMaR cannot live with that, so now we are back to the
old order.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1523 726aef4b-f618-498e-8847-2d620e286838
2009-05-27 10:49:48 +00:00
psychon
f36ad9e6e7 Change the API for getting traffic stats
We now have a central function CZNC::GetTrafficStats() which does all the ugly
stuff and just returns the data which the caller can then display. We now also
include all unknown sockets (e.g. imapauth or webadmin sockets) in the traffic
stats in the "<ZNC>" section.

The only downside to all this gloriousness is that this breaks the ordering of
/msg *status traffic which is now sorted alphabetically which means that <ZNC>
<Users> and <Total> aren't anymore in the places in which they used to be.
I hope one can live with that...


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1521 726aef4b-f618-498e-8847-2d620e286838
2009-05-26 18:38:58 +00:00
prozacx
7140873bd8 Auto-detect globalness in the re/un/loadmod commands using GetModInfo()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1505 726aef4b-f618-498e-8847-2d620e286838
2009-05-10 09:50:37 +00:00
prozacx
924d5717cd Removed repeat sentence since sModRet already says it was unable to load
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1493 726aef4b-f618-498e-8847-2d620e286838
2009-04-22 05:10:36 +00:00
psychon
48cb1b6cc6 Remove a pretty much useless usleep() on shutdown
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1429 726aef4b-f618-498e-8847-2d620e286838
2009-03-15 07:44:07 +00:00
psychon
c30b9a240f Meh. Today is not a good day -.-
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1419 726aef4b-f618-498e-8847-2d620e286838
2009-03-09 17:42:12 +00:00
psychon
c3e4a7a1e7 Add /msg *status UpdateMod[ule] which reloads an user module on all users
This command allows admins to really reload a module when they have updated it.
Because the dynamic linker does not really reload a shared object until all
handles to this object where dlclose()'d, this new command is necessary.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1418 726aef4b-f618-498e-8847-2d620e286838
2009-03-09 17:37:35 +00:00
psychon
efcbf7884f Always allow /msg *status setbuffer <chan>, even if we are not in <chan>
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1323 726aef4b-f618-498e-8847-2d620e286838
2009-01-07 17:38:49 +00:00
psychon
607a7f1c16 Get rid of most strtoul() and atoi() calls and use CString's features instead
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1320 726aef4b-f618-498e-8847-2d620e286838
2009-01-04 10:48:02 +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
fdb451a908 Show arguments used to load the module instead of the description in listmods.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1310 726aef4b-f618-498e-8847-2d620e286838
2008-12-29 18:46:39 +00:00
silverleo
05b259baef Append an * to the current server in *status listservers
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1308 726aef4b-f618-498e-8847-2d620e286838
2008-12-29 18:11:17 +00:00
psychon
7ba58aba72 Make CChan smaller
This is mostly done by removing unused members, but there is also removes a
cache which saved how many opped, voiced etc users are on a channel.
This shouldn't result in a big slowdown, since this data is only ever used
for /msg *status listchans.
Also, this replaces the API to access this data with a version which should
be faster especially for big channels.

On amd64 the size of CChan was 600 bytes before and is 400 bytes now.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1301 726aef4b-f618-498e-8847-2d620e286838
2008-12-23 10:07:54 +00:00
psychon
baab007f2b Allow adding a server multiple times if a different port or pass is used
This also moves the check for multiple servers
from CClient to CUser::AddServer().

The idea for this is from cnu, thanks.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1295 726aef4b-f618-498e-8847-2d620e286838
2008-12-20 19:59:36 +00:00
psychon
ce31b29b68 Some changes to the vhost interface from *status
This adds AddVHost, RemVHost and ListVHosts.
If this vhost list (which is the same webadmin uses for displaying drop-down
lists) is none-empty, then users can only set one of these vhosts via SetVHost.
If the list is empty, everything is allowed.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1256 726aef4b-f618-498e-8847-2d620e286838
2008-10-20 13:00:54 +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