A client doesn't necessarily have a network after logging in (e.g. could have
used an invalid network name).
This is another crash found by exoa, thanks.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Depending on which of its arguments where NULL, that macro called network / user
modules or not. While this is nice in that it avoids crashes, this behavior
actually surprised me and I'd rather have the caller explicitly say what it
wanted to do.
This macro is replaced with explicit calls to {GLOBAL,USER,NETWORKMODULECALL}.
Since there are actually module calls which do provide a CClient*, but may
happen before login (OnUnknownUserRaw() and the 3 CAP hooks), those are changed
to get the client pointer as their first argument. This should make it more
obvious that these module calls are special.
This commit should make it easier to catch bugs like the recent
OnClientDisconnected() with m_pUser == NULL.
Signed-off-by: Uli Schlachter <psychon@znc.in>
If a client disconnected before completing the authentication,
OnClientDisconnect() was called with m_pUser == NULL. This problem is new since
previously MODULECALL silently failed if it got a NULL.
Thanks to ex0a for repeatedly crashing his znc to figure this out. :-P
Signed-off-by: Uli Schlachter <psychon@znc.in>
First, we set m_sUser to the argument of USER. Later, when the PASS came in, the
username which was specified here (user/network:pass) was ignored, because
m_sUser was already set ("if (m_sUser.empty() &&" in ParseAuthLine).
The fix is to ignore if m_sUser was already set when parsing "PASS". Since this
means that the handling of PASS and USER becomes even more different, this
commit removes CClient::ParseAuthLine() again.
(The check for m_sUser.empty() can't just be dropped, because if USER comes in
after PASS, we should use the user name from PASS and ignore the USER one)
Signed-off-by: Uli Schlachter <psychon@znc.in>
This causes every piece of code which wants to use CFile or CDir to have to
include FileUtils.h. This causes quite some noise.
Signed-off-by: Uli Schlachter <psychon@znc.in>
ZNC will now send a PING if the connection was idle for 270 to 300 seconds.
After 540 seconds (that is, about 270 to 240 seconds later) the timeout is
triggered and ZNC reconnects.
These values are "inspired" by the values eggdrop uses.
The old timeouts were 180 to 210 secs for the PING and 240 secs for the timeout.
Signed-off-by: Uli Schlachter <psychon@znc.in>
We introduced a bug where sending "USER foo\r\nNICK foo\r\n" to znc would cause
an "invalid password" message even though no password was sent yet. This was
caused by a missing check.
This is easily fixed by checking whether we already received a password before
checking if the password is valid.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2117 726aef4b-f618-498e-8847-2d620e286838
"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
When we received a "PING" from a client without an argument, std::string would
throw a std::out_of_range exception which killed znc.
Thanks to Sm0ke0ut for reporting this.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2093 726aef4b-f618-498e-8847-2d620e286838
OnUnknownUserRaw() and OnClientCapRequest() were both getting a CClient* as
their first argument, but the proper way to pass a CClient* argument to a module
is via GetClient(). Since recently, all the places where this module hooks are
called do this properly, so we can remove this bogus argument.
No module that is part of znc is affected by this change.
Let's see how many external ones break. ;)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2077 726aef4b-f618-498e-8847-2d620e286838
This commit should make sure that all module calls are done through either
MODULECALL, GLOBALMODULECALL or ALLMODULECALL. Also, in the process some module
calls where ("accidentally" ;) ) fixed to set correct values for a global
module's m_pUser during a module call.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2076 726aef4b-f618-498e-8847-2d620e286838
This commit adds new module calls which make it possibly to announce new
capabilities from a module.
Thanks to DarthGandalf for the patch and for not going mad from my comments. :)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2071 726aef4b-f618-498e-8847-2d620e286838
CZNC::FindUser() does the same thing and we don't need two of these. GetUser()
was removed because FindUser() is used more than GetUser().
Thanks to Sthebig for noticing this.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2046 726aef4b-f618-498e-8847-2d620e286838
All PINGs are replied by ZNC, only PINGs from the client are forwarded.
All PONGs are blocked.
This should solve all issues with annoying PONGs showing up in clients.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2043 726aef4b-f618-498e-8847-2d620e286838
multi-prefix is just NAMESX' CAP name and userhost-in-names is just UHNAMES for
CAP. This makes it pretty easy to make them work. :)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2024 726aef4b-f618-498e-8847-2d620e286838
Right now, znc doesn't support any capabilities, but the general protocol works.
This also has the plus point that it stops direct CAP commands between the IRCd
and clients. That's a good thing because different clients might not support the
same CAPs and thus znc would have to translate between them.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2022 726aef4b-f618-498e-8847-2d620e286838
This new class waits for the first line from the client and checks if it's an
HTTP request and then passes the connection on to the irc or http code.
Before this, the IRC parser handled this as a special case which wasn't as
nice-looking as this is. :)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1925 726aef4b-f618-498e-8847-2d620e286838
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
If there is no connection to the IRC server, we can't forward a nick change
anyway, so there is no need to check for this case.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1723 726aef4b-f618-498e-8847-2d620e286838
If a module like imapauth needs some time to process a login, it's possible that
the client already disconnected by the time the lookup finished. This would then
cause a stale pointer in CAuthBase to be dereferenced.
Fix this remotely exploitable crash bug by adding a new function
CAuthBase::Invalidate(). After this was called, the CAuthBase instance doesn't
do anything at all anymore, especially not dereferencing the (possibly stale)
m_pSock pointer.
This also makes sure that one can only call AcceptLogin() or RefuseLogin() once.
Thanks to Sm0ke0ut for providing backtraces and reporting this bug.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1669 726aef4b-f618-498e-8847-2d620e286838
If this option is set to an ip address, this one is used as the local address
for DCC connections. This can e.g. be used to "fix" DCC bouncing with ipv6
connections. Without it, this just more or less fails badly.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1647 726aef4b-f618-498e-8847-2d620e286838