Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0895438900 | ||
|
|
ad99033ae4 | ||
|
|
757d341d96 | ||
|
|
b92e2fc457 | ||
|
|
a30eb425e3 | ||
|
|
bc8c3ff399 | ||
|
|
90ee7e01ca | ||
|
|
dde4e9adcc | ||
|
|
99488cbd5e | ||
|
|
fffdc76681 | ||
|
|
d2f2750a37 | ||
|
|
ddb002d57e | ||
|
|
270af08171 | ||
|
|
3d9a64d54e | ||
|
|
9f0c8f18fb | ||
|
|
e61424a7bf | ||
|
|
4680546c65 | ||
|
|
84ff99013a | ||
|
|
4ecb6d1a3d | ||
|
|
4ac03908fc | ||
|
|
722a7d2142 | ||
|
|
d3b099140f | ||
|
|
f8ad0dced3 | ||
|
|
ecbcc332cc | ||
|
|
e820fecf53 | ||
|
|
ff95117d9d | ||
|
|
70ce1cda1f | ||
|
|
274d7730ca | ||
|
|
2da1378f53 | ||
|
|
1bbf32f04c | ||
|
|
28b4477f48 | ||
|
|
5f8ee4fae3 | ||
|
|
3e91392c8a | ||
|
|
6afa56ba09 | ||
|
|
f8d43bd423 | ||
|
|
b7b4d08758 | ||
|
|
7d7958b0d7 | ||
|
|
98ffd0a3fe | ||
|
|
d090c02476 | ||
|
|
a746b9d0b2 | ||
|
|
56a9766529 | ||
|
|
1abc300112 |
No files matched your search
@@ -3,7 +3,10 @@
|
|||||||
|
|
||||||
From versions 0-1.1, Steven Young was the primary maintainer.
|
From versions 0-1.1, Steven Young was the primary maintainer.
|
||||||
From 1.2 to 1.3.0, Robert James Kaes was the primary maintainer.
|
From 1.2 to 1.3.0, Robert James Kaes was the primary maintainer.
|
||||||
As of 1.3.1, Steven Young will once again be the primary maintainer.
|
As of 1.3.1, Steven Young was once again be the primary maintainer.
|
||||||
|
|
||||||
|
But, Robert James Kaes was again the maintainer starting with 1.4.0.
|
||||||
|
Place your bets as to when the maintainer will change again. :) Kidding!
|
||||||
|
|
||||||
Please see the ChangeLog for futher details as to who did what. :)
|
Please see the ChangeLog for futher details as to who did what. :)
|
||||||
|
|
||||||
@@ -1,5 +1,55 @@
|
|||||||
|
2001-11-03 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/buffer.c (remove_from_buffer): This function is never
|
||||||
|
called with an empty buffer, so removed some inaccurate code which
|
||||||
|
would have removed an invalid line from the buffer if it was
|
||||||
|
empty. What was I thinking when I wrote that? Good thing is was
|
||||||
|
never called.
|
||||||
|
(add_to_buffer): Add a bit of a sanity check to make sure the
|
||||||
|
buffer structure hasn't been messed up some how.
|
||||||
|
|
||||||
|
2001-11-02 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/acl.c (insert_acl): Tightened the check regarding whether an
|
||||||
|
ACL is a string or a numeric address.
|
||||||
|
|
||||||
|
2001-10-25 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* Moved all the system header included into the tinyproxy.h header
|
||||||
|
and changed all the other files to include it. This should
|
||||||
|
centralise the header dependency issue into one file.
|
||||||
|
|
||||||
|
* src/conns.c: Brought back the conns.{c,h} files which contain
|
||||||
|
the connection structure definition plus the creation/destruction
|
||||||
|
routines.
|
||||||
|
|
||||||
|
* src/reqs.c (process_client_headers): Selectively send headers
|
||||||
|
based on whether we're using an upstream with a CONNECT
|
||||||
|
request. The short answer: all methods work correctly with
|
||||||
|
Upstream proxying and normal proxying.
|
||||||
|
|
||||||
|
* src/tinyproxy.h: Added a upstream flag to the conn_s structure
|
||||||
|
so we can figure out when to send headers and when not to send
|
||||||
|
headers. This is extremely important when trying to do upstream
|
||||||
|
proxying of the CONNECT method.
|
||||||
|
|
||||||
|
* src/reqs.c (relay_connection): Empty the contents of both
|
||||||
|
buffers when either socket is closed. This is more in line with
|
||||||
|
what a tunnel should do. Since either end could close with
|
||||||
|
information still in the buffers.
|
||||||
|
(connect_to_upstream): Cleaned up the code to re-use the
|
||||||
|
establish_http_connection() function.
|
||||||
|
|
||||||
|
* src/buffer.c (readbuff): Changed the memory allocation to 2K
|
||||||
|
from 48K since an Ethernet connection is usually around 1400
|
||||||
|
bytes. There's little point in allocating a huge amount of memory,
|
||||||
|
only to shrink the memory map in the next breath.
|
||||||
|
|
||||||
2001-10-22 Robert James Kaes <rjkaes@flarenet.com>
|
2001-10-22 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/sock.c (getpeer_string): Added logging in case the
|
||||||
|
gethostbyaddr() function fails.
|
||||||
|
|
||||||
* src/reqs.c (free_request_struct): Added a test to return if the
|
* src/reqs.c (free_request_struct): Added a test to return if the
|
||||||
pointer is NULL.
|
pointer is NULL.
|
||||||
(handle_connection): Cleaned up the code to better handle the
|
(handle_connection): Cleaned up the code to better handle the
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
EXTRA_DIST = configure acconfig.h aclocal.m4 acinclude.m4
|
EXTRA_DIST = TODO
|
||||||
SUBDIRS = src doc
|
SUBDIRS = src doc
|
||||||
@@ -1,26 +1,35 @@
|
|||||||
Tuesday, September 4, 2001
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
I finally fixed a problem with the anonymous header code. The searches
|
NEWS
|
||||||
are now all case insensitive. This fixes a problem where the spelling
|
====
|
||||||
of the HTTP headers could be different. It also helps with various
|
|
||||||
spellings of domain names. There is also a security fix for a format
|
|
||||||
string problem with the syslog feature. This problem doesn't affect
|
|
||||||
you if you use the log file instead.
|
|
||||||
|
|
||||||
-- Robert
|
There are a few problems with this version of tinyproxy, but I'm hoping
|
||||||
|
the benefits outweigh the negative. For some reason tinyproxy is not
|
||||||
|
able to handle requests to *.x10.com sites. (As someone mentioned: "maybe
|
||||||
|
this is a feature?" :) There also seem to be a few other random sites
|
||||||
|
where tinyproxy is not communicating with the server correctly. If you
|
||||||
|
find any such sites, let me know so I can add it to the list of domains
|
||||||
|
where tinyproxy is failing. I'll need this information for the regression
|
||||||
|
tests I plan on performing on the next release.
|
||||||
|
|
||||||
|
As for the next release (1.5.0), I will not be adding new features.
|
||||||
|
tinyproxy doesn't currently conform correctly to either the HTTP/1.0
|
||||||
|
or the HTTP/1.1 standards. The goal of the 1.5 release therefore is
|
||||||
|
to achieve standards compliance with at least HTTP/1.0. If you have
|
||||||
|
looked at the tinyproxy code you will have noticed that all the real
|
||||||
|
work of the proxy is performed in the reqs.c file. Therefore, other
|
||||||
|
than bug fixes in the other files, only reqs.c should be changed in
|
||||||
|
the 1.5.0 release. Basically, I'm hoping to just gut and replace the
|
||||||
|
reqs.c file with a standards compliant version and release a new version.
|
||||||
|
|
||||||
Thursday, August 30, 2001
|
Depending on my schedule I should have the new version ready for
|
||||||
-------------------------
|
pre-testing sometime next week. If you have any suggestions for improving
|
||||||
|
tinyproxy please let me know, but I will not be incorporating them until
|
||||||
|
1.6 (which _hopefully_ should come out fairly quickly after 1.5 has
|
||||||
|
stabilised.)
|
||||||
|
|
||||||
Maybe I just shouldn't be working on the code base this week. The
|
"Thank you" go out to all who have helped find bugs in the 1.4.3
|
||||||
memory fix I added in the last release contained a serious bug which
|
candidates. You know who you are, and if you don't look in the ChangeLog
|
||||||
would cause a segmentation fault. I actually fixed this by removing
|
for your name. :)
|
||||||
the code I added and just fixing the problem in ternary_insert()
|
|
||||||
instead. I don't know why I didn't do this in the first place. I also
|
|
||||||
removed the xstrstr() function since strstr() will do what tinyproxy
|
|
||||||
needs. Removing code is _always_ a good idea. Less code, less chance
|
|
||||||
of bugs.
|
|
||||||
|
|
||||||
-- Robert
|
Robert James Kaes
|
||||||
|
November 21, 2001
|
||||||
@@ -19,9 +19,14 @@
|
|||||||
------------
|
------------
|
||||||
|
|
||||||
To install this package under a Unix derivative, read the INSTALL
|
To install this package under a Unix derivative, read the INSTALL
|
||||||
file. tinyproxy uses a standard GNU configure script. There are
|
file. tinyproxy uses a standard GNU configure script (basically you
|
||||||
additional command line arguments you can supply to configure. They
|
should be able to do:
|
||||||
include:
|
|
||||||
|
./configure ; make ; make install
|
||||||
|
|
||||||
|
in the top level directory to compile and install tinyproxy). There
|
||||||
|
are additional command line arguments you can supply to configure.
|
||||||
|
They include:
|
||||||
|
|
||||||
--enable-debug If you would like to turn on full
|
--enable-debug If you would like to turn on full
|
||||||
debugging support
|
debugging support
|
||||||
@@ -35,6 +40,10 @@
|
|||||||
--enable-tunnel Provides the option of having
|
--enable-tunnel Provides the option of having
|
||||||
tinyproxy act as TCP tunnel, rather
|
tinyproxy act as TCP tunnel, rather
|
||||||
than a HTTP proxy.
|
than a HTTP proxy.
|
||||||
|
--enable-upstream Enable support for proxying connections
|
||||||
|
through another proxy server.
|
||||||
|
--enable-static Compile a static version of tinyproxy
|
||||||
|
|
||||||
|
|
||||||
Options for file locations etc.
|
Options for file locations etc.
|
||||||
--with-stathost=HOST Set the default name of the stats host
|
--with-stathost=HOST Set the default name of the stats host
|
||||||
@@ -46,28 +55,38 @@
|
|||||||
directory. This will send an email to the authors reporting your
|
directory. This will send an email to the authors reporting your
|
||||||
version, and a few bits of information concerning the memory usage of
|
version, and a few bits of information concerning the memory usage of
|
||||||
tinyproxy. Alternatively, you could just send an email stating the
|
tinyproxy. Alternatively, you could just send an email stating the
|
||||||
version. Which ever you prefer.
|
version, whichever you prefer.
|
||||||
|
|
||||||
|
|
||||||
SUPPORT
|
SUPPORT
|
||||||
-------
|
-------
|
||||||
|
|
||||||
If you are having problems with tinyproxy, please report the problem
|
If you are having problems with tinyproxy, please report the problem
|
||||||
to:
|
to either:
|
||||||
|
|
||||||
Robert James Kaes <rjkaes@users.sourceforge.net>
|
Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
Steven Young <sdyoung@users.sourceforge.net>
|
Steven Young <sdyoung@users.sourceforge.net>
|
||||||
|
|
||||||
|
You may also wish to subscribe to the tinyproxy-user mailing list. To
|
||||||
|
do so please visit:
|
||||||
|
|
||||||
|
http://lists.sourceforge.net/lists/listinfo/tinyproxy-users
|
||||||
|
|
||||||
|
for more information on how to subscribe and post messages to the
|
||||||
|
list.
|
||||||
|
|
||||||
Please recompile tinyproxy with full debug support (--enable-debug)
|
Please recompile tinyproxy with full debug support (--enable-debug)
|
||||||
and include a copy of the log file, and any assert errors reported by
|
and include a copy of the log file, and any assert errors reported by
|
||||||
tinyproxy. Also, if you feel up to it, try running tinyproxy under
|
tinyproxy. Note that tinyproxy will output memory statistics to
|
||||||
your debugger and report the error your received and a context
|
standard error if compiled with debugging support so you might want
|
||||||
listing of the location. Under gdb you would run tinyproxy like so:
|
to redirect the output to a file for later examination. Also, if you
|
||||||
|
feel up to it, try running tinyproxy under your debugger and report
|
||||||
|
the error your received and a context listing of the location. Under
|
||||||
|
gdb you would run tinyproxy like so:
|
||||||
|
|
||||||
gdb tinyproxy
|
gdb tinyproxy
|
||||||
|
|
||||||
(gdb) set args -c location_of_tinyproxy_conf -d
|
(gdb) run -c location_of_tinyproxy_conf -d 2>/dev/null
|
||||||
(gdb) run
|
|
||||||
|
|
||||||
Now access the port tinyproxy is on until you receive a break in the
|
Now access the port tinyproxy is on until you receive a break in the
|
||||||
gdb. You can now type:
|
gdb. You can now type:
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
Tinyproxy wouldn't be possible in its current form without the help of
|
|
||||||
the following people. Thanks a lot, guys (sorted in no particular
|
|
||||||
order). Note that in the case of entries listed under 'numerous others',
|
|
||||||
only the first person to report it is listed.
|
|
||||||
|
|
||||||
|
|
||||||
Steven Young - Wrote version 1.0 - 1.1
|
|
||||||
Robert James Kaes - Wrote versions from 1.2 to 1.3 and
|
|
||||||
autoconf enabled the source tree and
|
|
||||||
well just look at the ChangeLog for all
|
|
||||||
the rest. :)
|
|
||||||
Albert Ragnarsson - Made an RPM out of the 1.0d .tar.gz archive.
|
|
||||||
Alan W Black - Misc. bug reports and fixes.
|
|
||||||
Ed Boraas - Various suggestions, helped beta test 1.0d.
|
|
||||||
Abhijit Menon-Sen - Beta tested 1.1, numerous bugs fixed
|
|
||||||
and features improved. Also helped
|
|
||||||
establish world peace and eliminate
|
|
||||||
hunger and poverty. Generally
|
|
||||||
credited with the singlehanded
|
|
||||||
abolition of all crime and dishonesty.
|
|
||||||
Jay Kominek - Made the 1.1 DEB.
|
|
||||||
Eran Tromer - Provided webspace at attacca.com.
|
|
||||||
Bruno Viaris - Found and provided initial fix for
|
|
||||||
bug in the clientreq() routine when
|
|
||||||
dealing with broken requests from clients.
|
|
||||||
Alexander Loehr - Found and provided fix for a bug in
|
|
||||||
the listen_sock routine.
|
|
||||||
Bob Grabau - Added additional logging of URLs to
|
|
||||||
incoming connections.
|
|
||||||
Mitsuru Yoshida - Made the FreeBSD port
|
|
||||||
Ian Holsman - Suggested the selective listening option
|
|
||||||
Peter Meerwald - Portability suggests and improvements
|
|
||||||
Shaun Johnson - Fixed a problem with compiling with
|
|
||||||
syslog enabled on a SunOS box. Should
|
|
||||||
help other systems too.
|
|
||||||
Timothy E. Newsome - SOCKS firewall enabled tinyproxy
|
|
||||||
George Talusan - Bug testing
|
|
||||||
Chris Lightfoot - Provided patches to give tinyproxy adns
|
|
||||||
support.
|
|
||||||
Michael Pearson - Reported connptr bug with patch.
|
|
||||||
Raja Subramanian - Reported fd leak bug, with patch.
|
|
||||||
J.D. Bronson - Helped make version 1.4.0 release ready
|
|
||||||
Hans-Georg Bork - Fixed a problem with the thread_main()
|
|
||||||
function and added the LOG_CONN log level.
|
|
||||||
numerous others - Reported null requests bug.
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
TODO List
|
||||||
|
---------
|
||||||
|
|
||||||
|
The following are features that I would like to add to tinyproxy in the
|
||||||
|
future. Where possible, I've listed the person who suggested it. This
|
||||||
|
list is in no particular order. And hey, if you want to implement one of
|
||||||
|
these, or another idea you have, go right ahead. Just mail me the diff
|
||||||
|
against the current tree and I'll integrate it if possible.
|
||||||
|
|
||||||
|
[ Actually, the ordering has become kind of important as of
|
||||||
|
late. Basically, I'm adding new ideas to the bottom of the list
|
||||||
|
as I go. ]
|
||||||
|
|
||||||
|
* Include hooks so other types of proxies can be modularly added to
|
||||||
|
the source tree. Then people can simply choose which types of
|
||||||
|
proxies (ftp, www, etc) they'd like enabled in tinyproxy.h
|
||||||
|
Suggested: Tarun Tuli.
|
||||||
|
|
||||||
|
* Find a more elegant solution to embedding HTML documents in the
|
||||||
|
source than the current method. (see httperr() and showstats() for
|
||||||
|
examples of how it's done right now).
|
||||||
|
|
||||||
|
* Include a function to rewrite the incoming requests. Should not be
|
||||||
|
much of a problem. Just need to modify the process_method() code
|
||||||
|
to look up the URL and rewrite it. If we want to go really fancy
|
||||||
|
with RegEx mapping this could get ugly. :)
|
||||||
|
|
||||||
|
* Have the ability to send the data from the connections through an
|
||||||
|
external filtering program. I kind of like this idea, but I don't
|
||||||
|
really have a good way of doing it yet.
|
||||||
|
Suggested: Ed Avis
|
||||||
|
|
||||||
|
* Include the ability to rewrite both incoming and outgoing headers.
|
||||||
|
|
||||||
|
* Enable an option for chroot() jailing tinyproxy.
|
||||||
|
|
||||||
|
* Add an option which allows the blocking of connections to certain
|
||||||
|
ports (like 25, 110, etc.) that might be used for "bad" things. :)
|
||||||
|
|
||||||
|
* Come up with a more consistent (and elegant) way of logging errors
|
||||||
|
for the administrators. Right now it's more a hodge-podge
|
||||||
|
collections of error messages without a _real_ standard. I would
|
||||||
|
prefer a more uniform look.
|
||||||
+3
-2
@@ -1,4 +1,4 @@
|
|||||||
dnl $Id: configure.in,v 1.32 2001-10-22 21:30:18 rjkaes Exp $
|
dnl $Id: configure.in,v 1.35 2001-11-21 19:35:51 rjkaes Exp $
|
||||||
|
|
||||||
dnl Devlopers, please strive to achieve this order:
|
dnl Devlopers, please strive to achieve this order:
|
||||||
dnl
|
dnl
|
||||||
@@ -19,7 +19,7 @@ AC_INIT()
|
|||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
AC_DEFINE_UNQUOTED(TARGET_SYSTEM, "$target")
|
AC_DEFINE_UNQUOTED(TARGET_SYSTEM, "$target")
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE(tinyproxy,1.4.3pre6)
|
AM_INIT_AUTOMAKE(tinyproxy,1.4.3)
|
||||||
AM_CONFIG_HEADER(config.h)
|
AM_CONFIG_HEADER(config.h)
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
@@ -253,6 +253,7 @@ CFLAGS="-O2 $CFLAGS"
|
|||||||
if test "$enable_debug" = "yes" ; then
|
if test "$enable_debug" = "yes" ; then
|
||||||
dnl Add the warnings if we have the GCC compiler
|
dnl Add the warnings if we have the GCC compiler
|
||||||
if test "$ac_cv_prog_gcc" = "yes" ; then
|
if test "$ac_cv_prog_gcc" = "yes" ; then
|
||||||
|
CFLAGS="-pg -fprofile-arcs $CFLAGS"
|
||||||
CFLAGS="-Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes $CFLAGS"
|
CFLAGS="-Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes $CFLAGS"
|
||||||
CFLAGS="-Wmissing-prototypes -Wmissing-declarations $CFLAGS"
|
CFLAGS="-Wmissing-prototypes -Wmissing-declarations $CFLAGS"
|
||||||
CFLAGS="-Wpointer-arith -Waggregate-return -Wnested-externs $CFLAGS"
|
CFLAGS="-Wpointer-arith -Waggregate-return -Wnested-externs $CFLAGS"
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
EXTRA_DIST = tinyproxy.8 tinyproxy.conf HTTP_ERROR_CODES RFC_INFO TODO report.sh
|
EXTRA_DIST = tinyproxy.8 tinyproxy.conf HTTP_ERROR_CODES RFC_INFO report.sh
|
||||||
man_MANS = tinyproxy.8
|
man_MANS = tinyproxy.8
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
The following are some features that I'd like to add to tinyproxy in the
|
|
||||||
future. Where possible, I've listed the person who suggested it. This
|
|
||||||
list is in no particular order. And hey, if you want to implement one of
|
|
||||||
these, or another idea you have, go right ahead. Just mail me the diff
|
|
||||||
against the current tree and I'll integrate it if possible.
|
|
||||||
|
|
||||||
- Include hooks so other types of proxies can be modularly added to
|
|
||||||
the source tree. Then people can simply choose which types of
|
|
||||||
proxies (ftp, www, etc) they'd like enabled in tinyproxy.h
|
|
||||||
Suggested: Tarun Tuli.
|
|
||||||
- Find a more elegant solution to embedding HTML documents in the
|
|
||||||
source than the current method. (see httperr() and showstats() for
|
|
||||||
examples of how it's done right now).
|
|
||||||
- Include a function to rewrite the incoming requests. Should not be
|
|
||||||
much of a problem. Just need to modify the process_method() code
|
|
||||||
to look up the URL and rewrite it. If we want to go really fancy
|
|
||||||
with RegEx mapping this could get ugly. :)
|
|
||||||
- Have the ability to send the data from the connections through an
|
|
||||||
external filtering program. I kind of like this idea, but I don't
|
|
||||||
really have a good way of doing it yet.
|
|
||||||
Suggested: Ed Avis
|
|
||||||
- Include the ability to rewrite both incoming and outgoing headers.
|
|
||||||
- Enable an option for chroot() jailing tinyproxy.
|
|
||||||
- Add an option which allows the blocking of connections certain ports
|
|
||||||
(like 25, 110, etc.) that might be used for "bad" things. :)
|
|
||||||
+1
-1
@@ -5,7 +5,7 @@ date
|
|||||||
echo "uname: "
|
echo "uname: "
|
||||||
uname -a
|
uname -a
|
||||||
echo "ps: "
|
echo "ps: "
|
||||||
ps -auxw | grep [t]inyproxy -
|
ps -auxw | grep '[t]inyproxy' -
|
||||||
echo "ver: "
|
echo "ver: "
|
||||||
if [ -x /usr/local/bin/tinyproxy ]; then
|
if [ -x /usr/local/bin/tinyproxy ]; then
|
||||||
/usr/local/bin/tinyproxy -v
|
/usr/local/bin/tinyproxy -v
|
||||||
|
|||||||
+6
-1
@@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile.am,v 1.5 2001-10-01 04:01:10 rjkaes Exp $
|
# $Id: Makefile.am,v 1.7 2001-11-05 15:24:01 rjkaes Exp $
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -21,6 +21,7 @@ LDFLAGS = @LDFLAGS@
|
|||||||
bin_PROGRAMS = tinyproxy
|
bin_PROGRAMS = tinyproxy
|
||||||
|
|
||||||
tinyproxy_SOURCES = \
|
tinyproxy_SOURCES = \
|
||||||
|
conns.c conns.h \
|
||||||
buffer.c buffer.h \
|
buffer.c buffer.h \
|
||||||
dnscache.c dnscache.h \
|
dnscache.c dnscache.h \
|
||||||
log.c log.h \
|
log.c log.h \
|
||||||
@@ -45,3 +46,7 @@ EXTRA_tinyproxy_SOURCES = grammar.h
|
|||||||
|
|
||||||
scanner.c: scanner.l grammar.h
|
scanner.c: scanner.l grammar.h
|
||||||
$(LEX) $(AM_LFLAGS) $(LFLAGS) -i $< && mv $(LEX_OUTPUT_ROOT).c $@
|
$(LEX) $(AM_LFLAGS) $(LFLAGS) -i $< && mv $(LEX_OUTPUT_ROOT).c $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.da
|
||||||
|
rm -f gmon.out
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: acl.c,v 1.8 2001-09-15 21:21:01 rjkaes Exp $
|
/* $Id: acl.c,v 1.10 2001-11-03 06:08:37 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This system handles Access Control for use of this daemon. A list of
|
* This system handles Access Control for use of this daemon. A list of
|
||||||
* domains, or IP addresses (including IP blocks) are stored in a list
|
* domains, or IP addresses (including IP blocks) are stored in a list
|
||||||
@@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "tinyproxy.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "acl.h"
|
#include "acl.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
@@ -79,8 +77,11 @@ int insert_acl(char *location, acl_access_t access_type)
|
|||||||
/*
|
/*
|
||||||
* First check to see if the location is a string or numeric.
|
* First check to see if the location is a string or numeric.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < strlen((char *)location); i++) {
|
for (i = 0; location[i] != '\0'; i++) {
|
||||||
if (isdigit((unsigned char)location[i]) != 0 && location[i] != '.') {
|
/*
|
||||||
|
* Numeric strings can not contain letters, so test on it.
|
||||||
|
*/
|
||||||
|
if (isalpha((unsigned char)location[i])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,9 +102,11 @@ int insert_acl(char *location, acl_access_t access_type)
|
|||||||
|
|
||||||
new_acl_ptr->acl_access = access_type;
|
new_acl_ptr->acl_access = access_type;
|
||||||
|
|
||||||
if (i != strlen(location)) {
|
if (location[i] == '\0') {
|
||||||
|
DEBUG2("ACL \"%s\" is a number.", location);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We did break early, so this a numeric location.
|
* We did not break early, so this a numeric location.
|
||||||
* Check for a netmask.
|
* Check for a netmask.
|
||||||
*/
|
*/
|
||||||
new_acl_ptr->type = ACL_NUMERIC;
|
new_acl_ptr->type = ACL_NUMERIC;
|
||||||
@@ -111,7 +114,7 @@ int insert_acl(char *location, acl_access_t access_type)
|
|||||||
if (nptr) {
|
if (nptr) {
|
||||||
*nptr++ = '\0';
|
*nptr++ = '\0';
|
||||||
|
|
||||||
new_acl_ptr->netmask = atoi(nptr);
|
new_acl_ptr->netmask = strtol(nptr, NULL, 10);
|
||||||
if (new_acl_ptr->netmask < 0 || new_acl_ptr->netmask > 32) {
|
if (new_acl_ptr->netmask < 0 || new_acl_ptr->netmask > 32) {
|
||||||
safefree(new_acl_ptr);
|
safefree(new_acl_ptr);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -120,6 +123,8 @@ int insert_acl(char *location, acl_access_t access_type)
|
|||||||
new_acl_ptr->netmask = 32;
|
new_acl_ptr->netmask = 32;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
DEBUG2("ACL \"%s\" is a string.", location);
|
||||||
|
|
||||||
new_acl_ptr->type = ACL_STRING;
|
new_acl_ptr->type = ACL_STRING;
|
||||||
new_acl_ptr->netmask = 32;
|
new_acl_ptr->netmask = 32;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-11
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: anonymous.c,v 1.6 2001-08-26 21:07:27 rjkaes Exp $
|
/* $Id: anonymous.c,v 1.8 2001-11-05 15:24:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Handles insertion and searches for headers which should be let through when
|
* Handles insertion and searches for headers which should be let through when
|
||||||
* the anonymous feature is turned on. The headers are stored in a Ternary
|
* the anonymous feature is turned on. The headers are stored in a Ternary
|
||||||
@@ -18,15 +18,7 @@
|
|||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include "tinyproxy.h"
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "anonymous.h"
|
#include "anonymous.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@@ -40,7 +32,7 @@ static TERNARY anonymous_tree = 0;
|
|||||||
*/
|
*/
|
||||||
static short int anonymous_is_enabled = 0;
|
static short int anonymous_is_enabled = 0;
|
||||||
|
|
||||||
short int is_anonymous_enabled(void)
|
inline short int is_anonymous_enabled(void)
|
||||||
{
|
{
|
||||||
return anonymous_is_enabled;
|
return anonymous_is_enabled;
|
||||||
}
|
}
|
||||||
|
|||||||
+50
-56
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: buffer.c,v 1.12 2001-10-18 21:45:54 rjkaes Exp $
|
/* $Id: buffer.c,v 1.15 2001-11-05 15:23:05 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* The buffer used in each connection is a linked list of lines. As the lines
|
* The buffer used in each connection is a linked list of lines. As the lines
|
||||||
* are read in and written out the buffer expands and contracts. Basically,
|
* are read in and written out the buffer expands and contracts. Basically,
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#define BUFFER_HEAD(x) (((struct buffer_s *)(x))->head)
|
#define BUFFER_HEAD(x) (x)->head
|
||||||
#define BUFFER_TAIL(x) (((struct buffer_s *)(x))->tail)
|
#define BUFFER_TAIL(x) (x)->tail
|
||||||
|
|
||||||
struct bufline_s {
|
struct bufline_s {
|
||||||
unsigned char *string; /* the actual string of data */
|
unsigned char *string; /* the actual string of data */
|
||||||
@@ -37,31 +37,18 @@ struct bufline_s {
|
|||||||
size_t pos; /* start sending from this offset */
|
size_t pos; /* start sending from this offset */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct buffer_s {
|
|
||||||
struct bufline_s *head; /* top of the buffer */
|
|
||||||
struct bufline_s *tail; /* bottom of the buffer */
|
|
||||||
size_t size; /* total size of the buffer */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the size of the supplied buffer.
|
|
||||||
*/
|
|
||||||
size_t buffer_size(struct buffer_s *buffptr)
|
|
||||||
{
|
|
||||||
assert(buffptr != NULL);
|
|
||||||
|
|
||||||
return buffptr->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Take a string of data and a length and make a new line which can be added
|
* Take a string of data and a length and make a new line which can be added
|
||||||
* to the buffer
|
* to the buffer. We don't make a copy of the data, but simply copy the
|
||||||
|
* pointer into the structure. In other words, when you insert data into the
|
||||||
|
* buffer, the buffer becomes responsible for freeing it.
|
||||||
*/
|
*/
|
||||||
static struct bufline_s *makenewline(unsigned char *data, size_t length)
|
static struct bufline_s *makenewline(unsigned char *data, size_t length)
|
||||||
{
|
{
|
||||||
struct bufline_s *newline;
|
struct bufline_s *newline;
|
||||||
|
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
assert(length > 0);
|
||||||
|
|
||||||
if (!(newline = safemalloc(sizeof(struct bufline_s))))
|
if (!(newline = safemalloc(sizeof(struct bufline_s))))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -69,6 +56,8 @@ static struct bufline_s *makenewline(unsigned char *data, size_t length)
|
|||||||
newline->string = data;
|
newline->string = data;
|
||||||
newline->next = NULL;
|
newline->next = NULL;
|
||||||
newline->length = length;
|
newline->length = length;
|
||||||
|
|
||||||
|
/* Position our "read" pointer at the beginning of the data */
|
||||||
newline->pos = 0;
|
newline->pos = 0;
|
||||||
|
|
||||||
return newline;
|
return newline;
|
||||||
@@ -100,8 +89,13 @@ struct buffer_s *new_buffer(void)
|
|||||||
if (!(buffptr = safemalloc(sizeof(struct buffer_s))))
|
if (!(buffptr = safemalloc(sizeof(struct buffer_s))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buffptr->head = buffptr->tail = NULL;
|
/*
|
||||||
buffptr->size = 0;
|
* Since the buffer is initially empty, set the HEAD and TAIL
|
||||||
|
* pointers to NULL since they can't possibly point anywhere at the
|
||||||
|
* moment.
|
||||||
|
*/
|
||||||
|
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = NULL;
|
||||||
|
BUFFER_SIZE(buffptr) = 0;
|
||||||
|
|
||||||
return buffptr;
|
return buffptr;
|
||||||
}
|
}
|
||||||
@@ -120,8 +114,6 @@ void delete_buffer(struct buffer_s *buffptr)
|
|||||||
free_line(BUFFER_HEAD(buffptr));
|
free_line(BUFFER_HEAD(buffptr));
|
||||||
BUFFER_HEAD(buffptr) = next;
|
BUFFER_HEAD(buffptr) = next;
|
||||||
}
|
}
|
||||||
BUFFER_HEAD(buffptr) = NULL;
|
|
||||||
BUFFER_TAIL(buffptr) = NULL;
|
|
||||||
|
|
||||||
safefree(buffptr);
|
safefree(buffptr);
|
||||||
}
|
}
|
||||||
@@ -136,43 +128,46 @@ static int add_to_buffer(struct buffer_s *buffptr, unsigned char *data,
|
|||||||
|
|
||||||
assert(buffptr != NULL);
|
assert(buffptr != NULL);
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
assert(length > 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sanity check here. A buffer with a non-NULL head pointer must
|
||||||
|
* have a size greater than zero, and vice-versa.
|
||||||
|
*/
|
||||||
|
if (BUFFER_HEAD(buffptr) == NULL)
|
||||||
|
assert(BUFFER_SIZE(buffptr) == 0);
|
||||||
|
else
|
||||||
|
assert(BUFFER_SIZE(buffptr) > 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a new line so we can add it to the buffer.
|
||||||
|
*/
|
||||||
if (!(newline = makenewline(data, length)))
|
if (!(newline = makenewline(data, length)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!BUFFER_HEAD(buffptr) && !BUFFER_TAIL(buffptr))
|
if (BUFFER_SIZE(buffptr) == 0)
|
||||||
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = newline;
|
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = newline;
|
||||||
else
|
else
|
||||||
BUFFER_TAIL(buffptr) = (BUFFER_TAIL(buffptr)->next = newline);
|
BUFFER_TAIL(buffptr) = (BUFFER_TAIL(buffptr)->next = newline);
|
||||||
|
|
||||||
buffptr->size += length;
|
BUFFER_SIZE(buffptr) += length;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shift a line off the top of the buffer (remove the line from the top of
|
* Remove the first line from the top of the buffer
|
||||||
* the buffer)
|
|
||||||
*/
|
*/
|
||||||
static struct bufline_s *remove_from_buffer(struct buffer_s *buffptr)
|
static struct bufline_s *remove_from_buffer(struct buffer_s *buffptr)
|
||||||
{
|
{
|
||||||
struct bufline_s *line;
|
struct bufline_s *line;
|
||||||
|
|
||||||
assert(buffptr != NULL);
|
assert(buffptr != NULL);
|
||||||
|
assert(BUFFER_HEAD(buffptr) != NULL);
|
||||||
if (!BUFFER_HEAD(buffptr) && !BUFFER_TAIL(buffptr)) {
|
|
||||||
line = BUFFER_HEAD(buffptr);
|
|
||||||
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = NULL;
|
|
||||||
buffptr->size = 0;
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
line = BUFFER_HEAD(buffptr);
|
line = BUFFER_HEAD(buffptr);
|
||||||
BUFFER_HEAD(buffptr) = line->next;
|
BUFFER_HEAD(buffptr) = line->next;
|
||||||
|
|
||||||
if (!BUFFER_HEAD(buffptr))
|
|
||||||
BUFFER_TAIL(buffptr) = NULL;
|
|
||||||
|
|
||||||
buffptr->size -= line->length;
|
buffptr->size -= line->length;
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
@@ -182,6 +177,7 @@ static struct bufline_s *remove_from_buffer(struct buffer_s *buffptr)
|
|||||||
* Reads the bytes from the socket, and adds them to the buffer.
|
* Reads the bytes from the socket, and adds them to the buffer.
|
||||||
* Takes a connection and returns the number of bytes read.
|
* Takes a connection and returns the number of bytes read.
|
||||||
*/
|
*/
|
||||||
|
#define READ_BUFFER_SIZE (1024 * 2)
|
||||||
ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
||||||
{
|
{
|
||||||
ssize_t bytesin;
|
ssize_t bytesin;
|
||||||
@@ -191,14 +187,14 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
|||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(buffptr != NULL);
|
assert(buffptr != NULL);
|
||||||
|
|
||||||
if (buffer_size(buffptr) >= MAXBUFFSIZE)
|
if (BUFFER_SIZE(buffptr) >= READ_BUFFER_SIZE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buffer = safemalloc(MAXBUFFSIZE);
|
buffer = safemalloc(READ_BUFFER_SIZE);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bytesin = read(fd, buffer, MAXBUFFSIZE - buffer_size(buffptr));
|
bytesin = read(fd, buffer, READ_BUFFER_SIZE - BUFFER_SIZE(buffptr));
|
||||||
|
|
||||||
if (bytesin > 0) {
|
if (bytesin > 0) {
|
||||||
newbuffer = saferealloc(buffer, bytesin);
|
newbuffer = saferealloc(buffer, bytesin);
|
||||||
@@ -208,13 +204,15 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (add_to_buffer(buffptr, newbuffer, bytesin) < 0) {
|
if (add_to_buffer(buffptr, newbuffer, bytesin) < 0) {
|
||||||
|
log_message(LOG_ERR, "readbuff: add_to_buffer() error.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytesin;
|
return bytesin;
|
||||||
} else if (bytesin == 0) {
|
} else {
|
||||||
/* connection was closed by client */
|
|
||||||
safefree(buffer);
|
safefree(buffer);
|
||||||
|
if (bytesin == 0) {
|
||||||
|
/* connection was closed by client */
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
@@ -226,16 +224,14 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
case EINTR:
|
case EINTR:
|
||||||
safefree(buffer);
|
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
log_message(LOG_ERR, "recv error (fd %d: %s:%d) in 'readbuff'.",
|
log_message(LOG_ERR, "readbuff: recv() error \"%s\" on file descriptor %d", strerror(errno), fd);
|
||||||
fd, strerror(errno), errno);
|
|
||||||
safefree(buffer);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write the bytes in the buffer to the socket.
|
* Write the bytes in the buffer to the socket.
|
||||||
@@ -249,11 +245,13 @@ ssize_t writebuff(int fd, struct buffer_s *buffptr)
|
|||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(buffptr != NULL);
|
assert(buffptr != NULL);
|
||||||
|
|
||||||
line = BUFFER_HEAD(buffptr);
|
if (BUFFER_SIZE(buffptr) == 0)
|
||||||
|
|
||||||
if (buffer_size(buffptr) <= 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* Sanity check. It would be bad to be using a NULL pointer! */
|
||||||
|
assert(BUFFER_HEAD(buffptr) != NULL);
|
||||||
|
|
||||||
|
line = BUFFER_HEAD(buffptr);
|
||||||
bytessent = write(fd, line->string + line->pos, line->length - line->pos);
|
bytessent = write(fd, line->string + line->pos, line->length - line->pos);
|
||||||
|
|
||||||
if (bytessent >= 0) {
|
if (bytessent >= 0) {
|
||||||
@@ -275,14 +273,10 @@ ssize_t writebuff(int fd, struct buffer_s *buffptr)
|
|||||||
return 0;
|
return 0;
|
||||||
case ENOBUFS:
|
case ENOBUFS:
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
log_message(LOG_ERR,
|
log_message(LOG_ERR, "writebuff: write() error [NOBUFS/NOMEM] \"%s\" on file descriptor %d", strerror(errno), fd);
|
||||||
"write error [NOBUFS/NOMEM] (%s) in 'writebuff'.",
|
|
||||||
strerror(errno));
|
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
log_message(LOG_ERR,
|
log_message(LOG_ERR, "writebuff: write() error \"%s\" on file descriptor %d", strerror(errno), fd);
|
||||||
"write error (fd %d: %s:%d) in 'writebuff'.",
|
|
||||||
fd, strerror(errno), errno);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-2
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: buffer.h,v 1.4 2001-05-27 02:23:08 rjkaes Exp $
|
/* $Id: buffer.h,v 1.5 2001-11-05 15:23:05 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'buffer.c' for a detailed description.
|
* See 'buffer.c' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -18,9 +18,23 @@
|
|||||||
#ifndef _TINYPROXY_BUFFER_H_
|
#ifndef _TINYPROXY_BUFFER_H_
|
||||||
#define _TINYPROXY_BUFFER_H_
|
#define _TINYPROXY_BUFFER_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure contains the total size of a buffer, plus pointers to the
|
||||||
|
* head and tail of the buffer.
|
||||||
|
*/
|
||||||
|
struct buffer_s {
|
||||||
|
struct bufline_s *head; /* top of the buffer */
|
||||||
|
struct bufline_s *tail; /* bottom of the buffer */
|
||||||
|
size_t size; /* total size of the buffer */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the size of a buffer (pass a pointer to a buffer_s structure.)
|
||||||
|
*/
|
||||||
|
#define BUFFER_SIZE(x) (x)->size
|
||||||
|
|
||||||
extern struct buffer_s *new_buffer(void);
|
extern struct buffer_s *new_buffer(void);
|
||||||
extern void delete_buffer(struct buffer_s *buffptr);
|
extern void delete_buffer(struct buffer_s *buffptr);
|
||||||
extern size_t buffer_size(struct buffer_s *buffptr);
|
|
||||||
|
|
||||||
extern ssize_t readbuff(int fd, struct buffer_s *buffptr);
|
extern ssize_t readbuff(int fd, struct buffer_s *buffptr);
|
||||||
extern ssize_t writebuff(int fd, struct buffer_s *buffptr);
|
extern ssize_t writebuff(int fd, struct buffer_s *buffptr);
|
||||||
|
|||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
/* $Id: conns.c,v 1.4 2001-11-21 01:00:08 rjkaes Exp $
|
||||||
|
*
|
||||||
|
* Create and free the connection structure. One day there could be
|
||||||
|
* other connnection related tasks put here, but for now the header
|
||||||
|
* file and this file are only used for create/free functions and the
|
||||||
|
* connection structure definition.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2001 Robert James Kaes (rjkaes@flarenet.com)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2, or (at your option) any
|
||||||
|
* later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tinyproxy.h"
|
||||||
|
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "conns.h"
|
||||||
|
#include "stats.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
void initialize_conn(struct conn_s *connptr)
|
||||||
|
{
|
||||||
|
connptr->client_fd = connptr->server_fd = -1;
|
||||||
|
connptr->cbuffer = new_buffer();
|
||||||
|
connptr->sbuffer = new_buffer();
|
||||||
|
|
||||||
|
connptr->send_message = FALSE;
|
||||||
|
connptr->simple_req = FALSE;
|
||||||
|
|
||||||
|
connptr->ssl = FALSE;
|
||||||
|
connptr->upstream = FALSE;
|
||||||
|
|
||||||
|
connptr->protocol.major = connptr->protocol.minor = 0;
|
||||||
|
|
||||||
|
update_stats(STAT_OPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_conn(struct conn_s *connptr)
|
||||||
|
{
|
||||||
|
if (connptr->client_fd != -1)
|
||||||
|
close(connptr->client_fd);
|
||||||
|
if (connptr->server_fd != -1)
|
||||||
|
close(connptr->server_fd);
|
||||||
|
|
||||||
|
if (connptr->cbuffer)
|
||||||
|
delete_buffer(connptr->cbuffer);
|
||||||
|
if (connptr->sbuffer)
|
||||||
|
delete_buffer(connptr->sbuffer);
|
||||||
|
|
||||||
|
safefree(connptr);
|
||||||
|
|
||||||
|
update_stats(STAT_CLOSE);
|
||||||
|
}
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
/* $Id: conns.h,v 1.4 2001-11-21 01:00:09 rjkaes Exp $
|
||||||
|
*
|
||||||
|
* See 'conns.c' for a detailed description.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2001 Robert James Kaes (rjkaes@flarenet.com)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2, or (at your option) any
|
||||||
|
* later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_CONNS_H
|
||||||
|
#define TINYPROXY_CONNS_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Connection Definition
|
||||||
|
*/
|
||||||
|
struct conn_s {
|
||||||
|
int client_fd;
|
||||||
|
int server_fd;
|
||||||
|
struct buffer_s *cbuffer;
|
||||||
|
struct buffer_s *sbuffer;
|
||||||
|
bool_t simple_req;
|
||||||
|
bool_t ssl;
|
||||||
|
bool_t upstream;
|
||||||
|
bool_t send_message;
|
||||||
|
struct {
|
||||||
|
unsigned short int major;
|
||||||
|
unsigned short int minor;
|
||||||
|
} protocol;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions for the creation and destruction of a connection structure.
|
||||||
|
*/
|
||||||
|
extern void initialize_conn(struct conn_s *connptr);
|
||||||
|
extern void destroy_conn(struct conn_s *connptr);
|
||||||
|
|
||||||
|
#endif
|
||||||
+2
-9
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: dnscache.c,v 1.16 2001-09-12 03:32:24 rjkaes Exp $
|
/* $Id: dnscache.c,v 1.17 2001-10-25 17:27:39 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This is a caching DNS system. When a host name is needed we look it up here
|
* This is a caching DNS system. When a host name is needed we look it up here
|
||||||
* and see if there is already an answer for it. The domains are placed in a
|
* and see if there is already an answer for it. The domains are placed in a
|
||||||
@@ -20,14 +20,7 @@
|
|||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include "tinyproxy.h"
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "dnscache.h"
|
#include "dnscache.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|||||||
+2
-3
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: dnscache.h,v 1.6 2001-10-18 03:44:06 rjkaes Exp $
|
/* $Id: dnscache.h,v 1.7 2001-10-25 17:02:50 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'dnscache.c' for a detailed description.
|
* See 'dnscache.c' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -18,8 +18,7 @@
|
|||||||
#ifndef _TINYPROXY_DNSCACHE_H_
|
#ifndef _TINYPROXY_DNSCACHE_H_
|
||||||
#define _TINYPROXY_DNSCACHE_H_
|
#define _TINYPROXY_DNSCACHE_H_
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include "tinyproxy.h"
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
extern int dnscache(struct in_addr *addr, char *domain);
|
extern int dnscache(struct in_addr *addr, char *domain);
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: filter.c,v 1.6 2001-09-12 03:32:54 rjkaes Exp $
|
/* $Id: filter.c,v 1.7 2001-10-25 17:27:39 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca)
|
* Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca)
|
||||||
*
|
*
|
||||||
@@ -18,9 +18,6 @@
|
|||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "tinyproxy.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <sysexits.h>
|
|
||||||
|
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "regexp.h"
|
#include "regexp.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: log.c,v 1.14 2001-09-04 16:50:22 rjkaes Exp $
|
/* $Id: log.c,v 1.15 2001-10-25 17:27:39 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Logs the various messages which tinyproxy produces to either a log file or
|
* Logs the various messages which tinyproxy produces to either a log file or
|
||||||
* the syslog daemon. Not much to it...
|
* the syslog daemon. Not much to it...
|
||||||
@@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "tinyproxy.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static char *syslog_level[] = {
|
static char *syslog_level[] = {
|
||||||
|
|||||||
+116
-76
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: reqs.c,v 1.31 2001-10-22 16:08:29 rjkaes Exp $
|
/* $Id: reqs.c,v 1.39 2001-11-21 19:19:46 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This is where all the work in tinyproxy is actually done. Incoming
|
* This is where all the work in tinyproxy is actually done. Incoming
|
||||||
* connections have a new thread created for them. The thread then
|
* connections have a new thread created for them. The thread then
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "acl.h"
|
#include "acl.h"
|
||||||
#include "anonymous.h"
|
#include "anonymous.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
#include "conns.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "regexp.h"
|
#include "regexp.h"
|
||||||
@@ -81,7 +82,7 @@ static char *read_request_line(struct conn_s *connptr)
|
|||||||
|
|
||||||
len = readline(connptr->client_fd, request_buffer, LINE_LENGTH);
|
len = readline(connptr->client_fd, request_buffer, LINE_LENGTH);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
log_message(LOG_ERR, "Client (file descriptor: %d) closed socket before read.", connptr->client_fd);
|
log_message(LOG_ERR, "read_request_line: Client (file descriptor: %d) closed socket before read.", connptr->client_fd);
|
||||||
safefree(request_buffer);
|
safefree(request_buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -148,7 +149,7 @@ static int extract_http_url(const char *url, struct request_s *request)
|
|||||||
request->port = 80;
|
request->port = 80;
|
||||||
strcpy(request->path, "/");
|
strcpy(request->path, "/");
|
||||||
} else {
|
} else {
|
||||||
log_message(LOG_ERR, "Can't parse URL.");
|
log_message(LOG_ERR, "extract_http_url: Can't parse URL.");
|
||||||
|
|
||||||
safefree(request->host);
|
safefree(request->host);
|
||||||
safefree(request->path);
|
safefree(request->path);
|
||||||
@@ -173,7 +174,7 @@ static int extract_ssl_url(const char *url, struct request_s *request)
|
|||||||
else if (sscanf(url, "%s", request->host) == 1)
|
else if (sscanf(url, "%s", request->host) == 1)
|
||||||
request->port = 443;
|
request->port = 443;
|
||||||
else {
|
else {
|
||||||
log_message(LOG_ERR, "Can't parse URL.");
|
log_message(LOG_ERR, "extract_ssl_url: Can't parse URL.");
|
||||||
|
|
||||||
safefree(request->host);
|
safefree(request->host);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -281,7 +282,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
|||||||
|
|
||||||
ret = sscanf(request_line, "%[^ ] %[^ ] %[^ ]", request->method, url, request->protocol);
|
ret = sscanf(request_line, "%[^ ] %[^ ] %[^ ]", request->method, url, request->protocol);
|
||||||
if (ret < 2) {
|
if (ret < 2) {
|
||||||
log_message(LOG_ERR, "Bad Request on file descriptor %d", connptr->client_fd);
|
log_message(LOG_ERR, "process_request: Bad Request on file descriptor %d", connptr->client_fd);
|
||||||
httperr(connptr, 400, "Bad Request. No request found.");
|
httperr(connptr, 400, "Bad Request. No request found.");
|
||||||
|
|
||||||
safefree(url);
|
safefree(url);
|
||||||
@@ -293,7 +294,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
log_message(LOG_ERR, "Null URL on file descriptor %d", connptr->client_fd);
|
log_message(LOG_ERR, "process_request: Null URL on file descriptor %d", connptr->client_fd);
|
||||||
httperr(connptr, 400, "Bad Request. Null URL.");
|
httperr(connptr, 400, "Bad Request. Null URL.");
|
||||||
|
|
||||||
safefree(url);
|
safefree(url);
|
||||||
@@ -326,7 +327,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
|||||||
}
|
}
|
||||||
connptr->ssl = TRUE;
|
connptr->ssl = TRUE;
|
||||||
} else {
|
} else {
|
||||||
log_message(LOG_ERR, "Unknown URL type on file descriptor %d", connptr->client_fd);
|
log_message(LOG_ERR, "process_request: Unknown URL type on file descriptor %d", connptr->client_fd);
|
||||||
httperr(connptr, 400, "Bad Request. Unknown URL type.");
|
httperr(connptr, 400, "Bad Request. Unknown URL type.");
|
||||||
|
|
||||||
safefree(url);
|
safefree(url);
|
||||||
@@ -345,7 +346,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
|||||||
if (filter_url(request->host)) {
|
if (filter_url(request->host)) {
|
||||||
update_stats(STAT_DENIED);
|
update_stats(STAT_DENIED);
|
||||||
|
|
||||||
log_message(LOG_ERR, "Proxying refused on filtered domain \"%s\"", request->host);
|
log_message(LOG_NOTICE, "Proxying refused on filtered domain \"%s\"", request->host);
|
||||||
httperr(connptr, 404, "Connection to filtered domain is now allowed.");
|
httperr(connptr, 404, "Connection to filtered domain is now allowed.");
|
||||||
|
|
||||||
free_request_struct(request);
|
free_request_struct(request);
|
||||||
@@ -359,7 +360,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
|||||||
* Check to see if they're requesting the stat host
|
* Check to see if they're requesting the stat host
|
||||||
*/
|
*/
|
||||||
if (config.stathost && strcmp(config.stathost, request->host) == 0) {
|
if (config.stathost && strcmp(config.stathost, request->host) == 0) {
|
||||||
log_message(LOG_NOTICE, "tinyproxy stathost request.");
|
log_message(LOG_NOTICE, "Request for the stathost.");
|
||||||
|
|
||||||
free_request_struct(request);
|
free_request_struct(request);
|
||||||
|
|
||||||
@@ -367,6 +368,14 @@ static struct request_s *process_request(struct conn_s *connptr,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Break apart the protocol and update the connection structure.
|
||||||
|
*/
|
||||||
|
if (strncasecmp(request->protocol, "http", 4) == 0) {
|
||||||
|
memcpy(request->protocol, "HTTP", 4);
|
||||||
|
sscanf(request->protocol, "HTTP/%hu.%hu", &connptr->protocol.major, &connptr->protocol.minor);
|
||||||
|
}
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,6 +454,12 @@ static int add_xtinyproxy_header(struct conn_s *connptr)
|
|||||||
char xtinyproxy[32];
|
char xtinyproxy[32];
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't try to send if we have an invalid server handle.
|
||||||
|
*/
|
||||||
|
if (connptr->server_fd == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
length = snprintf(xtinyproxy, sizeof(xtinyproxy),
|
length = snprintf(xtinyproxy, sizeof(xtinyproxy),
|
||||||
"X-Tinyproxy: %s\r\n",
|
"X-Tinyproxy: %s\r\n",
|
||||||
getpeer_ip(connptr->client_fd, ipaddr));
|
getpeer_ip(connptr->client_fd, ipaddr));
|
||||||
@@ -465,10 +480,16 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
{
|
{
|
||||||
char *header;
|
char *header;
|
||||||
long content_length = -1;
|
long content_length = -1;
|
||||||
|
#if 0
|
||||||
|
short int sent_via_header = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
static char *skipheaders[] = {
|
static char *skipheaders[] = {
|
||||||
"proxy-connection",
|
"proxy-connection",
|
||||||
"host",
|
"host",
|
||||||
|
"keep-alive",
|
||||||
|
"proxy-authenticate",
|
||||||
|
"proxy-authorization",
|
||||||
"connection"
|
"connection"
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
@@ -479,6 +500,7 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
|
|
||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
if (readline(connptr->client_fd, header, LINE_LENGTH) <= 0) {
|
if (readline(connptr->client_fd, header, LINE_LENGTH) <= 0) {
|
||||||
|
DEBUG2("Client (file descriptor %d) closed connection.", connptr->client_fd);
|
||||||
safefree(header);
|
safefree(header);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -492,11 +514,32 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't send any of the headers if we're in SSL mode.
|
* Don't send any of the headers if we're in SSL mode and
|
||||||
|
* NOT using an upstream proxy.
|
||||||
*/
|
*/
|
||||||
if (connptr->ssl)
|
if (connptr->ssl && !connptr->upstream)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
* If we find a Via header we need to append our information
|
||||||
|
* to the end of it.
|
||||||
|
*/
|
||||||
|
if (strncasecmp(header, "via", 3) == 0) {
|
||||||
|
char hostname[128];
|
||||||
|
char via_header_buffer[256];
|
||||||
|
|
||||||
|
sent_via_header = 1;
|
||||||
|
|
||||||
|
gethostname(hostname, sizeof(hostname));
|
||||||
|
snprintf(via_header_buffer, sizeof(via_header_buffer), ", %hu.%hu %s (%s/%s)\r\n", connptr->protocol.major, connptr->protocol.minor, hostname, PACKAGE, VERSION);
|
||||||
|
|
||||||
|
trim(header, strlen(header));
|
||||||
|
|
||||||
|
strlcat(header, via_header_buffer, LINE_LENGTH);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't send certain headers.
|
* Don't send certain headers.
|
||||||
*/
|
*/
|
||||||
@@ -517,13 +560,28 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
content_length = atol(content_ptr);
|
content_length = atol(content_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
if ((connptr->server_fd != -1) && safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
||||||
safefree(header);
|
safefree(header);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connptr->send_message && !connptr->ssl) {
|
#if 0
|
||||||
|
if (sent_via_header == 0) {
|
||||||
|
/*
|
||||||
|
* We're the first proxy so send the first Via header.
|
||||||
|
*/
|
||||||
|
char via_header_buffer[256];
|
||||||
|
char hostname[128];
|
||||||
|
|
||||||
|
gethostname(hostname, sizeof(hostname));
|
||||||
|
snprintf(via_header_buffer, sizeof(via_header_buffer), "Via: %hu.%hu %s (%s/%s)\r\n", connptr->protocol.major, connptr->protocol.minor, hostname, PACKAGE, VERSION);
|
||||||
|
|
||||||
|
safe_write(connptr->server_fd, via_header_buffer, strlen(via_header_buffer));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!connptr->send_message && (connptr->upstream || !connptr->ssl)) {
|
||||||
#ifdef XTINYPROXY_ENABLE
|
#ifdef XTINYPROXY_ENABLE
|
||||||
if (config.my_domain
|
if (config.my_domain
|
||||||
&& add_xtinyproxy_header(connptr) < 0) {
|
&& add_xtinyproxy_header(connptr) < 0) {
|
||||||
@@ -532,7 +590,7 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
}
|
}
|
||||||
#endif /* XTINYPROXY */
|
#endif /* XTINYPROXY */
|
||||||
|
|
||||||
if (safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
if ((connptr->server_fd != -1) && safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
||||||
safefree(header);
|
safefree(header);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -563,6 +621,7 @@ static int process_server_headers(struct conn_s *connptr)
|
|||||||
|
|
||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
if (readline(connptr->server_fd, header, LINE_LENGTH) <= 0) {
|
if (readline(connptr->server_fd, header, LINE_LENGTH) <= 0) {
|
||||||
|
DEBUG2("Server (file descriptor %d) closed connection.", connptr->server_fd);
|
||||||
safefree(header);
|
safefree(header);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -618,13 +677,13 @@ static void relay_connection(struct conn_s *connptr)
|
|||||||
tv.tv_sec = config.idletimeout - difftime(time(NULL), last_access);
|
tv.tv_sec = config.idletimeout - difftime(time(NULL), last_access);
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
if (buffer_size(connptr->sbuffer) > 0)
|
if (BUFFER_SIZE(connptr->sbuffer) > 0)
|
||||||
FD_SET(connptr->client_fd, &wset);
|
FD_SET(connptr->client_fd, &wset);
|
||||||
if (buffer_size(connptr->cbuffer) > 0)
|
if (BUFFER_SIZE(connptr->cbuffer) > 0)
|
||||||
FD_SET(connptr->server_fd, &wset);
|
FD_SET(connptr->server_fd, &wset);
|
||||||
if (buffer_size(connptr->sbuffer) < MAXBUFFSIZE)
|
if (BUFFER_SIZE(connptr->sbuffer) < MAXBUFFSIZE)
|
||||||
FD_SET(connptr->server_fd, &rset);
|
FD_SET(connptr->server_fd, &rset);
|
||||||
if (buffer_size(connptr->cbuffer) < MAXBUFFSIZE)
|
if (BUFFER_SIZE(connptr->cbuffer) < MAXBUFFSIZE)
|
||||||
FD_SET(connptr->client_fd, &rset);
|
FD_SET(connptr->client_fd, &rset);
|
||||||
|
|
||||||
ret = select(maxfd, &rset, &wset, NULL, &tv);
|
ret = select(maxfd, &rset, &wset, NULL, &tv);
|
||||||
@@ -638,7 +697,7 @@ static void relay_connection(struct conn_s *connptr)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (ret < 0) {
|
} else if (ret < 0) {
|
||||||
log_message(LOG_ERR, "Received an error in select() [\"%s\", %d], so closing connection (client_fd:%d, server_fd:%d)", strerror(errno), errno, connptr->client_fd, connptr->server_fd);
|
log_message(LOG_ERR, "relay_connection: select() error \"%s\". Closing connection (client_fd:%d, server_fd:%d)", strerror(errno), connptr->client_fd, connptr->server_fd);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@@ -649,21 +708,19 @@ static void relay_connection(struct conn_s *connptr)
|
|||||||
|
|
||||||
if (FD_ISSET(connptr->server_fd, &rset)
|
if (FD_ISSET(connptr->server_fd, &rset)
|
||||||
&& readbuff(connptr->server_fd, connptr->sbuffer) < 0) {
|
&& readbuff(connptr->server_fd, connptr->sbuffer) < 0) {
|
||||||
shutdown(connptr->server_fd, SHUT_WR);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (FD_ISSET(connptr->client_fd, &rset)
|
if (FD_ISSET(connptr->client_fd, &rset)
|
||||||
&& readbuff(connptr->client_fd, connptr->cbuffer) < 0) {
|
&& readbuff(connptr->client_fd, connptr->cbuffer) < 0) {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
if (FD_ISSET(connptr->server_fd, &wset)
|
if (FD_ISSET(connptr->server_fd, &wset)
|
||||||
&& writebuff(connptr->server_fd, connptr->cbuffer) < 0) {
|
&& writebuff(connptr->server_fd, connptr->cbuffer) < 0) {
|
||||||
shutdown(connptr->server_fd, SHUT_WR);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (FD_ISSET(connptr->client_fd, &wset)
|
if (FD_ISSET(connptr->client_fd, &wset)
|
||||||
&& writebuff(connptr->client_fd, connptr->sbuffer) < 0) {
|
&& writebuff(connptr->client_fd, connptr->sbuffer) < 0) {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,45 +729,23 @@ static void relay_connection(struct conn_s *connptr)
|
|||||||
* remainder to the client and then exit.
|
* remainder to the client and then exit.
|
||||||
*/
|
*/
|
||||||
socket_blocking(connptr->client_fd);
|
socket_blocking(connptr->client_fd);
|
||||||
while (buffer_size(connptr->sbuffer) > 0) {
|
while (BUFFER_SIZE(connptr->sbuffer) > 0) {
|
||||||
if (writebuff(connptr->client_fd, connptr->sbuffer) < 0)
|
if (writebuff(connptr->client_fd, connptr->sbuffer) < 0)
|
||||||
return;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to send any remaining data to the server if we can.
|
||||||
|
*/
|
||||||
|
socket_blocking(connptr->server_fd);
|
||||||
|
while (BUFFER_SIZE(connptr->cbuffer) > 0) {
|
||||||
|
if (writebuff(connptr->client_fd, connptr->cbuffer) < 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize_conn(struct conn_s *connptr)
|
|
||||||
{
|
|
||||||
connptr->client_fd = connptr->server_fd = -1;
|
|
||||||
connptr->cbuffer = new_buffer();
|
|
||||||
connptr->sbuffer = new_buffer();
|
|
||||||
|
|
||||||
connptr->send_message = FALSE;
|
|
||||||
connptr->simple_req = FALSE;
|
|
||||||
|
|
||||||
connptr->ssl = FALSE;
|
|
||||||
|
|
||||||
update_stats(STAT_OPEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void destroy_conn(struct conn_s *connptr)
|
|
||||||
{
|
|
||||||
if (connptr->client_fd != -1)
|
|
||||||
close(connptr->client_fd);
|
|
||||||
if (connptr->server_fd != -1)
|
|
||||||
close(connptr->server_fd);
|
|
||||||
|
|
||||||
if (connptr->cbuffer)
|
|
||||||
delete_buffer(connptr->cbuffer);
|
|
||||||
if (connptr->sbuffer)
|
|
||||||
delete_buffer(connptr->sbuffer);
|
|
||||||
|
|
||||||
safefree(connptr);
|
|
||||||
|
|
||||||
update_stats(STAT_CLOSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef UPSTREAM_SUPPORT
|
#ifdef UPSTREAM_SUPPORT
|
||||||
/*
|
/*
|
||||||
* Establish a connection to the upstream proxy server.
|
* Establish a connection to the upstream proxy server.
|
||||||
@@ -718,7 +753,7 @@ static void destroy_conn(struct conn_s *connptr)
|
|||||||
static int connect_to_upstream(struct conn_s *connptr,
|
static int connect_to_upstream(struct conn_s *connptr,
|
||||||
struct request_s *request)
|
struct request_s *request)
|
||||||
{
|
{
|
||||||
char *combined_host_path;
|
char *combined_string;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
connptr->server_fd = opensock(config.upstream_name, config.upstream_port);
|
connptr->server_fd = opensock(config.upstream_name, config.upstream_port);
|
||||||
@@ -731,29 +766,32 @@ static int connect_to_upstream(struct conn_s *connptr,
|
|||||||
|
|
||||||
log_message(LOG_CONN, "Established connection to upstream proxy \"%s\" using file descriptor %d.", config.upstream_name, connptr->server_fd);
|
log_message(LOG_CONN, "Established connection to upstream proxy \"%s\" using file descriptor %d.", config.upstream_name, connptr->server_fd);
|
||||||
|
|
||||||
if (connptr->ssl) {
|
|
||||||
safe_write(connptr->server_fd, "CONNECT ", 8);
|
|
||||||
safe_write(connptr->server_fd, request->host, strlen(request->host));
|
|
||||||
safe_write(connptr->server_fd, ":443 HTTP/1.0\r\n", 15);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since we're going to use the establish_http_connection() function
|
* We need to re-write the "path" part of the request so that we
|
||||||
* we need to rebuild the "path" by combining the host, port, and
|
* can reuse the establish_http_connection() function. It expects a
|
||||||
* path so we can use the common send functions.
|
* method and path.
|
||||||
*/
|
*/
|
||||||
len = strlen(request->host) + strlen(request->path) + 14;
|
if (connptr->ssl) {
|
||||||
combined_host_path = safemalloc(len + 1);
|
len = strlen(request->host) + 6;
|
||||||
if (!combined_host_path) {
|
|
||||||
|
combined_string = safemalloc(len + 1);
|
||||||
|
if (!combined_string) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(combined_host_path, len, "http://%s:%d%s", request->host, request->port, request->path);
|
snprintf(combined_string, len, "%s:%d", request->host, request->port);
|
||||||
|
} else {
|
||||||
|
len = strlen(request->host) + strlen(request->path) + 14;
|
||||||
|
combined_string = safemalloc(len + 1);
|
||||||
|
if (!combined_string) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(combined_string, len, "http://%s:%d%s", request->host, request->port, request->path);
|
||||||
|
}
|
||||||
|
|
||||||
safefree(request->path);
|
safefree(request->path);
|
||||||
request->path = combined_host_path;
|
request->path = combined_string;
|
||||||
|
|
||||||
return establish_http_connection(connptr, request);
|
return establish_http_connection(connptr, request);
|
||||||
}
|
}
|
||||||
@@ -816,7 +854,7 @@ void handle_connection(int fd)
|
|||||||
goto internal_proxy;
|
goto internal_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message(LOG_CONN, "Established a connection to the tunnel \"%s\" using file descriptor %d.", config.tunnel_name, connptr->server_fd);
|
log_message(LOG_INFO, "Established a connection to the tunnel \"%s\" using file descriptor %d.", config.tunnel_name, connptr->server_fd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I know GOTOs are evil, but duplicating the code is even
|
* I know GOTOs are evil, but duplicating the code is even
|
||||||
@@ -849,6 +887,8 @@ internal_proxy:
|
|||||||
|
|
||||||
#ifdef UPSTREAM_SUPPORT
|
#ifdef UPSTREAM_SUPPORT
|
||||||
if (config.upstream_name && config.upstream_port != -1) {
|
if (config.upstream_name && config.upstream_port != -1) {
|
||||||
|
connptr->upstream = TRUE;
|
||||||
|
|
||||||
if (connect_to_upstream(connptr, request) < 0)
|
if (connect_to_upstream(connptr, request) < 0)
|
||||||
goto send_error;
|
goto send_error;
|
||||||
} else {
|
} else {
|
||||||
@@ -885,7 +925,7 @@ send_error:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connptr->ssl || config.upstream_name) {
|
if (!connptr->ssl || connptr->upstream) {
|
||||||
if (process_server_headers(connptr) < 0) {
|
if (process_server_headers(connptr) < 0) {
|
||||||
update_stats(STAT_BADCONN);
|
update_stats(STAT_BADCONN);
|
||||||
destroy_conn(connptr);
|
destroy_conn(connptr);
|
||||||
@@ -893,7 +933,7 @@ send_error:
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (send_ssl_response(connptr) < 0) {
|
if (send_ssl_response(connptr) < 0) {
|
||||||
log_message(LOG_ERR, "Could not send SSL greeting to client.");
|
log_message(LOG_ERR, "handle_connection: Could not send SSL greeting to client.");
|
||||||
update_stats(STAT_BADCONN);
|
update_stats(STAT_BADCONN);
|
||||||
destroy_conn(connptr);
|
destroy_conn(connptr);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+2
-3
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: scanner.l,v 1.5 2001-09-16 20:08:24 rjkaes Exp $
|
/* $Id: scanner.l,v 1.6 2001-10-25 17:27:39 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This builds the scanner for the tinyproxy configuration file. This
|
* This builds the scanner for the tinyproxy configuration file. This
|
||||||
* file needs to stay in sync with grammar.y. If someone knows lex and yacc
|
* file needs to stay in sync with grammar.y. If someone knows lex and yacc
|
||||||
@@ -19,9 +19,8 @@
|
|||||||
%{
|
%{
|
||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "tinyproxy.h"
|
||||||
|
|
||||||
#include "grammar.h"
|
#include "grammar.h"
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
struct keyword {
|
struct keyword {
|
||||||
char *kw_name;
|
char *kw_name;
|
||||||
|
|||||||
+27
-11
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: sock.c,v 1.10 2001-10-22 16:52:34 rjkaes Exp $
|
/* $Id: sock.c,v 1.15 2001-11-12 21:10:51 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Sockets are created and destroyed here. When a new connection comes in from
|
* Sockets are created and destroyed here. When a new connection comes in from
|
||||||
* a client, we need to copy the socket and the create a second socket to the
|
* a client, we need to copy the socket and the create a second socket to the
|
||||||
@@ -66,19 +66,19 @@ int opensock(char *ip_addr, uint16_t port)
|
|||||||
ret = dnscache(&port_info.sin_addr, ip_addr);
|
ret = dnscache(&port_info.sin_addr, ip_addr);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
log_message(LOG_ERR, "Could not lookup address [%s].", ip_addr);
|
log_message(LOG_ERR, "opensock: Could not lookup address \"%s\".", ip_addr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
port_info.sin_port = htons(port);
|
port_info.sin_port = htons(port);
|
||||||
|
|
||||||
if ((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
if ((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||||
log_message(LOG_ERR, "Could not create socket because of '%s'.", strerror(errno));
|
log_message(LOG_ERR, "opensock: socket() error \"%s\".", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect(sock_fd, (struct sockaddr*)&port_info, sizeof(port_info)) < 0) {
|
if (connect(sock_fd, (struct sockaddr*)&port_info, sizeof(port_info)) < 0) {
|
||||||
log_message(LOG_ERR, "Could not connect socket because of '%s'", strerror(errno));
|
log_message(LOG_ERR, "opensock: connect() error \"%s\".", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,9 +160,13 @@ char *getpeer_ip(int fd, char *ipaddr)
|
|||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(ipaddr != NULL);
|
assert(ipaddr != NULL);
|
||||||
|
|
||||||
if (getpeername(fd, (struct sockaddr*)&name, &namelen) != 0) {
|
/*
|
||||||
log_message(LOG_ERR, "geetpeer_ip: 'could not get peer name' (\"%s\": %d)", strerror(errno), errno);
|
* Make sure the user's buffer is initialized to an empty string.
|
||||||
|
*/
|
||||||
*ipaddr = '\0';
|
*ipaddr = '\0';
|
||||||
|
|
||||||
|
if (getpeername(fd, (struct sockaddr*)&name, &namelen) != 0) {
|
||||||
|
log_message(LOG_ERR, "getpeer_ip: getpeername() error \"%s\".", strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
strlcpy(ipaddr,
|
strlcpy(ipaddr,
|
||||||
inet_ntoa(*(struct in_addr*)&name.sin_addr.s_addr),
|
inet_ntoa(*(struct in_addr*)&name.sin_addr.s_addr),
|
||||||
@@ -185,9 +189,13 @@ char *getpeer_string(int fd, char *string)
|
|||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(string != NULL);
|
assert(string != NULL);
|
||||||
|
|
||||||
if (getpeername(fd, (struct sockaddr *)&name, &namelen) != 0) {
|
/*
|
||||||
log_message(LOG_ERR, "getpeer_string: 'could not get peer name' (\"%s\": %d)", strerror(errno), errno);
|
* Make sure the user's buffer is initialized to an empty string.
|
||||||
|
*/
|
||||||
*string = '\0';
|
*string = '\0';
|
||||||
|
|
||||||
|
if (getpeername(fd, (struct sockaddr *)&name, &namelen) != 0) {
|
||||||
|
log_message(LOG_ERR, "getpeer_string: getpeername() error \"%s\".", strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
LOCK();
|
LOCK();
|
||||||
peername = gethostbyaddr((char *)&name.sin_addr.s_addr,
|
peername = gethostbyaddr((char *)&name.sin_addr.s_addr,
|
||||||
@@ -195,6 +203,9 @@ char *getpeer_string(int fd, char *string)
|
|||||||
AF_INET);
|
AF_INET);
|
||||||
if (peername)
|
if (peername)
|
||||||
strlcpy(string, peername->h_name, PEER_STRING_LENGTH);
|
strlcpy(string, peername->h_name, PEER_STRING_LENGTH);
|
||||||
|
else
|
||||||
|
log_message(LOG_ERR, "getpeer_string: gethostbyaddr() error \"%s\".", hstrerror(h_errno));
|
||||||
|
|
||||||
UNLOCK();
|
UNLOCK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,23 +259,28 @@ ssize_t readline(int fd, char *ptr, size_t maxlen)
|
|||||||
|
|
||||||
for (n = 1; n < maxlen; n++) {
|
for (n = 1; n < maxlen; n++) {
|
||||||
again:
|
again:
|
||||||
if ((rc = read(fd, &c, 1)) == 1) {
|
if ((rc = recv(fd, &c, 1, MSG_NOSIGNAL)) == 1) {
|
||||||
*ptr++ = c;
|
*ptr++ = c;
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
} else if (rc == 0) {
|
} else if (rc == 0) {
|
||||||
if (n == 1)
|
if (n == 1) {
|
||||||
|
DEBUG2("File_Desc: %d Closed.", fd);
|
||||||
return 0;
|
return 0;
|
||||||
else
|
} else
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
goto again;
|
goto again;
|
||||||
|
|
||||||
|
DEBUG2("File_Desc: %d \"%s\" (%d)", fd, strerror(errno), errno);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tack a NIL to the end to make is a standard "C" string */
|
/* Tack a NIL to the end to make is a standard "C" string */
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
|
|
||||||
return (ssize_t)n;
|
return (ssize_t)n;
|
||||||
}
|
}
|
||||||
+2
-4
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: sock.h,v 1.5 2001-09-16 20:11:07 rjkaes Exp $
|
/* $Id: sock.h,v 1.6 2001-10-25 17:02:50 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'sock.c' for a detailed description.
|
* See 'sock.c' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -19,9 +19,7 @@
|
|||||||
#ifndef TINYPROXY_SOCK_H
|
#ifndef TINYPROXY_SOCK_H
|
||||||
#define TINYPROXY_SOCK_H
|
#define TINYPROXY_SOCK_H
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include "tinyproxy.h"
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PEER_IP_LENGTH 16
|
#define PEER_IP_LENGTH 16
|
||||||
#define PEER_STRING_LENGTH 256
|
#define PEER_STRING_LENGTH 256
|
||||||
|
|||||||
+3
-1
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: stats.h,v 1.2 2001-09-16 20:11:24 rjkaes Exp $
|
/* $Id: stats.h,v 1.3 2001-10-25 16:58:50 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'stats.h' for a detailed description.
|
* See 'stats.h' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
#ifndef _TINYPROXY_STATS_H_
|
#ifndef _TINYPROXY_STATS_H_
|
||||||
#define _TINYPROXY_STATS_H_
|
#define _TINYPROXY_STATS_H_
|
||||||
|
|
||||||
|
#include "conns.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Various logable statistics
|
* Various logable statistics
|
||||||
*/
|
*/
|
||||||
|
|||||||
+2
-14
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: ternary.c,v 1.10 2001-09-08 18:58:02 rjkaes Exp $
|
/* $Id: ternary.c,v 1.11 2001-10-25 17:27:39 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This module creates a Ternary Search Tree which can store both string
|
* This module creates a Ternary Search Tree which can store both string
|
||||||
* keys, and arbitrary data for each key. It works similar to a hash, and
|
* keys, and arbitrary data for each key. It works similar to a hash, and
|
||||||
@@ -21,22 +21,10 @@
|
|||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined HAVE_CONFIG_H
|
#include "tinyproxy.h"
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined HAVE_SYS_TYPES_H
|
|
||||||
# include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "ternary.h"
|
#include "ternary.h"
|
||||||
#include "tinyproxy.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: thread.c,v 1.16 2001-09-15 21:28:25 rjkaes Exp $
|
/* $Id: thread.c,v 1.17 2001-10-24 00:37:23 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Handles the creation/destruction of the various threads required for
|
* Handles the creation/destruction of the various threads required for
|
||||||
* processing incoming connections.
|
* processing incoming connections.
|
||||||
@@ -196,11 +196,11 @@ short int thread_pool_create(void)
|
|||||||
pthread_attr_setstacksize(&thread_attr, THREAD_STACK_SIZE);
|
pthread_attr_setstacksize(&thread_attr, THREAD_STACK_SIZE);
|
||||||
|
|
||||||
if (thread_config.maxclients == 0) {
|
if (thread_config.maxclients == 0) {
|
||||||
log_message(LOG_ERR, "'MaxClients' must be greater than zero.");
|
log_message(LOG_ERR, "thread_pool_create: \"MaxClients\" must be greater than zero.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (thread_config.startservers == 0) {
|
if (thread_config.startservers == 0) {
|
||||||
log_message(LOG_ERR, "'StartServers' must be greater than zero.");
|
log_message(LOG_ERR, "thread_pool_create: \"StartServers\" must be greater than zero.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ short int thread_pool_create(void)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (thread_config.startservers > thread_config.maxclients) {
|
if (thread_config.startservers > thread_config.maxclients) {
|
||||||
log_message(LOG_WARNING, "Can not start more than 'MaxClients' servers. Starting %u servers instead.", thread_config.maxclients);
|
log_message(LOG_WARNING, "Can not start more than \"MaxClients\" servers. Starting %u servers instead.", thread_config.maxclients);
|
||||||
thread_config.startservers = thread_config.maxclients;
|
thread_config.startservers = thread_config.maxclients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-10
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tinyproxy.c,v 1.17 2001-09-16 20:11:54 rjkaes Exp $
|
/* $Id: tinyproxy.c,v 1.18 2001-10-25 17:27:39 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* The initialise routine. Basically sets up all the initial stuff (logfile,
|
* The initialise routine. Basically sets up all the initial stuff (logfile,
|
||||||
* listening socket, config options, etc.) and then sits there and loops
|
* listening socket, config options, etc.) and then sits there and loops
|
||||||
@@ -24,15 +24,6 @@
|
|||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "tinyproxy.h"
|
||||||
|
|
||||||
#ifdef HAVE_SYS_RESOURCE_H
|
|
||||||
# include <sys/resource.h>
|
|
||||||
#endif /* HAVE_SYS_RESOUCE_H */
|
|
||||||
#include <grp.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <sysexits.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
|
|
||||||
#include "anonymous.h"
|
#include "anonymous.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "dnscache.h"
|
#include "dnscache.h"
|
||||||
|
|||||||
+12
-10
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tinyproxy.h,v 1.16 2001-09-16 20:12:29 rjkaes Exp $
|
/* $Id: tinyproxy.h,v 1.19 2001-10-25 17:27:39 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'tinyproxy.c' for a detailed description.
|
* See 'tinyproxy.c' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -27,6 +27,9 @@
|
|||||||
* Include standard headers which are used through-out tinyproxy
|
* Include standard headers which are used through-out tinyproxy
|
||||||
*/
|
*/
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
|
# include <sys/resource.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_SYS_SELECT_H
|
#ifdef HAVE_SYS_SELECT_H
|
||||||
# include <sys/select.h>
|
# include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -45,12 +48,18 @@
|
|||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <grp.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#ifdef HAVE_PTHREAD_H
|
#ifdef HAVE_PTHREAD_H
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#ifdef HAVE_STDINT_H
|
#ifdef HAVE_STDINT_H
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -60,8 +69,9 @@
|
|||||||
#ifdef HAVE_STRINGS_H
|
#ifdef HAVE_STRINGS_H
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sysexits.h>
|
||||||
|
#include <syslog.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#ifndef SHUT_RD /* these three Posix.1g names are quite new */
|
#ifndef SHUT_RD /* these three Posix.1g names are quite new */
|
||||||
# define SHUT_RD 0 /* shutdown for reading */
|
# define SHUT_RD 0 /* shutdown for reading */
|
||||||
@@ -113,14 +123,6 @@ struct config_s {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct conn_s {
|
|
||||||
int client_fd, server_fd;
|
|
||||||
struct buffer_s *cbuffer, *sbuffer;
|
|
||||||
bool_t simple_req;
|
|
||||||
bool_t ssl;
|
|
||||||
bool_t send_message;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Global Structures used in the program */
|
/* Global Structures used in the program */
|
||||||
extern struct config_s config;
|
extern struct config_s config;
|
||||||
|
|
||||||
|
|||||||
+9
-12
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: utils.c,v 1.13 2001-09-16 20:13:52 rjkaes Exp $
|
/* $Id: utils.c,v 1.16 2001-10-25 17:27:39 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Misc. routines which are used by the various functions to handle strings
|
* Misc. routines which are used by the various functions to handle strings
|
||||||
* and memory allocation and pretty much anything else we can think of. Also,
|
* and memory allocation and pretty much anything else we can think of. Also,
|
||||||
@@ -21,11 +21,8 @@
|
|||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "tinyproxy.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <sysexits.h>
|
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
#include "conns.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@@ -173,7 +170,7 @@ int create_file_safely(const char *filename)
|
|||||||
* existing", exit.
|
* existing", exit.
|
||||||
*/
|
*/
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
log_message(LOG_ERR, "Error checking PID file %s: %s.",
|
log_message(LOG_ERR, "create_file_safely: Error checking PID file %s: %s.",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -184,7 +181,7 @@ int create_file_safely(const char *filename)
|
|||||||
* and open()
|
* and open()
|
||||||
*/
|
*/
|
||||||
if ((fildes = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
|
if ((fildes = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
|
||||||
log_message(LOG_ERR, "Could not create PID file %s: %s.",
|
log_message(LOG_ERR, "create_file_safely: Could not create PID file %s: %s.",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -195,7 +192,7 @@ int create_file_safely(const char *filename)
|
|||||||
* Open an existing file.
|
* Open an existing file.
|
||||||
*/
|
*/
|
||||||
if ((fildes = open(filename, O_RDWR)) < 0) {
|
if ((fildes = open(filename, O_RDWR)) < 0) {
|
||||||
log_message(LOG_ERR, "Could not open PID file %s: %s.",
|
log_message(LOG_ERR, "create_file_safely: Could not open PID file %s: %s.",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -208,7 +205,7 @@ int create_file_safely(const char *filename)
|
|||||||
|| lstatinfo.st_mode != fstatinfo.st_mode
|
|| lstatinfo.st_mode != fstatinfo.st_mode
|
||||||
|| lstatinfo.st_ino != fstatinfo.st_ino
|
|| lstatinfo.st_ino != fstatinfo.st_ino
|
||||||
|| lstatinfo.st_dev != fstatinfo.st_dev) {
|
|| lstatinfo.st_dev != fstatinfo.st_dev) {
|
||||||
log_message(LOG_ERR, "The PID file %s has been changed before it could be opened.",
|
log_message(LOG_ERR, "create_file_safely: The PID file %s has been changed before it could be opened.",
|
||||||
filename);
|
filename);
|
||||||
close(fildes);
|
close(fildes);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -222,7 +219,7 @@ int create_file_safely(const char *filename)
|
|||||||
* st_mode check would also find this)
|
* st_mode check would also find this)
|
||||||
*/
|
*/
|
||||||
if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) {
|
if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) {
|
||||||
log_message(LOG_ERR, "The PID file %s has too many links, or is not a regular file: %s.",
|
log_message(LOG_ERR, "create_file_safely: The PID file %s has too many links, or is not a regular file: %s.",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
close(fildes);
|
close(fildes);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -241,7 +238,7 @@ int create_file_safely(const char *filename)
|
|||||||
#else
|
#else
|
||||||
close(fildes);
|
close(fildes);
|
||||||
if ((fildes = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
|
if ((fildes = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
|
||||||
log_message(LOG_ERR, "Could not open PID file %s: %s.",
|
log_message(LOG_ERR, "create_file_safely: Could not open PID file %s: %s.",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -269,7 +266,7 @@ void pidfile_create(const char *filename)
|
|||||||
* Open a stdio file over the low-level one.
|
* Open a stdio file over the low-level one.
|
||||||
*/
|
*/
|
||||||
if ((fd = fdopen(fildes, "w")) == NULL) {
|
if ((fd = fdopen(fildes, "w")) == NULL) {
|
||||||
log_message(LOG_ERR, "fdopen() error on PID file %s: %s.",
|
log_message(LOG_ERR, "pidfile_create: fdopen() error on PID file %s: %s.",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
close(fildes);
|
close(fildes);
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
|
|||||||
+3
-1
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: utils.h,v 1.9 2001-09-15 21:29:59 rjkaes Exp $
|
/* $Id: utils.h,v 1.10 2001-10-25 16:58:50 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'utils.h' for a detailed description.
|
* See 'utils.h' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "tinyproxy.h"
|
||||||
|
|
||||||
|
#include "conns.h"
|
||||||
|
|
||||||
extern int send_http_message(struct conn_s* connptr, int http_code,
|
extern int send_http_message(struct conn_s* connptr, int http_code,
|
||||||
const char *error_title, const char *message);
|
const char *error_title, const char *message);
|
||||||
extern int httperr(struct conn_s *connptr, int err, const char *msg);
|
extern int httperr(struct conn_s *connptr, int err, const char *msg);
|
||||||
|
|||||||
Reference in new issue
Block a user