Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6de61b219c |
No files matched your search
@@ -1,22 +1,7 @@
|
||||
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
|
||||
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
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
EXTRA_DIST = TODO
|
||||
EXTRA_DIST = configure acconfig.h aclocal.m4 acinclude.m4 TODO
|
||||
SUBDIRS = src doc
|
||||
@@ -1,35 +1,28 @@
|
||||
Thursday, October 25, 2001
|
||||
--------------------------
|
||||
|
||||
NEWS
|
||||
====
|
||||
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.
|
||||
|
||||
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.
|
||||
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...)
|
||||
|
||||
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.
|
||||
-- Robert
|
||||
|
||||
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.)
|
||||
|
||||
"Thank you" go out to all who have helped find bugs in the 1.4.3
|
||||
candidates. You know who you are, and if you don't look in the ChangeLog
|
||||
for your name. :)
|
||||
Tuesday, September 4, 2001
|
||||
--------------------------
|
||||
|
||||
Robert James Kaes
|
||||
November 21, 2001
|
||||
I finally fixed a problem with the anonymous header code. The searches
|
||||
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
|
||||
@@ -0,0 +1,45 @@
|
||||
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.
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
dnl $Id: configure.in,v 1.35 2001-11-21 19:35:51 rjkaes Exp $
|
||||
dnl $Id: configure.in,v 1.33 2001-10-25 05:13:46 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.3)
|
||||
AM_INIT_AUTOMAKE(tinyproxy,1.4.3pre7)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
dnl
|
||||
@@ -253,7 +253,6 @@ CFLAGS="-O2 $CFLAGS"
|
||||
if test "$enable_debug" = "yes" ; then
|
||||
dnl Add the warnings if we have the GCC compiler
|
||||
if test "$ac_cv_prog_gcc" = "yes" ; then
|
||||
CFLAGS="-pg -fprofile-arcs $CFLAGS"
|
||||
CFLAGS="-Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes $CFLAGS"
|
||||
CFLAGS="-Wmissing-prototypes -Wmissing-declarations $CFLAGS"
|
||||
CFLAGS="-Wpointer-arith -Waggregate-return -Wnested-externs $CFLAGS"
|
||||
|
||||
+1
-5
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile.am,v 1.7 2001-11-05 15:24:01 rjkaes Exp $
|
||||
# $Id: Makefile.am,v 1.6 2001-10-25 16:58:50 rjkaes Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
@@ -46,7 +46,3 @@ EXTRA_tinyproxy_SOURCES = grammar.h
|
||||
|
||||
scanner.c: scanner.l grammar.h
|
||||
$(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.10 2001-11-03 06:08:37 rjkaes Exp $
|
||||
/* $Id: acl.c,v 1.9 2001-10-25 17:27:39 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
|
||||
@@ -77,11 +77,8 @@ int insert_acl(char *location, acl_access_t access_type)
|
||||
/*
|
||||
* First check to see if the location is a string or numeric.
|
||||
*/
|
||||
for (i = 0; location[i] != '\0'; i++) {
|
||||
/*
|
||||
* Numeric strings can not contain letters, so test on it.
|
||||
*/
|
||||
if (isalpha((unsigned char)location[i])) {
|
||||
for (i = 0; i < strlen((char *)location); i++) {
|
||||
if (isdigit((unsigned char)location[i]) != 0 && location[i] != '.') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -102,11 +99,9 @@ int insert_acl(char *location, acl_access_t access_type)
|
||||
|
||||
new_acl_ptr->acl_access = access_type;
|
||||
|
||||
if (location[i] == '\0') {
|
||||
DEBUG2("ACL \"%s\" is a number.", location);
|
||||
|
||||
if (i != strlen(location)) {
|
||||
/*
|
||||
* We did not break early, so this a numeric location.
|
||||
* We did break early, so this a numeric location.
|
||||
* Check for a netmask.
|
||||
*/
|
||||
new_acl_ptr->type = ACL_NUMERIC;
|
||||
@@ -114,7 +109,7 @@ int insert_acl(char *location, acl_access_t access_type)
|
||||
if (nptr) {
|
||||
*nptr++ = '\0';
|
||||
|
||||
new_acl_ptr->netmask = strtol(nptr, NULL, 10);
|
||||
new_acl_ptr->netmask = atoi(nptr);
|
||||
if (new_acl_ptr->netmask < 0 || new_acl_ptr->netmask > 32) {
|
||||
safefree(new_acl_ptr);
|
||||
return -1;
|
||||
@@ -123,8 +118,6 @@ int insert_acl(char *location, acl_access_t access_type)
|
||||
new_acl_ptr->netmask = 32;
|
||||
}
|
||||
} else {
|
||||
DEBUG2("ACL \"%s\" is a string.", location);
|
||||
|
||||
new_acl_ptr->type = ACL_STRING;
|
||||
new_acl_ptr->netmask = 32;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
/* $Id: anonymous.c,v 1.8 2001-11-05 15:24:42 rjkaes Exp $
|
||||
/* $Id: anonymous.c,v 1.7 2001-10-25 17:27:39 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
|
||||
@@ -32,7 +32,7 @@ static TERNARY anonymous_tree = 0;
|
||||
*/
|
||||
static short int anonymous_is_enabled = 0;
|
||||
|
||||
inline short int is_anonymous_enabled(void)
|
||||
short int is_anonymous_enabled(void)
|
||||
{
|
||||
return anonymous_is_enabled;
|
||||
}
|
||||
|
||||
+57
-54
@@ -1,4 +1,4 @@
|
||||
/* $Id: buffer.c,v 1.15 2001-11-05 15:23:05 rjkaes Exp $
|
||||
/* $Id: buffer.c,v 1.14 2001-10-25 04:39:10 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,
|
||||
@@ -27,8 +27,8 @@
|
||||
#include "log.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define BUFFER_HEAD(x) (x)->head
|
||||
#define BUFFER_TAIL(x) (x)->tail
|
||||
#define BUFFER_HEAD(x) (((struct buffer_s *)(x))->head)
|
||||
#define BUFFER_TAIL(x) (((struct buffer_s *)(x))->tail)
|
||||
|
||||
struct bufline_s {
|
||||
unsigned char *string; /* the actual string of data */
|
||||
@@ -37,18 +37,31 @@ struct bufline_s {
|
||||
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
|
||||
* 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.
|
||||
* to the buffer
|
||||
*/
|
||||
static struct bufline_s *makenewline(unsigned char *data, size_t length)
|
||||
{
|
||||
struct bufline_s *newline;
|
||||
|
||||
assert(data != NULL);
|
||||
assert(length > 0);
|
||||
|
||||
if (!(newline = safemalloc(sizeof(struct bufline_s))))
|
||||
return NULL;
|
||||
@@ -56,8 +69,6 @@ static struct bufline_s *makenewline(unsigned char *data, size_t length)
|
||||
newline->string = data;
|
||||
newline->next = NULL;
|
||||
newline->length = length;
|
||||
|
||||
/* Position our "read" pointer at the beginning of the data */
|
||||
newline->pos = 0;
|
||||
|
||||
return newline;
|
||||
@@ -89,13 +100,8 @@ struct buffer_s *new_buffer(void)
|
||||
if (!(buffptr = safemalloc(sizeof(struct buffer_s))))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
buffptr->head = buffptr->tail = NULL;
|
||||
buffptr->size = 0;
|
||||
|
||||
return buffptr;
|
||||
}
|
||||
@@ -114,6 +120,8 @@ void delete_buffer(struct buffer_s *buffptr)
|
||||
free_line(BUFFER_HEAD(buffptr));
|
||||
BUFFER_HEAD(buffptr) = next;
|
||||
}
|
||||
BUFFER_HEAD(buffptr) = NULL;
|
||||
BUFFER_TAIL(buffptr) = NULL;
|
||||
|
||||
safefree(buffptr);
|
||||
}
|
||||
@@ -128,46 +136,43 @@ static int add_to_buffer(struct buffer_s *buffptr, unsigned char *data,
|
||||
|
||||
assert(buffptr != 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)))
|
||||
return -1;
|
||||
|
||||
if (BUFFER_SIZE(buffptr) == 0)
|
||||
if (!BUFFER_HEAD(buffptr) && !BUFFER_TAIL(buffptr))
|
||||
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = newline;
|
||||
else
|
||||
BUFFER_TAIL(buffptr) = (BUFFER_TAIL(buffptr)->next = newline);
|
||||
|
||||
BUFFER_SIZE(buffptr) += length;
|
||||
buffptr->size += length;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the first line from the top of the buffer
|
||||
* Shift a line off the top of the buffer (remove the line from the top of
|
||||
* the buffer)
|
||||
*/
|
||||
static struct bufline_s *remove_from_buffer(struct buffer_s *buffptr)
|
||||
{
|
||||
struct bufline_s *line;
|
||||
|
||||
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);
|
||||
BUFFER_HEAD(buffptr) = line->next;
|
||||
|
||||
if (!BUFFER_HEAD(buffptr))
|
||||
BUFFER_TAIL(buffptr) = NULL;
|
||||
|
||||
buffptr->size -= line->length;
|
||||
|
||||
return line;
|
||||
@@ -187,14 +192,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) >= READ_BUFFER_SIZE)
|
||||
return 0;
|
||||
|
||||
buffer = safemalloc(READ_BUFFER_SIZE);
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
bytesin = read(fd, buffer, READ_BUFFER_SIZE - BUFFER_SIZE(buffptr));
|
||||
bytesin = read(fd, buffer, READ_BUFFER_SIZE - buffer_size(buffptr));
|
||||
|
||||
if (bytesin > 0) {
|
||||
newbuffer = saferealloc(buffer, bytesin);
|
||||
@@ -209,26 +214,26 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
||||
}
|
||||
|
||||
return bytesin;
|
||||
} else {
|
||||
} else if (bytesin == 0) {
|
||||
/* connection was closed by client */
|
||||
safefree(buffer);
|
||||
if (bytesin == 0) {
|
||||
/* connection was closed by client */
|
||||
return -1;
|
||||
} else {
|
||||
switch (errno) {
|
||||
return -1;
|
||||
} else {
|
||||
switch (errno) {
|
||||
#ifdef EWOULDBLOCK
|
||||
case EWOULDBLOCK:
|
||||
case EWOULDBLOCK:
|
||||
#else
|
||||
# ifdef EAGAIN
|
||||
case EAGAIN:
|
||||
case EAGAIN:
|
||||
# endif
|
||||
#endif
|
||||
case EINTR:
|
||||
return 0;
|
||||
default:
|
||||
log_message(LOG_ERR, "readbuff: recv() error \"%s\" on file descriptor %d", strerror(errno), fd);
|
||||
return -1;
|
||||
}
|
||||
case EINTR:
|
||||
safefree(buffer);
|
||||
return 0;
|
||||
default:
|
||||
log_message(LOG_ERR, "readbuff: recv() error \"%s\" on file descriptor %d", strerror(errno), fd);
|
||||
safefree(buffer);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,13 +250,11 @@ ssize_t writebuff(int fd, struct buffer_s *buffptr)
|
||||
assert(fd >= 0);
|
||||
assert(buffptr != NULL);
|
||||
|
||||
if (BUFFER_SIZE(buffptr) == 0)
|
||||
line = BUFFER_HEAD(buffptr);
|
||||
|
||||
if (buffer_size(buffptr) <= 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);
|
||||
|
||||
if (bytessent >= 0) {
|
||||
|
||||
+2
-16
@@ -1,4 +1,4 @@
|
||||
/* $Id: buffer.h,v 1.5 2001-11-05 15:23:05 rjkaes Exp $
|
||||
/* $Id: buffer.h,v 1.4 2001-05-27 02:23:08 rjkaes Exp $
|
||||
*
|
||||
* See 'buffer.c' for a detailed description.
|
||||
*
|
||||
@@ -18,23 +18,9 @@
|
||||
#ifndef _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 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 writebuff(int fd, struct buffer_s *buffptr);
|
||||
|
||||
+1
-3
@@ -1,4 +1,4 @@
|
||||
/* $Id: conns.c,v 1.4 2001-11-21 01:00:08 rjkaes Exp $
|
||||
/* $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
|
||||
@@ -37,8 +37,6 @@ void initialize_conn(struct conn_s *connptr)
|
||||
connptr->ssl = FALSE;
|
||||
connptr->upstream = FALSE;
|
||||
|
||||
connptr->protocol.major = connptr->protocol.minor = 0;
|
||||
|
||||
update_stats(STAT_OPEN);
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -1,4 +1,4 @@
|
||||
/* $Id: conns.h,v 1.4 2001-11-21 01:00:09 rjkaes Exp $
|
||||
/* $Id: conns.h,v 1.3 2001-10-25 16:58:09 rjkaes Exp $
|
||||
*
|
||||
* See 'conns.c' for a detailed description.
|
||||
*
|
||||
@@ -30,10 +30,6 @@ struct conn_s {
|
||||
bool_t ssl;
|
||||
bool_t upstream;
|
||||
bool_t send_message;
|
||||
struct {
|
||||
unsigned short int major;
|
||||
unsigned short int minor;
|
||||
} protocol;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
+10
-67
@@ -1,4 +1,4 @@
|
||||
/* $Id: reqs.c,v 1.39 2001-11-21 19:19:46 rjkaes Exp $
|
||||
/* $Id: reqs.c,v 1.35 2001-10-25 16:58:50 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
|
||||
@@ -368,14 +368,6 @@ static struct request_s *process_request(struct conn_s *connptr,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -454,12 +446,6 @@ static int add_xtinyproxy_header(struct conn_s *connptr)
|
||||
char xtinyproxy[32];
|
||||
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),
|
||||
"X-Tinyproxy: %s\r\n",
|
||||
getpeer_ip(connptr->client_fd, ipaddr));
|
||||
@@ -480,16 +466,10 @@ static int process_client_headers(struct conn_s *connptr)
|
||||
{
|
||||
char *header;
|
||||
long content_length = -1;
|
||||
#if 0
|
||||
short int sent_via_header = 0;
|
||||
#endif
|
||||
|
||||
static char *skipheaders[] = {
|
||||
"proxy-connection",
|
||||
"host",
|
||||
"keep-alive",
|
||||
"proxy-authenticate",
|
||||
"proxy-authorization",
|
||||
"connection"
|
||||
};
|
||||
int i;
|
||||
@@ -500,7 +480,6 @@ static int process_client_headers(struct conn_s *connptr)
|
||||
|
||||
for ( ; ; ) {
|
||||
if (readline(connptr->client_fd, header, LINE_LENGTH) <= 0) {
|
||||
DEBUG2("Client (file descriptor %d) closed connection.", connptr->client_fd);
|
||||
safefree(header);
|
||||
return -1;
|
||||
}
|
||||
@@ -520,26 +499,6 @@ static int process_client_headers(struct conn_s *connptr)
|
||||
if (connptr->ssl && !connptr->upstream)
|
||||
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.
|
||||
*/
|
||||
@@ -560,27 +519,12 @@ static int process_client_headers(struct conn_s *connptr)
|
||||
content_length = atol(content_ptr);
|
||||
}
|
||||
|
||||
if ((connptr->server_fd != -1) && safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
||||
if (safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
||||
safefree(header);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#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
|
||||
if (config.my_domain
|
||||
@@ -590,7 +534,7 @@ static int process_client_headers(struct conn_s *connptr)
|
||||
}
|
||||
#endif /* XTINYPROXY */
|
||||
|
||||
if ((connptr->server_fd != -1) && safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
||||
if (safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
||||
safefree(header);
|
||||
return -1;
|
||||
}
|
||||
@@ -621,7 +565,6 @@ static int process_server_headers(struct conn_s *connptr)
|
||||
|
||||
for ( ; ; ) {
|
||||
if (readline(connptr->server_fd, header, LINE_LENGTH) <= 0) {
|
||||
DEBUG2("Server (file descriptor %d) closed connection.", connptr->server_fd);
|
||||
safefree(header);
|
||||
return -1;
|
||||
}
|
||||
@@ -677,13 +620,13 @@ static void relay_connection(struct conn_s *connptr)
|
||||
tv.tv_sec = config.idletimeout - difftime(time(NULL), last_access);
|
||||
tv.tv_usec = 0;
|
||||
|
||||
if (BUFFER_SIZE(connptr->sbuffer) > 0)
|
||||
if (buffer_size(connptr->sbuffer) > 0)
|
||||
FD_SET(connptr->client_fd, &wset);
|
||||
if (BUFFER_SIZE(connptr->cbuffer) > 0)
|
||||
if (buffer_size(connptr->cbuffer) > 0)
|
||||
FD_SET(connptr->server_fd, &wset);
|
||||
if (BUFFER_SIZE(connptr->sbuffer) < MAXBUFFSIZE)
|
||||
if (buffer_size(connptr->sbuffer) < MAXBUFFSIZE)
|
||||
FD_SET(connptr->server_fd, &rset);
|
||||
if (BUFFER_SIZE(connptr->cbuffer) < MAXBUFFSIZE)
|
||||
if (buffer_size(connptr->cbuffer) < MAXBUFFSIZE)
|
||||
FD_SET(connptr->client_fd, &rset);
|
||||
|
||||
ret = select(maxfd, &rset, &wset, NULL, &tv);
|
||||
@@ -729,7 +672,7 @@ static void relay_connection(struct conn_s *connptr)
|
||||
* remainder to the client and then exit.
|
||||
*/
|
||||
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)
|
||||
break;
|
||||
}
|
||||
@@ -738,7 +681,7 @@ static void relay_connection(struct conn_s *connptr)
|
||||
* Try to send any remaining data to the server if we can.
|
||||
*/
|
||||
socket_blocking(connptr->server_fd);
|
||||
while (BUFFER_SIZE(connptr->cbuffer) > 0) {
|
||||
while (buffer_size(connptr->cbuffer) > 0) {
|
||||
if (writebuff(connptr->client_fd, connptr->cbuffer) < 0)
|
||||
break;
|
||||
}
|
||||
@@ -854,7 +797,7 @@ void handle_connection(int fd)
|
||||
goto internal_proxy;
|
||||
}
|
||||
|
||||
log_message(LOG_INFO, "Established a connection to the tunnel \"%s\" using file descriptor %d.", config.tunnel_name, connptr->server_fd);
|
||||
log_message(LOG_CONN, "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
|
||||
|
||||
+4
-8
@@ -1,4 +1,4 @@
|
||||
/* $Id: sock.c,v 1.15 2001-11-12 21:10:51 rjkaes Exp $
|
||||
/* $Id: sock.c,v 1.14 2001-10-25 05:10:32 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
|
||||
@@ -259,22 +259,18 @@ ssize_t readline(int fd, char *ptr, size_t maxlen)
|
||||
|
||||
for (n = 1; n < maxlen; n++) {
|
||||
again:
|
||||
if ((rc = recv(fd, &c, 1, MSG_NOSIGNAL)) == 1) {
|
||||
if ((rc = read(fd, &c, 1)) == 1) {
|
||||
*ptr++ = c;
|
||||
if (c == '\n')
|
||||
break;
|
||||
} else if (rc == 0) {
|
||||
if (n == 1) {
|
||||
DEBUG2("File_Desc: %d Closed.", fd);
|
||||
if (n == 1)
|
||||
return 0;
|
||||
} else
|
||||
else
|
||||
break;
|
||||
} else {
|
||||
if (errno == EINTR)
|
||||
goto again;
|
||||
|
||||
DEBUG2("File_Desc: %d \"%s\" (%d)", fd, strerror(errno), errno);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user