Commit Graph

42 Commits

Author SHA1 Message Date
Uli Schlachter
10c33112c4 Fix logging in with PASS after USER
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>
2011-08-29 13:02:55 +02:00
Kyle Fuller
ef2b2cf601 Make CClient network aware 2011-08-24 19:07:31 +01:00
psychon
b9b0fd4c87 Oh, shiny... NOT
(Yes, it's that time of the year again)

Signed-off-by: Uli Schlachter <psychon@znc.in>

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2260 726aef4b-f618-498e-8847-2d620e286838
2011-01-14 17:03:24 +00:00
psychon
3ecbf13390 Use autoheader
This commit adds a zncconfig.h to ZNC that is automatically generated by
configure. This is done because the -DPACKAGE_STRING=\"znc\ 0.097\" that
configure adds to CXXFLAGS breaks znc-buildmod.

This means that we have to include zncconfig.h as the very first header in every
C++ file that is compiled. This commit kinda cheats and instead adds this
include as the very first thing to all header files we have. This should
hopefully mean that modules don't have to include this.

Because Csocket includes defines.h too late, this commit causes znc to divert
from upstream Csocket once again. :(


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2250 726aef4b-f618-498e-8847-2d620e286838
2011-01-07 15:01:08 +00:00
psychon
9d99e4cc8d Add module calls for client CAPs
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
2010-07-07 16:01:15 +00:00
psychon
99ea9c6ff7 Implement CAP between clients and znc
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
2010-06-13 07:36:32 +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
psychon
f2d7ae1a08 Change a bunch of tabs into spaces
At the beginning of lines, one uses tabs for indenting. In the middle of the
line, you use spaces. If you want two different lines to line up with each
other, you start them with the same number of tabs and use spaces for the rest
of the indenting in the "other" line.

Really, that's how one does it!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1963 726aef4b-f618-498e-8847-2d620e286838
2010-05-01 20:15:01 +00:00
psychon
46b70f654d Move the HTTP/IRC switching to CIncomingConnection
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
2010-04-15 18:20:12 +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
b0e59f1294 Fix a crash bug with auth modules
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
2009-11-28 18:53:20 +00:00
psychon
edb6c42dd8 Remove the dedicated new-client-timeout timer
We used to start a dedicated timer for a new client socket that would make sure
the client is disconnected if it didn't successfully log in after 60 seconds.

This is now replaced by using Csocket's built-in timeout support. When a new
client connects we SetTimeout(60, 0); which means that Timeout() will be called
in 60 seconds, no matter what. The second argument is a bitmask which says on
which events the timeout should be reset (TMO_READ, TMO_WRITE, TMO_ACCEPT,
TMO_ALL).

Once the client logs in successfully, CClient::AcceptLogin() now sets back the
proper timeout (SetTimeout(240, TMO_READ);) which was set in Connected() before.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1622 726aef4b-f618-498e-8847-2d620e286838
2009-09-10 10:45:35 +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
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
309339091a Add CAuthBase::GetSocket()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1512 726aef4b-f618-498e-8847-2d620e286838
2009-05-20 09:32:28 +00:00
psychon
4e31d49209 CAuthBase: Use a Csock* instead of a CString "sRemoteIP"
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1511 726aef4b-f618-498e-8847-2d620e286838
2009-05-20 09:30:19 +00:00
psychon
cbc27f5bb9 Call OnFailedLogin() for all failed logins, not only those on the irc port
This breaks CAuthBase's API for modules that want to auth users.
Instead of overloading AcceptLogin() and RefuseLogin(), they now have to
overload AcceptedLogin() and RefusedLogin().

Modules that auth users (e.g. imapauth) still call AcceptLogin() and
RefuseLogin() which is where OnFailedLogin() gets called.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1389 726aef4b-f618-498e-8847-2d620e286838
2009-02-21 16:48:28 +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
psychon
acd854eb1c Remove virtual where it makes no sense
This commit actually saves memory, since some classes no longer contain a
pointer to their vtable!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1300 726aef4b-f618-498e-8847-2d620e286838
2008-12-22 17:22:34 +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
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
d4cd78a43b Instead of (ab)using a CClient for listening, use an own class this job
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1178 726aef4b-f618-498e-8847-2d620e286838
2008-08-29 18:51:08 +00:00
psychon
03e34ac6e6 Remove KeepNick
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1151 726aef4b-f618-498e-8847-2d620e286838
2008-07-24 11:34:11 +00:00
psychon
31feec2c9f Use CZNC::Auth() to authenticate IRC clients
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1115 726aef4b-f618-498e-8847-2d620e286838
2008-07-07 18:35:41 +00:00
psychon
5e0c652b9a Add the remote ip to the info CAuthBase got
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1112 726aef4b-f618-498e-8847-2d620e286838
2008-07-07 18:24:38 +00:00
psychon
f88c7384b6 Clean up some includes
We no longer include Csocket.h in main.h because only few files actually need
it. (Only HTTPSock.h and Timers.h)

We also clean up some includes in Timers.h. It didn't actually include
the file it needed.

Oh and this also adds a warning to main.h if PATH_MAX is undefined. If this
happens, it is most likely a bug that needs to be addressed. (some missing
includes, I'd guess)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1099 726aef4b-f618-498e-8847-2d620e286838
2008-06-21 11:20:30 +00:00
psychon
e1bf2d21ca Disconnect unauthed connections after a timeout of 60 secs
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1067 726aef4b-f618-498e-8847-2d620e286838
2008-05-24 17:09:25 +00:00
psychon
e7bb3e5daa Remove an unused var from CClient
If CClient::m_bAuthed was false, CClient::m_pUser was NULL as well and
if it was true, m_pUser wasn't NULL, too. So why not take that var for
this job?


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1003 726aef4b-f618-498e-8847-2d620e286838
2008-04-01 08:49:33 +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
f74f501d5a Handle CTCP to *status
We only answer to PING and VERSION.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@890 726aef4b-f618-498e-8847-2d620e286838
2007-12-02 09:25:19 +00:00
psychon
a09a7e79f6 Switch to the copyright headers the GPLv2 wants us to have
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@843 726aef4b-f618-498e-8847-2d620e286838
2007-09-21 18:55:33 +00:00
psychon
ac805c59a9 Fix warnings from -Woverloaded-virtual.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@816 726aef4b-f618-498e-8847-2d620e286838
2007-07-19 22:28:54 +00:00
psychon
b772e2664e Merged rev 838,888,890,894,899,900,902-904,926,934,963,984-989 from crox's branch:
- Changes to specfile
- define PATH_MAX and RTLD_LOCAL if not defines
- compile fixes
- SetFileName should not set m_iFD
- check for cygwin and do not use -fPIC
- replaced if ... elif with case in configure.in
- handle 437 reply code
- allow disabled channels
- use strerror() in CIRCSock::SockError()
- added GetUser() to CClient and CIRCSock
- added support for traffic accounting
- added names to timers


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@806 726aef4b-f618-498e-8847-2d620e286838
2007-05-17 19:09:17 +00:00
psychon
9b671ee976 merge rev 936, 939-943 from psychon branch:
- if a client connected before znc connected to irc and if it uses a wrong nick it
   wasnt informed of this -> fixed
- znc.cpp didnt work with --disable-modules
- some stuff which was already merged previously


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@800 726aef4b-f618-498e-8847-2d620e286838
2007-05-16 22:20:10 +00:00
prozacx
0a62274975 Committing patches from crox/psychon
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@790 726aef4b-f618-498e-8847-2d620e286838
2007-03-12 06:26:54 +00:00
prozacx
6dcacaa79e Added contact info
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@752 726aef4b-f618-498e-8847-2d620e286838
2006-09-13 07:39:48 +00:00
prozacx
be354f113e Added auth class
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@690 726aef4b-f618-498e-8847-2d620e286838
2006-03-16 00:23:55 +00:00
prozacx
712d40065a Renamed CUserSock to CClient
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@584 726aef4b-f618-498e-8847-2d620e286838
2005-10-15 05:11:39 +00:00