From 2d9d164034b4179619a4eb7120b39842863e362f Mon Sep 17 00:00:00 2001 From: Robert James Kaes Date: Mon, 11 Sep 2000 23:24:59 +0000 Subject: These files are no longer used within tinyproxy. --- src/config.h | 72 ----------------------- src/conns.c | 187 ----------------------------------------------------------- src/conns.h | 59 ------------------- 3 files changed, 318 deletions(-) delete mode 100644 src/config.h delete mode 100644 src/conns.c delete mode 100644 src/conns.h diff --git a/src/config.h b/src/config.h deleted file mode 100644 index a7a50e6..0000000 --- a/src/config.h +++ /dev/null @@ -1,72 +0,0 @@ -/* $Id: config.h,v 1.3 2000-03-31 20:14:26 rjkaes Exp $ - * - * Contains all the tune-able variables which are used by tinyproxy. - * Modifications made to these variables WILL change the default behaviour - * of tinyproxy. Please read the comments to better understand what each - * variable does. - * - * Copyright (C) 1998 Steven Young - * Copyright (C) 1999 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 _CONFIG_H_ -#define _CONFIG_H_ 1 - -/* - * Define this if you want tinyproxy to use /proc/loadavg to determine - * system load (Linux only, I think) - */ -#define USE_PROC - -#ifndef USE_PROC -/* - * Path to uptime to determin system load. This path doesn't have to be - * valid if DEFAULT_CUTOFFLOAD is 0 - */ -#define UPTIME_PATH "/usr/bin/uptime" -#endif /* !USE_PROC */ - -/* - * The default load at which tinyproxy will start refusing connections. - * 0 == disabled by default - */ -#define DEFAULT_CUTOFFLOAD 0 - -/* - * NOTE: for DEFAULT_STATHOST: this controls remote proxy stats display. - * for example, the default DEFAULT_STATHOST of "tinyproxy.stats" will - * mean that when you use the proxy to access http://tinyproxy.stats/", - * you will be shown the proxy stats. Set this to something obscure - * if you don't want random people to be able to see them, or set it to - * "" to disable. In the future, I figure maybe some sort of auth - * might be desirable, but that would involve a major simplicity - * sacrifice. - */ - -/* The "hostname" for getting tinyproxy stats. "" = disabled by default */ -#define DEFAULT_STATHOST "tinyproxy.stats" - -/* - * NOTE: change these if you know what you're doing - */ -#define SOCK_TIMEOUT 10 -/* Recalculate load avery 30 seconds */ -#define LOAD_RECALCTIMER 30 -/* Default HTTP port */ -#define HTTP_PORT 80 -/* Every time conncoll is called, nuke connections idle for > 60 seconds */ -#define STALECONN_TIME (60 * 15) -/* Every 100 times through run the garbage collection */ -#define GARBCOLL_INTERVAL 10 - -#endif diff --git a/src/conns.c b/src/conns.c deleted file mode 100644 index a96067f..0000000 --- a/src/conns.c +++ /dev/null @@ -1,187 +0,0 @@ -/* $Id: conns.c,v 1.1.1.1 2000-02-16 17:32:22 sdyoung Exp $ - * - * These functions handle the various stages a connection will go through in - * the course of its life in tinyproxy. New connections are initialized and - * added to the linked list of active connections. As these connections are - * completed, they are closed, and the a garbage collection process removes - * them from the list. - * - * Copyright (C) 1998 Steven Young - * Copyright (C) 1999 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. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -extern adns_state adns; - -#include "config.h" -#include "log.h" -#include "utils.h" -#include "conns.h" -#include "buffer.h" -#include "dnscache.h" - -struct conn_s *connections = NULL; - -/* - * Add a new connection to the linked list - */ -struct conn_s *new_conn(int fd) -{ - struct conn_s **rpConnptr = &connections; - struct conn_s *connptr = connections; - struct conn_s *newconn; - - assert(fd >= 0); - - while (connptr) { - rpConnptr = &connptr->next; - connptr = connptr->next; - } - - if (!(newconn = xmalloc(sizeof(struct conn_s)))) { - log("ERROR new_conn: could not allocate memory for conn"); - return NULL; - } - - /* Allocate the new buffer */ - newconn->cbuffer = NULL; - newconn->sbuffer = NULL; - if (!(newconn->cbuffer = new_buffer()) - || !(newconn->sbuffer = new_buffer())) { - log("ERROR new_conn: could not allocate memory for buffer"); - safefree(newconn->cbuffer); - safefree(newconn->sbuffer); - - newconn->next = NULL; - safefree(newconn); - return NULL; - } - - newconn->client_fd = fd; - newconn->server_fd = -1; - newconn->type = NEWCONN; - newconn->inittime = newconn->actiontime = time(NULL); - - newconn->clientheader = newconn->serverheader = FALSE; - newconn->simple_req = FALSE; - - *rpConnptr = newconn; - newconn->next = connptr; - - stats.num_cons++; - - return newconn; -} - -/* - * Delete a connection from the linked list - */ -int del_conn(struct conn_s *delconn) -{ - struct conn_s **rpConnptr = &connections; - struct conn_s *connptr = connections; - - assert(delconn); - - if (delconn->cbuffer) { - delete_buffer(delconn->cbuffer); - delconn->cbuffer = NULL; - } - if (delconn->sbuffer) { - delete_buffer(delconn->sbuffer); - delconn->sbuffer = NULL; - } - - close(delconn->client_fd); - close(delconn->server_fd); - - while (connptr && (connptr != delconn)) { - rpConnptr = &connptr->next; - connptr = connptr->next; - } - - if (connptr == delconn) { - *rpConnptr = delconn->next; - safefree(delconn); - } - - return 0; -} - -/* - * Check for connections that have been idle too long - */ -void conncoll(void) -{ - struct conn_s *connptr = connections; - - while (connptr) { - if ( - (difftime(time(NULL), connptr->actiontime) > - STALECONN_TIME) && connptr->type != FINISHCONN) { - connptr->type = FINISHCONN; - stats.num_idles++; - } - connptr = connptr->next; - } -} - -/* - * Actually remove all entries in the linked list that have been marked for - * deletion. - */ -void garbcoll(void) -{ - struct conn_s *connptr = connections; - struct conn_s *tmp; - - static unsigned int dnscount = 0; - -#ifdef __DEBUG__ - log("Garbage collecting (%lu)", stats.num_garbage); -#endif - - stats.num_garbage++; - - while (connptr) { - tmp = connptr->next; - if (connptr->type == FINISHCONN) { -#ifdef __DEBUG__ - log("Deleting connection: %p", connptr); -#endif - del_conn(connptr); - } - connptr = tmp; - } - - if (dnscount++ > DNS_GARBAGE_COL) { - dnscount = 0; - dnsclean(); - } -} diff --git a/src/conns.h b/src/conns.h deleted file mode 100644 index 05cfdb5..0000000 --- a/src/conns.h +++ /dev/null @@ -1,59 +0,0 @@ -/* $Id: conns.h,v 1.1.1.1 2000-02-16 17:32:22 sdyoung Exp $ - * - * See 'conns.c' for a detailed description. - * - * Copyright (C) 1998 Steven Young - * Copyright (C) 1999 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 _CONN_H_ -#define _CONN_H_ 1 - -#include "tinyproxy.h" - -#include - -/* Different connection types */ -enum conn_type { - NEWCONN, - WAITCONN, - DNS_WAITCONN, - RELAYCONN, - CLOSINGCONN, - FINISHCONN -}; - -struct conn_s { - struct conn_s *next; - int client_fd, server_fd; - enum conn_type type; - struct buffer_s *cbuffer; - struct buffer_s *sbuffer; - time_t inittime, actiontime; - flag clientheader, serverheader; - flag simple_req; - - adns_query adns_qu; - char *domain; - int port_no; -}; - -extern struct conn_s *connections; - -/* Handle the creation and deletion of connections */ -extern struct conn_s *new_conn(int fd); -extern int del_conn(struct conn_s *connptr); -extern void conncoll(void); -extern void garbcoll(void); - -#endif -- cgit v1.2.3