Commit Graph

39 Commits

Author SHA1 Message Date
psychon
0af674ac89 First argument to CHTTPSock::PrintHeader() should be of type off_t
Thanks to KiNgMaR


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1474 726aef4b-f618-498e-8847-2d620e286838
2009-04-02 12:54:12 +00:00
psychon
2f5a1cafc5 Switch some code to use the new return type of GetSize()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1471 726aef4b-f618-498e-8847-2d620e286838
2009-03-31 15:11:32 +00:00
sebastinas
812526278a Swap some lines in CHTTPSock::ReadLine
Copying sData and trimming it can be omitted if the function is left
because m_bGotHeader is true.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1409 726aef4b-f618-498e-8847-2d620e286838
2009-03-04 18:19:29 +00:00
psychon
a938666602 HTTPSock: Remove some code which makes no sense
Thanks to sebastinas


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1408 726aef4b-f618-498e-8847-2d620e286838
2009-03-03 17:10:52 +00:00
psychon
21120e2146 Handle newlines in CHTTPSock::GetParam() and strip them out.
There was a bug in webadmin which allowed any users to write arbitrary strings
to znc.conf by setting e.g. their quit message to:
  Some quit message
  Admin = true
  LoadModule = shell
  </User>
  ISpoofFile = /home/<user>/.ssh/authorited_keys
  ISpoofFormat = <some ssh key>
  <User a>
(The newlines must be sent as newlines to webadmin)

This commit fixes this by stripping all newlines from all the data fields
by default. Since some fields (e.g. CTCPReplies and Servers) do need newlines,
there is a new function CHTTPSock::GetRawParam() which doesn't do the stripping.

Thanks to cnu for finding and reporting this bug.
Thanks to kroimon for patch review.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1395 726aef4b-f618-498e-8847-2d620e286838
2009-02-24 16:00:11 +00:00
psychon
a7e8326300 Fix some "uninitialized variable" compiler warning
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1392 726aef4b-f618-498e-8847-2d620e286838
2009-02-23 19:24:41 +00:00
psychon
8b15351aa2 HTTPSock: Don't transfer endless static files in PrintFile()
This limits the max file size to 16 MiB and makes the read loop stop after
it has read as many bytes as GetSize() said the file is long. This fixes
an endless loop when trying to transfer endless files like /dev/zero.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1374 726aef4b-f618-498e-8847-2d620e286838
2009-02-05 17:11:45 +00:00
psychon
8177a609d2 Make webadmin's debug output for ETags more readable
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1373 726aef4b-f618-498e-8847-2d620e286838
2009-02-05 15:33:48 +00:00
psychon
35458af905 Make some functions in CHTTPSock pure virtual where it makes sense
Or do you seriously expect anyone to set up a http which always replies
with 404 File not found errors?


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1372 726aef4b-f618-498e-8847-2d620e286838
2009-02-04 16:29:06 +00:00
psychon
649dca204f HTTPSock: Use TrimLeft() instead of a combination of Left() and LeftChomp()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1364 726aef4b-f618-498e-8847-2d620e286838
2009-02-02 15:24:48 +00:00
psychon
a6995ba59a Remove that useless and more or less unused enum for open() modes
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1361 726aef4b-f618-498e-8847-2d620e286838
2009-02-02 15:03:32 +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
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
90ecce7880 Make httpsock (and thus webadmin) support client side caching of static files
If such a file is served (e.g. webadmin images) an ETag header is now generated.
When the browser needs the file again it sends the ETag back to us in an
If-None-Match header and the file isn't transfered again if the ETag still
matches. This should greatly reduce webadmin's traffic usage.

This also updates HTTPSock to sometimes generate a HTTP/1.1 reply
(ETag was added in HTTP/1.1).

This was successfully tested with Firefox 2 & 3 and IE7.
Konqueror failed badly (No If-None-Match header generated).

