Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
445decf6a8 |
No files matched your search
@@ -3,10 +3,7 @@
|
||||
|
||||
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.
|
||||
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!
|
||||
As of 1.3.1, Steven Young will once again be the primary maintainer.
|
||||
|
||||
Please see the ChangeLog for futher details as to who did what. :)
|
||||
|
||||
@@ -1,40 +1,5 @@
|
||||
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. The 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>
|
||||
|
||||
* 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
|
||||
pointer is NULL.
|
||||
(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 TODO
|
||||
EXTRA_DIST = configure acconfig.h aclocal.m4 acinclude.m4
|
||||
SUBDIRS = src doc
|
||||
@@ -1,20 +1,3 @@
|
||||
Thursday, October 25, 2001
|
||||
--------------------------
|
||||
|
||||
This version (1.4.3pre7) should be the last release before I make a
|
||||
full 1.4.3 release of tinyproxy. So, assuming no one reports any
|
||||
problems with 1.4.3pre7 it will become 1.4.3 with no changes.
|
||||
|
||||
For more information as what has been worked on, look at the
|
||||
ChangeLog. As you can tell, I don't keep this "NEWS" file very up to
|
||||
date. All the real logging of information happens in the ChangeLog
|
||||
file since I update it as I work on the code. Here on the other hand,
|
||||
I have to remember what I've done. Not near as seamless. (Maybe I
|
||||
should get somebody else to write the NEWS file...)
|
||||
|
||||
-- Robert
|
||||
|
||||
|
||||
Tuesday, September 4, 2001
|
||||
--------------------------
|
||||
|
||||
@@ -26,3 +9,18 @@ string problem with the syslog feature. This problem doesn't affect
|
||||
you if you use the log file instead.
|
||||
|
||||
-- Robert
|
||||
|
||||
|
||||
Thursday, August 30, 2001
|
||||
-------------------------
|
||||
|
||||
Maybe I just shouldn't be working on the code base this week. The
|
||||
memory fix I added in the last release contained a serious bug which
|
||||
would cause a segmentation fault. I actually fixed this by removing
|
||||
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
|
||||
@@ -19,14 +19,9 @@
|
||||
------------
|
||||
|
||||
To install this package under a Unix derivative, read the INSTALL
|
||||
file. tinyproxy uses a standard GNU configure script (basically you
|
||||
should be able to do:
|
||||
|
||||
./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:
|
||||
file. tinyproxy uses a standard GNU configure script. There are
|
||||
additional command line arguments you can supply to configure. They
|
||||
include:
|
||||
|
||||
--enable-debug If you would like to turn on full
|
||||
debugging support
|
||||
@@ -40,10 +35,6 @@
|
||||
--enable-tunnel Provides the option of having
|
||||
tinyproxy act as TCP tunnel, rather
|
||||
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.
|
||||
--with-stathost=HOST Set the default name of the stats host
|
||||
@@ -55,38 +46,28 @@
|
||||
directory. This will send an email to the authors reporting your
|
||||
version, and a few bits of information concerning the memory usage of
|
||||
tinyproxy. Alternatively, you could just send an email stating the
|
||||
version, whichever you prefer.
|
||||
version. Which ever you prefer.
|
||||
|
||||
|
||||
SUPPORT
|
||||
-------
|
||||
|
||||
If you are having problems with tinyproxy, please report the problem
|
||||
to either:
|
||||
to:
|
||||
|
||||
Robert James Kaes <rjkaes@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)
|
||||
and include a copy of the log file, and any assert errors reported by
|
||||
tinyproxy. Note that tinyproxy will output memory statistics to
|
||||
standard error if compiled with debugging support so you might want
|
||||
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:
|
||||
tinyproxy. 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) run -c location_of_tinyproxy_conf -d 2>/dev/null
|
||||
(gdb) set args -c location_of_tinyproxy_conf -d
|
||||
(gdb) run
|
||||
|
||||
Now access the port tinyproxy is on until you receive a break in the
|
||||
gdb. You can now type:
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
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.
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
dnl $Id: configure.in,v 1.33 2001-10-25 05:13:46 rjkaes Exp $
|
||||
dnl $Id: configure.in,v 1.32 2001-10-22 21:30:18 rjkaes Exp $
|
||||
|
||||
dnl Devlopers, please strive to achieve this order:
|
||||
dnl
|
||||
@@ -19,7 +19,7 @@ AC_INIT()
|
||||
AC_CANONICAL_SYSTEM
|
||||
AC_DEFINE_UNQUOTED(TARGET_SYSTEM, "$target")
|
||||
|
||||
AM_INIT_AUTOMAKE(tinyproxy,1.4.3pre7)
|
||||
AM_INIT_AUTOMAKE(tinyproxy,1.4.3pre6)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
dnl
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
EXTRA_DIST = tinyproxy.8 tinyproxy.conf HTTP_ERROR_CODES RFC_INFO report.sh
|
||||
EXTRA_DIST = tinyproxy.8 tinyproxy.conf HTTP_ERROR_CODES RFC_INFO TODO report.sh
|
||||
man_MANS = tinyproxy.8
|
||||
@@ -0,0 +1,25 @@
|
||||
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: "
|
||||
uname -a
|
||||
echo "ps: "
|
||||
ps -auxw | grep '[t]inyproxy' -
|
||||
ps -auxw | grep [t]inyproxy -
|
||||
echo "ver: "
|
||||
if [ -x /usr/local/bin/tinyproxy ]; then
|
||||
/usr/local/bin/tinyproxy -v
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile.am,v 1.6 2001-10-25 16:58:50 rjkaes Exp $
|
||||
# $Id: Makefile.am,v 1.5 2001-10-01 04:01:10 rjkaes Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
@@ -21,7 +21,6 @@ LDFLAGS = @LDFLAGS@
|
||||
bin_PROGRAMS = tinyproxy
|
||||
|
||||
tinyproxy_SOURCES = \
|
||||
conns.c conns.h \
|
||||
buffer.c buffer.h \
|
||||
dnscache.c dnscache.h \
|
||||
log.c log.h \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: acl.c,v 1.9 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: acl.c,v 1.8 2001-09-15 21:21:01 rjkaes Exp $
|
||||
*
|
||||
* 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
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "tinyproxy.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "acl.h"
|
||||
#include "log.h"
|
||||
#include "sock.h"
|
||||
|
||||
+10
-2
@@ -1,4 +1,4 @@
|
||||
/* $Id: anonymous.c,v 1.7 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: anonymous.c,v 1.6 2001-08-26 21:07:27 rjkaes Exp $
|
||||
*
|
||||
* 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
|
||||
@@ -18,7 +18,15 @@
|
||||
* General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "tinyproxy.h"
|
||||
#ifdef HAVE_CONFIG_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 "log.h"
|
||||
|
||||
+12
-9
@@ -1,4 +1,4 @@
|
||||
/* $Id: buffer.c,v 1.14 2001-10-25 04:39:10 rjkaes Exp $
|
||||
/* $Id: buffer.c,v 1.12 2001-10-18 21:45:54 rjkaes Exp $
|
||||
*
|
||||
* 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,
|
||||
@@ -182,7 +182,6 @@ static struct bufline_s *remove_from_buffer(struct buffer_s *buffptr)
|
||||
* Reads the bytes from the socket, and adds them to the buffer.
|
||||
* 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 bytesin;
|
||||
@@ -192,14 +191,14 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
||||
assert(fd >= 0);
|
||||
assert(buffptr != NULL);
|
||||
|
||||
if (buffer_size(buffptr) >= READ_BUFFER_SIZE)
|
||||
if (buffer_size(buffptr) >= MAXBUFFSIZE)
|
||||
return 0;
|
||||
|
||||
buffer = safemalloc(READ_BUFFER_SIZE);
|
||||
buffer = safemalloc(MAXBUFFSIZE);
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
bytesin = read(fd, buffer, READ_BUFFER_SIZE - buffer_size(buffptr));
|
||||
bytesin = read(fd, buffer, MAXBUFFSIZE - buffer_size(buffptr));
|
||||
|
||||
if (bytesin > 0) {
|
||||
newbuffer = saferealloc(buffer, bytesin);
|
||||
@@ -209,7 +208,6 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
||||
}
|
||||
|
||||
if (add_to_buffer(buffptr, newbuffer, bytesin) < 0) {
|
||||
log_message(LOG_ERR, "readbuff: add_to_buffer() error.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -231,7 +229,8 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
||||
safefree(buffer);
|
||||
return 0;
|
||||
default:
|
||||
log_message(LOG_ERR, "readbuff: recv() error \"%s\" on file descriptor %d", strerror(errno), fd);
|
||||
log_message(LOG_ERR, "recv error (fd %d: %s:%d) in 'readbuff'.",
|
||||
fd, strerror(errno), errno);
|
||||
safefree(buffer);
|
||||
return -1;
|
||||
}
|
||||
@@ -276,10 +275,14 @@ ssize_t writebuff(int fd, struct buffer_s *buffptr)
|
||||
return 0;
|
||||
case ENOBUFS:
|
||||
case ENOMEM:
|
||||
log_message(LOG_ERR, "writebuff: write() error [NOBUFS/NOMEM] \"%s\" on file descriptor %d", strerror(errno), fd);
|
||||
log_message(LOG_ERR,
|
||||
"write error [NOBUFS/NOMEM] (%s) in 'writebuff'.",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
default:
|
||||
log_message(LOG_ERR, "writebuff: write() error \"%s\" on file descriptor %d", strerror(errno), fd);
|
||||
log_message(LOG_ERR,
|
||||
"write error (fd %d: %s:%d) in 'writebuff'.",
|
||||
fd, strerror(errno), errno);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
/* $Id: conns.c,v 1.3 2001-10-25 16:58:09 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;
|
||||
|
||||
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);
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
/* $Id: conns.h,v 1.3 2001-10-25 16:58: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;
|
||||
};
|
||||
|
||||
/*
|
||||
* 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
|
||||
+9
-2
@@ -1,4 +1,4 @@
|
||||
/* $Id: dnscache.c,v 1.17 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: dnscache.c,v 1.16 2001-09-12 03:32:24 rjkaes Exp $
|
||||
*
|
||||
* 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
|
||||
@@ -20,7 +20,14 @@
|
||||
* General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "tinyproxy.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "dnscache.h"
|
||||
#include "log.h"
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
/* $Id: dnscache.h,v 1.7 2001-10-25 17:02:50 rjkaes Exp $
|
||||
/* $Id: dnscache.h,v 1.6 2001-10-18 03:44:06 rjkaes Exp $
|
||||
*
|
||||
* See 'dnscache.c' for a detailed description.
|
||||
*
|
||||
@@ -18,7 +18,8 @@
|
||||
#ifndef _TINYPROXY_DNSCACHE_H_
|
||||
#define _TINYPROXY_DNSCACHE_H_
|
||||
|
||||
#include "tinyproxy.h"
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
extern int dnscache(struct in_addr *addr, char *domain);
|
||||
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
/* $Id: filter.c,v 1.7 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: filter.c,v 1.6 2001-09-12 03:32:54 rjkaes Exp $
|
||||
*
|
||||
* Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca)
|
||||
*
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
#include "tinyproxy.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <sysexits.h>
|
||||
|
||||
#include "filter.h"
|
||||
#include "regexp.h"
|
||||
#include "utils.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: log.c,v 1.15 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: log.c,v 1.14 2001-09-04 16:50:22 rjkaes Exp $
|
||||
*
|
||||
* Logs the various messages which tinyproxy produces to either a log file or
|
||||
* the syslog daemon. Not much to it...
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "tinyproxy.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "log.h"
|
||||
|
||||
static char *syslog_level[] = {
|
||||
|
||||
+65
-48
@@ -1,4 +1,4 @@
|
||||
/* $Id: reqs.c,v 1.35 2001-10-25 16:58:50 rjkaes Exp $
|
||||
/* $Id: reqs.c,v 1.31 2001-10-22 16:08:29 rjkaes Exp $
|
||||
*
|
||||
* This is where all the work in tinyproxy is actually done. Incoming
|
||||
* connections have a new thread created for them. The thread then
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "acl.h"
|
||||
#include "anonymous.h"
|
||||
#include "buffer.h"
|
||||
#include "conns.h"
|
||||
#include "filter.h"
|
||||
#include "log.h"
|
||||
#include "regexp.h"
|
||||
@@ -82,7 +81,7 @@ static char *read_request_line(struct conn_s *connptr)
|
||||
|
||||
len = readline(connptr->client_fd, request_buffer, LINE_LENGTH);
|
||||
if (len <= 0) {
|
||||
log_message(LOG_ERR, "read_request_line: Client (file descriptor: %d) closed socket before read.", connptr->client_fd);
|
||||
log_message(LOG_ERR, "Client (file descriptor: %d) closed socket before read.", connptr->client_fd);
|
||||
safefree(request_buffer);
|
||||
return NULL;
|
||||
}
|
||||
@@ -149,7 +148,7 @@ static int extract_http_url(const char *url, struct request_s *request)
|
||||
request->port = 80;
|
||||
strcpy(request->path, "/");
|
||||
} else {
|
||||
log_message(LOG_ERR, "extract_http_url: Can't parse URL.");
|
||||
log_message(LOG_ERR, "Can't parse URL.");
|
||||
|
||||
safefree(request->host);
|
||||
safefree(request->path);
|
||||
@@ -174,7 +173,7 @@ static int extract_ssl_url(const char *url, struct request_s *request)
|
||||
else if (sscanf(url, "%s", request->host) == 1)
|
||||
request->port = 443;
|
||||
else {
|
||||
log_message(LOG_ERR, "extract_ssl_url: Can't parse URL.");
|
||||
log_message(LOG_ERR, "Can't parse URL.");
|
||||
|
||||
safefree(request->host);
|
||||
return -1;
|
||||
@@ -282,7 +281,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
||||
|
||||
ret = sscanf(request_line, "%[^ ] %[^ ] %[^ ]", request->method, url, request->protocol);
|
||||
if (ret < 2) {
|
||||
log_message(LOG_ERR, "process_request: Bad Request on file descriptor %d", connptr->client_fd);
|
||||
log_message(LOG_ERR, "Bad Request on file descriptor %d", connptr->client_fd);
|
||||
httperr(connptr, 400, "Bad Request. No request found.");
|
||||
|
||||
safefree(url);
|
||||
@@ -294,7 +293,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
||||
}
|
||||
|
||||
if (!url) {
|
||||
log_message(LOG_ERR, "process_request: Null URL on file descriptor %d", connptr->client_fd);
|
||||
log_message(LOG_ERR, "Null URL on file descriptor %d", connptr->client_fd);
|
||||
httperr(connptr, 400, "Bad Request. Null URL.");
|
||||
|
||||
safefree(url);
|
||||
@@ -327,7 +326,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
||||
}
|
||||
connptr->ssl = TRUE;
|
||||
} else {
|
||||
log_message(LOG_ERR, "process_request: Unknown URL type on file descriptor %d", connptr->client_fd);
|
||||
log_message(LOG_ERR, "Unknown URL type on file descriptor %d", connptr->client_fd);
|
||||
httperr(connptr, 400, "Bad Request. Unknown URL type.");
|
||||
|
||||
safefree(url);
|
||||
@@ -346,7 +345,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
||||
if (filter_url(request->host)) {
|
||||
update_stats(STAT_DENIED);
|
||||
|
||||
log_message(LOG_NOTICE, "Proxying refused on filtered domain \"%s\"", request->host);
|
||||
log_message(LOG_ERR, "Proxying refused on filtered domain \"%s\"", request->host);
|
||||
httperr(connptr, 404, "Connection to filtered domain is now allowed.");
|
||||
|
||||
free_request_struct(request);
|
||||
@@ -360,7 +359,7 @@ static struct request_s *process_request(struct conn_s *connptr,
|
||||
* Check to see if they're requesting the stat host
|
||||
*/
|
||||
if (config.stathost && strcmp(config.stathost, request->host) == 0) {
|
||||
log_message(LOG_NOTICE, "Request for the stathost.");
|
||||
log_message(LOG_NOTICE, "tinyproxy stathost request.");
|
||||
|
||||
free_request_struct(request);
|
||||
|
||||
@@ -493,10 +492,9 @@ static int process_client_headers(struct conn_s *connptr)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Don't send any of the headers if we're in SSL mode and
|
||||
* NOT using an upstream proxy.
|
||||
* Don't send any of the headers if we're in SSL mode.
|
||||
*/
|
||||
if (connptr->ssl && !connptr->upstream)
|
||||
if (connptr->ssl)
|
||||
continue;
|
||||
|
||||
/*
|
||||
@@ -525,7 +523,7 @@ static int process_client_headers(struct conn_s *connptr)
|
||||
}
|
||||
}
|
||||
|
||||
if (!connptr->send_message && (connptr->upstream || !connptr->ssl)) {
|
||||
if (!connptr->send_message && !connptr->ssl) {
|
||||
#ifdef XTINYPROXY_ENABLE
|
||||
if (config.my_domain
|
||||
&& add_xtinyproxy_header(connptr) < 0) {
|
||||
@@ -640,7 +638,7 @@ static void relay_connection(struct conn_s *connptr)
|
||||
continue;
|
||||
}
|
||||
} else if (ret < 0) {
|
||||
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);
|
||||
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);
|
||||
return;
|
||||
} else {
|
||||
/*
|
||||
@@ -651,19 +649,21 @@ static void relay_connection(struct conn_s *connptr)
|
||||
|
||||
if (FD_ISSET(connptr->server_fd, &rset)
|
||||
&& readbuff(connptr->server_fd, connptr->sbuffer) < 0) {
|
||||
shutdown(connptr->server_fd, SHUT_WR);
|
||||
break;
|
||||
}
|
||||
if (FD_ISSET(connptr->client_fd, &rset)
|
||||
&& readbuff(connptr->client_fd, connptr->cbuffer) < 0) {
|
||||
break;
|
||||
return;
|
||||
}
|
||||
if (FD_ISSET(connptr->server_fd, &wset)
|
||||
&& writebuff(connptr->server_fd, connptr->cbuffer) < 0) {
|
||||
shutdown(connptr->server_fd, SHUT_WR);
|
||||
break;
|
||||
}
|
||||
if (FD_ISSET(connptr->client_fd, &wset)
|
||||
&& writebuff(connptr->client_fd, connptr->sbuffer) < 0) {
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,21 +674,43 @@ static void relay_connection(struct conn_s *connptr)
|
||||
socket_blocking(connptr->client_fd);
|
||||
while (buffer_size(connptr->sbuffer) > 0) {
|
||||
if (writebuff(connptr->client_fd, connptr->sbuffer) < 0)
|
||||
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
|
||||
/*
|
||||
* Establish a connection to the upstream proxy server.
|
||||
@@ -696,7 +718,7 @@ static void relay_connection(struct conn_s *connptr)
|
||||
static int connect_to_upstream(struct conn_s *connptr,
|
||||
struct request_s *request)
|
||||
{
|
||||
char *combined_string;
|
||||
char *combined_host_path;
|
||||
int len;
|
||||
|
||||
connptr->server_fd = opensock(config.upstream_name, config.upstream_port);
|
||||
@@ -709,32 +731,29 @@ 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);
|
||||
|
||||
/*
|
||||
* We need to re-write the "path" part of the request so that we
|
||||
* can reuse the establish_http_connection() function. It expects a
|
||||
* method and path.
|
||||
*/
|
||||
if (connptr->ssl) {
|
||||
len = strlen(request->host) + 6;
|
||||
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);
|
||||
|
||||
combined_string = safemalloc(len + 1);
|
||||
if (!combined_string) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
snprintf(combined_string, len, "%s:%d", request->host, request->port);
|
||||
} else {
|
||||
/*
|
||||
* Since we're going to use the establish_http_connection() function
|
||||
* we need to rebuild the "path" by combining the host, port, and
|
||||
* path so we can use the common send functions.
|
||||
*/
|
||||
len = strlen(request->host) + strlen(request->path) + 14;
|
||||
combined_string = safemalloc(len + 1);
|
||||
if (!combined_string) {
|
||||
combined_host_path = safemalloc(len + 1);
|
||||
if (!combined_host_path) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(combined_string, len, "http://%s:%d%s", request->host, request->port, request->path);
|
||||
}
|
||||
snprintf(combined_host_path, len, "http://%s:%d%s", request->host, request->port, request->path);
|
||||
|
||||
safefree(request->path);
|
||||
request->path = combined_string;
|
||||
request->path = combined_host_path;
|
||||
|
||||
return establish_http_connection(connptr, request);
|
||||
}
|
||||
@@ -830,8 +849,6 @@ internal_proxy:
|
||||
|
||||
#ifdef UPSTREAM_SUPPORT
|
||||
if (config.upstream_name && config.upstream_port != -1) {
|
||||
connptr->upstream = TRUE;
|
||||
|
||||
if (connect_to_upstream(connptr, request) < 0)
|
||||
goto send_error;
|
||||
} else {
|
||||
@@ -868,7 +885,7 @@ send_error:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!connptr->ssl || connptr->upstream) {
|
||||
if (!connptr->ssl || config.upstream_name) {
|
||||
if (process_server_headers(connptr) < 0) {
|
||||
update_stats(STAT_BADCONN);
|
||||
destroy_conn(connptr);
|
||||
@@ -876,7 +893,7 @@ send_error:
|
||||
}
|
||||
} else {
|
||||
if (send_ssl_response(connptr) < 0) {
|
||||
log_message(LOG_ERR, "handle_connection: Could not send SSL greeting to client.");
|
||||
log_message(LOG_ERR, "Could not send SSL greeting to client.");
|
||||
update_stats(STAT_BADCONN);
|
||||
destroy_conn(connptr);
|
||||
return;
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
/* $Id: scanner.l,v 1.6 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: scanner.l,v 1.5 2001-09-16 20:08:24 rjkaes Exp $
|
||||
*
|
||||
* 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
|
||||
@@ -19,8 +19,9 @@
|
||||
%{
|
||||
|
||||
#include "tinyproxy.h"
|
||||
|
||||
#include "grammar.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct keyword {
|
||||
char *kw_name;
|
||||
|
||||
+8
-20
@@ -1,4 +1,4 @@
|
||||
/* $Id: sock.c,v 1.14 2001-10-25 05:10:32 rjkaes Exp $
|
||||
/* $Id: sock.c,v 1.10 2001-10-22 16:52:34 rjkaes Exp $
|
||||
*
|
||||
* 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
|
||||
@@ -66,19 +66,19 @@ int opensock(char *ip_addr, uint16_t port)
|
||||
ret = dnscache(&port_info.sin_addr, ip_addr);
|
||||
|
||||
if (ret < 0) {
|
||||
log_message(LOG_ERR, "opensock: Could not lookup address \"%s\".", ip_addr);
|
||||
log_message(LOG_ERR, "Could not lookup address [%s].", ip_addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
port_info.sin_port = htons(port);
|
||||
|
||||
if ((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||
log_message(LOG_ERR, "opensock: socket() error \"%s\".", strerror(errno));
|
||||
log_message(LOG_ERR, "Could not create socket because of '%s'.", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (connect(sock_fd, (struct sockaddr*)&port_info, sizeof(port_info)) < 0) {
|
||||
log_message(LOG_ERR, "opensock: connect() error \"%s\".", strerror(errno));
|
||||
log_message(LOG_ERR, "Could not connect socket because of '%s'", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -160,13 +160,9 @@ char *getpeer_ip(int fd, char *ipaddr)
|
||||
assert(fd >= 0);
|
||||
assert(ipaddr != NULL);
|
||||
|
||||
/*
|
||||
* Make sure the user's buffer is initialized to an empty string.
|
||||
*/
|
||||
*ipaddr = '\0';
|
||||
|
||||
if (getpeername(fd, (struct sockaddr*)&name, &namelen) != 0) {
|
||||
log_message(LOG_ERR, "getpeer_ip: getpeername() error \"%s\".", strerror(errno));
|
||||
log_message(LOG_ERR, "geetpeer_ip: 'could not get peer name' (\"%s\": %d)", strerror(errno), errno);
|
||||
*ipaddr = '\0';
|
||||
} else {
|
||||
strlcpy(ipaddr,
|
||||
inet_ntoa(*(struct in_addr*)&name.sin_addr.s_addr),
|
||||
@@ -189,13 +185,9 @@ char *getpeer_string(int fd, char *string)
|
||||
assert(fd >= 0);
|
||||
assert(string != NULL);
|
||||
|
||||
/*
|
||||
* Make sure the user's buffer is initialized to an empty string.
|
||||
*/
|
||||
*string = '\0';
|
||||
|
||||
if (getpeername(fd, (struct sockaddr *)&name, &namelen) != 0) {
|
||||
log_message(LOG_ERR, "getpeer_string: getpeername() error \"%s\".", strerror(errno));
|
||||
log_message(LOG_ERR, "getpeer_string: 'could not get peer name' (\"%s\": %d)", strerror(errno), errno);
|
||||
*string = '\0';
|
||||
} else {
|
||||
LOCK();
|
||||
peername = gethostbyaddr((char *)&name.sin_addr.s_addr,
|
||||
@@ -203,9 +195,6 @@ char *getpeer_string(int fd, char *string)
|
||||
AF_INET);
|
||||
if (peername)
|
||||
strlcpy(string, peername->h_name, PEER_STRING_LENGTH);
|
||||
else
|
||||
log_message(LOG_ERR, "getpeer_string: gethostbyaddr() error \"%s\".", hstrerror(h_errno));
|
||||
|
||||
UNLOCK();
|
||||
}
|
||||
|
||||
@@ -277,6 +266,5 @@ ssize_t readline(int fd, char *ptr, size_t maxlen)
|
||||
|
||||
/* Tack a NIL to the end to make is a standard "C" string */
|
||||
*ptr = '\0';
|
||||
|
||||
return (ssize_t)n;
|
||||
}
|
||||
+4
-2
@@ -1,4 +1,4 @@
|
||||
/* $Id: sock.h,v 1.6 2001-10-25 17:02:50 rjkaes Exp $
|
||||
/* $Id: sock.h,v 1.5 2001-09-16 20:11:07 rjkaes Exp $
|
||||
*
|
||||
* See 'sock.c' for a detailed description.
|
||||
*
|
||||
@@ -19,7 +19,9 @@
|
||||
#ifndef TINYPROXY_SOCK_H
|
||||
#define TINYPROXY_SOCK_H
|
||||
|
||||
#include "tinyproxy.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#define PEER_IP_LENGTH 16
|
||||
#define PEER_STRING_LENGTH 256
|
||||
|
||||
+1
-3
@@ -1,4 +1,4 @@
|
||||
/* $Id: stats.h,v 1.3 2001-10-25 16:58:50 rjkaes Exp $
|
||||
/* $Id: stats.h,v 1.2 2001-09-16 20:11:24 rjkaes Exp $
|
||||
*
|
||||
* See 'stats.h' for a detailed description.
|
||||
*
|
||||
@@ -18,8 +18,6 @@
|
||||
#ifndef _TINYPROXY_STATS_H_
|
||||
#define _TINYPROXY_STATS_H_
|
||||
|
||||
#include "conns.h"
|
||||
|
||||
/*
|
||||
* Various logable statistics
|
||||
*/
|
||||
|
||||
+14
-2
@@ -1,4 +1,4 @@
|
||||
/* $Id: ternary.c,v 1.11 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: ternary.c,v 1.10 2001-09-08 18:58:02 rjkaes Exp $
|
||||
*
|
||||
* 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
|
||||
@@ -21,10 +21,22 @@
|
||||
* General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "tinyproxy.h"
|
||||
#if defined HAVE_CONFIG_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 "ternary.h"
|
||||
#include "tinyproxy.h"
|
||||
#include "utils.h"
|
||||
|
||||
/*
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
/* $Id: thread.c,v 1.17 2001-10-24 00:37:23 rjkaes Exp $
|
||||
/* $Id: thread.c,v 1.16 2001-09-15 21:28:25 rjkaes Exp $
|
||||
*
|
||||
* Handles the creation/destruction of the various threads required for
|
||||
* processing incoming connections.
|
||||
@@ -196,11 +196,11 @@ short int thread_pool_create(void)
|
||||
pthread_attr_setstacksize(&thread_attr, THREAD_STACK_SIZE);
|
||||
|
||||
if (thread_config.maxclients == 0) {
|
||||
log_message(LOG_ERR, "thread_pool_create: \"MaxClients\" must be greater than zero.");
|
||||
log_message(LOG_ERR, "'MaxClients' must be greater than zero.");
|
||||
return -1;
|
||||
}
|
||||
if (thread_config.startservers == 0) {
|
||||
log_message(LOG_ERR, "thread_pool_create: \"StartServers\" must be greater than zero.");
|
||||
log_message(LOG_ERR, "'StartServers' must be greater than zero.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ short int thread_pool_create(void)
|
||||
return -1;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -1,4 +1,4 @@
|
||||
/* $Id: tinyproxy.c,v 1.18 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: tinyproxy.c,v 1.17 2001-09-16 20:11:54 rjkaes Exp $
|
||||
*
|
||||
* The initialise routine. Basically sets up all the initial stuff (logfile,
|
||||
* listening socket, config options, etc.) and then sits there and loops
|
||||
@@ -24,6 +24,15 @@
|
||||
|
||||
#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 "buffer.h"
|
||||
#include "dnscache.h"
|
||||
|
||||
+10
-12
@@ -1,4 +1,4 @@
|
||||
/* $Id: tinyproxy.h,v 1.19 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: tinyproxy.h,v 1.16 2001-09-16 20:12:29 rjkaes Exp $
|
||||
*
|
||||
* See 'tinyproxy.c' for a detailed description.
|
||||
*
|
||||
@@ -27,9 +27,6 @@
|
||||
* Include standard headers which are used through-out tinyproxy
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
@@ -48,18 +45,12 @@
|
||||
#include <sys/uio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
#include <netdb.h>
|
||||
#ifdef HAVE_PTHREAD_H
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
@@ -69,9 +60,8 @@
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <sysexits.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef SHUT_RD /* these three Posix.1g names are quite new */
|
||||
# define SHUT_RD 0 /* shutdown for reading */
|
||||
@@ -123,6 +113,14 @@ 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 */
|
||||
extern struct config_s config;
|
||||
|
||||
|
||||
+12
-9
@@ -1,4 +1,4 @@
|
||||
/* $Id: utils.c,v 1.16 2001-10-25 17:27:39 rjkaes Exp $
|
||||
/* $Id: utils.c,v 1.13 2001-09-16 20:13:52 rjkaes Exp $
|
||||
*
|
||||
* 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,
|
||||
@@ -21,8 +21,11 @@
|
||||
|
||||
#include "tinyproxy.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <sysexits.h>
|
||||
|
||||
#include "buffer.h"
|
||||
#include "conns.h"
|
||||
#include "log.h"
|
||||
#include "sock.h"
|
||||
#include "utils.h"
|
||||
@@ -170,7 +173,7 @@ int create_file_safely(const char *filename)
|
||||
* existing", exit.
|
||||
*/
|
||||
if (errno != ENOENT) {
|
||||
log_message(LOG_ERR, "create_file_safely: Error checking PID file %s: %s.",
|
||||
log_message(LOG_ERR, "Error checking PID file %s: %s.",
|
||||
filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
@@ -181,7 +184,7 @@ int create_file_safely(const char *filename)
|
||||
* and open()
|
||||
*/
|
||||
if ((fildes = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
|
||||
log_message(LOG_ERR, "create_file_safely: Could not create PID file %s: %s.",
|
||||
log_message(LOG_ERR, "Could not create PID file %s: %s.",
|
||||
filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
@@ -192,7 +195,7 @@ int create_file_safely(const char *filename)
|
||||
* Open an existing file.
|
||||
*/
|
||||
if ((fildes = open(filename, O_RDWR)) < 0) {
|
||||
log_message(LOG_ERR, "create_file_safely: Could not open PID file %s: %s.",
|
||||
log_message(LOG_ERR, "Could not open PID file %s: %s.",
|
||||
filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
@@ -205,7 +208,7 @@ int create_file_safely(const char *filename)
|
||||
|| lstatinfo.st_mode != fstatinfo.st_mode
|
||||
|| lstatinfo.st_ino != fstatinfo.st_ino
|
||||
|| lstatinfo.st_dev != fstatinfo.st_dev) {
|
||||
log_message(LOG_ERR, "create_file_safely: The PID file %s has been changed before it could be opened.",
|
||||
log_message(LOG_ERR, "The PID file %s has been changed before it could be opened.",
|
||||
filename);
|
||||
close(fildes);
|
||||
return -1;
|
||||
@@ -219,7 +222,7 @@ int create_file_safely(const char *filename)
|
||||
* st_mode check would also find this)
|
||||
*/
|
||||
if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) {
|
||||
log_message(LOG_ERR, "create_file_safely: The PID file %s has too many links, or is not a regular file: %s.",
|
||||
log_message(LOG_ERR, "The PID file %s has too many links, or is not a regular file: %s.",
|
||||
filename, strerror(errno));
|
||||
close(fildes);
|
||||
return -1;
|
||||
@@ -238,7 +241,7 @@ int create_file_safely(const char *filename)
|
||||
#else
|
||||
close(fildes);
|
||||
if ((fildes = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
|
||||
log_message(LOG_ERR, "create_file_safely: Could not open PID file %s: %s.",
|
||||
log_message(LOG_ERR, "Could not open PID file %s: %s.",
|
||||
filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
@@ -266,7 +269,7 @@ void pidfile_create(const char *filename)
|
||||
* Open a stdio file over the low-level one.
|
||||
*/
|
||||
if ((fd = fdopen(fildes, "w")) == NULL) {
|
||||
log_message(LOG_ERR, "pidfile_create: fdopen() error on PID file %s: %s.",
|
||||
log_message(LOG_ERR, "fdopen() error on PID file %s: %s.",
|
||||
filename, strerror(errno));
|
||||
close(fildes);
|
||||
unlink(filename);
|
||||
|
||||
+1
-3
@@ -1,4 +1,4 @@
|
||||
/* $Id: utils.h,v 1.10 2001-10-25 16:58:50 rjkaes Exp $
|
||||
/* $Id: utils.h,v 1.9 2001-09-15 21:29:59 rjkaes Exp $
|
||||
*
|
||||
* See 'utils.h' for a detailed description.
|
||||
*
|
||||
@@ -21,8 +21,6 @@
|
||||
|
||||
#include "tinyproxy.h"
|
||||
|
||||
#include "conns.h"
|
||||
|
||||
extern int send_http_message(struct conn_s* connptr, int http_code,
|
||||
const char *error_title, const char *message);
|
||||
extern int httperr(struct conn_s *connptr, int err, const char *msg);
|
||||
|
||||
Reference in new issue
Block a user