[Fixes Bug 996518]

Merged in a patch from Hans-Dieter that fixes a problem with upstream
proxy support.
This commit is contained in:
Robert James Kaes 2004-08-06 16:56:55 +00:00
parent cde61e2fac
commit 385fae593d
4 changed files with 19 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $Id: conns.c,v 1.17 2003-05-31 23:02:21 rjkaes Exp $
/* $Id: conns.c,v 1.17.2.1 2004-08-06 16:56:55 rjkaes Exp $
*
* Create and free the connection structure. One day there could be
* other connection related tasks put here, but for now the header
@ -75,6 +75,8 @@ initialize_conn(int client_fd, const char* ipaddr, const char* string_addr)
connptr->client_ip_addr = safestrdup(ipaddr);
connptr->client_string_addr = safestrdup(string_addr);
connptr->upstream_proxy = NULL;
update_stats(STAT_OPEN);
return connptr;

View File

@ -1,4 +1,4 @@
/* $Id: conns.h,v 1.14 2003-05-04 04:35:10 rjkaes Exp $
/* $Id: conns.h,v 1.14.2.1 2004-08-06 16:56:55 rjkaes Exp $
*
* See 'conns.c' for a detailed description.
*
@ -70,6 +70,10 @@ struct conn_s {
unsigned int major;
unsigned int minor;
} protocol;
/*
* Pointer to upstream proxy.
*/
struct upstream *upstream_proxy;
};
/*

View File

@ -1,4 +1,4 @@
/* $Id: reqs.c,v 1.105.2.1 2003-11-19 19:20:18 rjkaes Exp $
/* $Id: reqs.c,v 1.105.2.2 2004-08-06 16:56:55 rjkaes Exp $
*
* This is where all the work in tinyproxy is actually done. Incoming
* connections have a new child created for them. The child then
@ -1072,7 +1072,7 @@ process_client_headers(struct conn_s *connptr, hashmap_t hashofheaders)
* proxy is in use.)
*/
if (connptr->server_fd == -1 || connptr->show_stats
|| (connptr->connect_method && !UPSTREAM_CONFIGURED())) {
|| (connptr->connect_method && (connptr->upstream_proxy == NULL))) {
log_message(LOG_INFO, "Not sending client headers to remote machine");
return 0;
}
@ -1410,7 +1410,7 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request)
char *combined_string;
int len;
struct upstream *cur_upstream = upstream_get(request->host);
struct upstream *cur_upstream = connptr->upstream_proxy;
if(!cur_upstream) {
log_message(LOG_WARNING,
"No upstream proxy defined for %s.",
@ -1554,7 +1554,8 @@ handle_connection(int fd)
goto send_error;
}
if (UPSTREAM_CONFIGURED() && (UPSTREAM_HOST(request->host) != NULL)) {
connptr->upstream_proxy = UPSTREAM_HOST(request->host);
if (connptr->upstream_proxy != NULL) {
if (connect_to_upstream(connptr, request) < 0) {
goto send_error;
}
@ -1599,7 +1600,7 @@ handle_connection(int fd)
return;
}
if (!connptr->connect_method || UPSTREAM_CONFIGURED()) {
if (!connptr->connect_method || (connptr->upstream_proxy != NULL)) {
if (process_server_headers(connptr) < 0) {
if (connptr->error_variables)
send_http_error_message(connptr);

View File

@ -1,4 +1,4 @@
/* $Id: tinyproxy.h,v 1.41 2003-06-20 17:02:12 rjkaes Exp $
/* $Id: tinyproxy.h,v 1.41.2.1 2004-08-06 16:56:55 rjkaes Exp $
*
* See 'tinyproxy.c' for a detailed description.
*
@ -25,7 +25,10 @@
#define MAXBUFFSIZE ((size_t)(1024 * 96)) /* Max size of buffer */
#define MAX_IDLE_TIME (60 * 10) /* 10 minutes of no activity */
#ifdef UPSTREAM_SUPPORT
/*
* Even if upstream support is not compiled into tinyproxy, this
* structure still needs to be defined.
*/
struct upstream {
struct upstream *next;
char *domain; /* optional */
@ -33,7 +36,6 @@ struct upstream {
int port;
in_addr_t ip, mask;
};
#endif
struct config_s {
char *logf_name;