Thanks to flakes for having the idea, writing the patch and testing it.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1248 726aef4b-f618-498e-8847-2d620e286838
2008-10-12 15:49:03 +00:00
psychon
92a718e3a6 Use CSocket in webadmin instead of directly using Csock
This gets rid of some code duplication for managing the sockets.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1240 726aef4b-f618-498e-8847-2d620e286838
2008-10-04 20:55:50 +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
01bc68b1cb Move ChangeDir() and MakeDir() from CUtils to CDir
Those function were not modified. Only change is the name.

Those *Dir() functions really made no sense in CUtils when there is FileUtils
stuff. They really fit much better into here. I'll bet they'll make new friends
fast. I mean, why shouldn't they?
Uhm... sorry ;)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1044 726aef4b-f618-498e-8847-2d620e286838
2008-05-08 16:58:32 +00:00
psychon
5665fd872d Update to latest Csocket
This breaks (& fixes again, as far as ZNC itself is concerened) API!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1040 726aef4b-f618-498e-8847-2d620e286838
2008-05-06 14:47:13 +00:00
psychon
c64d7bc108 Force a space between if, for, while and (
This was done via:
   sed -ir 's/if(/if (/g; s/for(/for (/g; s/while(/while (/g' \
        *.h *.cpp modules/*.cpp



git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1030 726aef4b-f618-498e-8847-2d620e286838
2008-04-20 13:08:44 +00:00
psychon
1f9e4f9601 Save some space for --disable-modules by not compiling template and http socks
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@927 726aef4b-f618-498e-8847-2d620e286838
2008-01-18 22:46:40 +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
1f84cda286 Webadmin sent 'Server: ZNC ZNC 0.051', remove one 'ZNC'
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@864 726aef4b-f618-498e-8847-2d620e286838
2007-11-06 20:13:15 +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
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
a9e60b43c5 Migrated away from CString::ToString() in favor of explicit constructors
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@669 726aef4b-f618-498e-8847-2d620e286838
2006-02-25 09:43:35 +00:00
prozacx
dfd1620cd6 Changed debug print
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@620 726aef4b-f618-498e-8847-2d620e286838
2006-02-08 08:42:16 +00:00
prozacx
1838c73986 Added extra debug info
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@615 726aef4b-f618-498e-8847-2d620e286838
2006-02-08 06:09:03 +00:00
prozacx
3dc9b0a32e Added support for auto detecting content-types in PrintFile()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@613 726aef4b-f618-498e-8847-2d620e286838
2006-02-08 05:47:31 +00:00
prozacx
0917335eab Added PrintFile() and refactored some things
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@610 726aef4b-f618-498e-8847-2d620e286838
2006-02-08 03:15:29 +00:00
prozacx
ecf431f246 Added CTemplate support which included upgrading String.cpp/h and FileUtils.cpp/h and fixing some issues
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@603 726aef4b-f618-498e-8847-2d620e286838
2006-02-05 05:01:53 +00:00
prozacx
6def419579 Added HasParam()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@530 726aef4b-f618-498e-8847-2d620e286838
2005-09-24 18:06:40 +00:00
prozacx
a105770d93 Added support for custom content types
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@514 726aef4b-f618-498e-8847-2d620e286838
2005-09-20 01:57:10 +00:00
prozacx
dfbb2db170 Take advantage of Csocket changes for graceful Close()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@496 726aef4b-f618-498e-8847-2d620e286838
2005-09-15 04:14:43 +00:00
prozacx
0840525a0d Added GetParamValues() overload which returns a set instead of vector
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@457 726aef4b-f618-498e-8847-2d620e286838
2005-08-02 17:45:57 +00:00
prozacx
dc33b862a7 Init m_bDone to false, duh
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@454 726aef4b-f618-498e-8847-2d620e286838
2005-07-21 21:03:05 +00:00
prozacx
008c14e554 Added GetParamString() and m_bDone
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@452 726aef4b-f618-498e-8847-2d620e286838
2005-07-19 04:33:02 +00:00
prozacx
c0ed0b4cb5 Fixed bug in POST by keeping track of buffer in member var
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@425 726aef4b-f618-498e-8847-2d620e286838
2005-07-10 17:56:51 +00:00
prozacx
fcbd9c4ed5 HTTP Server
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@412 726aef4b-f618-498e-8847-2d620e286838
2005-07-05 09:24:21 +00:00