Add proxy list

This commit is contained in:
Markus Moeller 2020-01-10 14:34:33 +00:00
parent 93e9c156e8
commit d72ad621e5
32 changed files with 680 additions and 519 deletions

View File

@ -72,6 +72,11 @@ The possible keywords and their descriptions are as follows:
The maximum number of seconds of inactivity a connection is The maximum number of seconds of inactivity a connection is
allowed to have before it is closed by Tinyproxy. allowed to have before it is closed by Tinyproxy.
*DeadTime*::
The maximum number of seconds of marking a proxy dead i.e. proxy
won't be used for a new connections by Tinyproxy during the deadtime.
*ErrorFile*:: *ErrorFile*::
This parameter controls which HTML file Tinyproxy returns when a This parameter controls which HTML file Tinyproxy returns when a
@ -153,12 +158,16 @@ The possible keywords and their descriptions are as follows:
rules exist: rules exist:
* 'upstream type host:port' turns proxy upstream support on generally. * 'upstream type host:port' turns proxy upstream support on generally.
host:port can be a list seperated by | e.g. host1:port1|host2:port2.
* 'upstream type user:pass@host:port' does the same, but uses the * 'upstream type user:pass@host:port' does the same, but uses the
supplied credentials for authentication. supplied credentials for authentication. host:port can be a list
seperated by | e.g. host1:port1|host2:port2. Same user:pass will be
used for the list.
* 'upstream type host:port "site_spec"' turns on the upstream proxy * 'upstream type host:port "site_spec"' turns on the upstream proxy
for the sites matching `site_spec`. for the sites matching `site_spec`. host:port can be a list
seperated by | e.g. host1:port1|host2:port2.
`type` can be one of `http`, `socks4`, `socks5`, `none`. `type` can be one of `http`, `socks4`, `socks5`, `none`.
@ -173,6 +182,11 @@ The possible keywords and their descriptions are as follows:
* '.' matches any host with no domain (in 'empty' domain) * '.' matches any host with no domain (in 'empty' domain)
* 'IP/bits' matches network/mask * 'IP/bits' matches network/mask
* 'IP/mask' matches network/mask * 'IP/mask' matches network/mask
* 'regex(<pat>)' matches against basic case senstive regular expression
* 'regexe(<pat>)' matches against extended case senstive regular expression
* 'regexi(<pat>)' matches against basic case insenstive regular expression
* 'regexei(<pat>)' matches against extended case insenstive regular expression
* 'regexie(<pat>)' matches against extended case insenstive regular expression
*MaxClients*:: *MaxClients*::

View File

@ -54,4 +54,3 @@ void base64enc(char *dst, const void* src, size_t count)
} }
*d = 0; *d = 0;
} }

View File

@ -26,4 +26,3 @@
void base64enc (char *dst, const void *src, size_t count); void base64enc (char *dst, const void *src, size_t count);
#endif #endif

View File

@ -37,10 +37,13 @@ ssize_t basicauth_string(const char *user, const char *pass,
{ {
char tmp[256 + 2]; char tmp[256 + 2];
int l; int l;
if (!user || !pass) return -1; if (!user || !pass)
return -1;
l = snprintf (tmp, sizeof tmp, "%s:%s", user, pass); l = snprintf (tmp, sizeof tmp, "%s:%s", user, pass);
if (l < 0 || l >= (ssize_t) sizeof tmp) return 0; if (l < 0 || l >= (ssize_t) sizeof tmp)
if (bufsize < (BASE64ENC_BYTES((unsigned)l) + 1)) return 0; return 0;
if (bufsize < (BASE64ENC_BYTES ((unsigned) l) + 1))
return 0;
base64enc (buf, tmp, l); base64enc (buf, tmp, l);
return BASE64ENC_BYTES (l); return BASE64ENC_BYTES (l);
} }
@ -48,8 +51,7 @@ ssize_t basicauth_string(const char *user, const char *pass,
/* /*
* Add entry to the basicauth list * Add entry to the basicauth list
*/ */
void basicauth_add (vector_t authlist, void basicauth_add (vector_t authlist, const char *user, const char *pass)
const char *user, const char *pass)
{ {
char b[BASE64ENC_BYTES ((256 + 2) - 1) + 1]; char b[BASE64ENC_BYTES ((256 + 2) - 1) + 1];
ssize_t ret; ssize_t ret;
@ -71,8 +73,7 @@ void basicauth_add (vector_t authlist,
return; return;
} }
log_message (LOG_INFO, log_message (LOG_INFO, "Added basic auth user : %s", user);
"Added basic auth user : %s", user);
} }
/* /*
@ -87,7 +88,8 @@ int basicauth_check (vector_t authlist, const char *authstring)
const char *entry; const char *entry;
vl = vector_length (authlist); vl = vector_length (authlist);
if (vl == -EINVAL) return 0; if (vl == -EINVAL)
return 0;
for (i = 0; i < vl; i++) { for (i = 0; i < vl; i++) {
entry = vector_getentry (authlist, i, &el); entry = vector_getentry (authlist, i, &el);

View File

@ -217,7 +217,8 @@ static void child_main (struct child_s *ptr)
ret = socket_nonblocking (*fd); ret = socket_nonblocking (*fd);
if (ret != 0) { if (ret != 0) {
log_message(LOG_ERR, "Failed to set the listening " log_message (LOG_ERR,
"Failed to set the listening "
"socket %d to non-blocking: %s", "socket %d to non-blocking: %s",
fd, strerror (errno)); fd, strerror (errno));
exit (1); exit (1);
@ -539,7 +540,6 @@ void child_kill_children (int sig)
} }
} }
/** /**
* Listen on the various configured interfaces * Listen on the various configured interfaces
*/ */
@ -559,9 +559,7 @@ int child_listening_sockets(vector_t listen_addrs, uint16_t port)
} }
} }
if ((listen_addrs == NULL) || if ((listen_addrs == NULL) || (vector_length (listen_addrs) == 0)) {
(vector_length(listen_addrs) == 0))
{
/* /*
* no Listen directive: * no Listen directive:
* listen on the wildcard address(es) * listen on the wildcard address(es)

View File

@ -80,13 +80,14 @@
#define IPV6MASK "(" IPV6 "(/[[:digit:]]+)?)" #define IPV6MASK "(" IPV6 "(/[[:digit:]]+)?)"
#define BEGIN "^[[:space:]]*" #define BEGIN "^[[:space:]]*"
#define END "[[:space:]]*$" #define END "[[:space:]]*$"
#define PIPE "\\|"
/* /*
* Limit the maximum number of substring matches to a reasonably high * Limit the maximum number of substring matches to a reasonably high
* number. Given the usual structure of the configuration file, sixteen * number. Given the usual structure of the configuration file, sixteen
* substring matches should be plenty. * substring matches should be plenty.
*/ */
#define RE_MAX_MATCHES 16 #define RE_MAX_MATCHES 50
/* /*
* All configuration handling functions are REQUIRED to be defined * All configuration handling functions are REQUIRED to be defined
@ -163,6 +164,7 @@ static HANDLE_FUNC (handle_disableviaheader);
static HANDLE_FUNC (handle_xtinyproxy); static HANDLE_FUNC (handle_xtinyproxy);
#ifdef UPSTREAM_SUPPORT #ifdef UPSTREAM_SUPPORT
static HANDLE_FUNC (handle_deadtime);
static HANDLE_FUNC (handle_upstream); static HANDLE_FUNC (handle_upstream);
static HANDLE_FUNC (handle_upstream_no); static HANDLE_FUNC (handle_upstream_no);
#endif #endif
@ -195,12 +197,10 @@ struct {
} directives[] = { } directives[] = {
/* comments */ /* comments */
{ {
BEGIN "#", handle_nop, NULL BEGIN "#", handle_nop, NULL},
},
/* blank lines */ /* blank lines */
{ {
"^[[:space:]]+$", handle_nop, NULL "^[[:space:]]+$", handle_nop, NULL},
},
/* string arguments */ /* string arguments */
STDCONF ("logfile", STR, handle_logfile), STDCONF ("logfile", STR, handle_logfile),
STDCONF ("pidfile", STR, handle_pidfile), STDCONF ("pidfile", STR, handle_pidfile),
@ -222,6 +222,9 @@ struct {
STDCONF ("startservers", INT, handle_startservers), STDCONF ("startservers", INT, handle_startservers),
STDCONF ("maxrequestsperchild", INT, handle_maxrequestsperchild), STDCONF ("maxrequestsperchild", INT, handle_maxrequestsperchild),
STDCONF ("timeout", INT, handle_timeout), STDCONF ("timeout", INT, handle_timeout),
#ifdef UPSTREAM_SUPPORT
STDCONF ("deadtime", INT, handle_deadtime),
#endif
STDCONF ("connectport", INT, handle_connectport), STDCONF ("connectport", INT, handle_connectport),
/* alphanumeric arguments */ /* alphanumeric arguments */
STDCONF ("user", ALNUM, handle_user), STDCONF ("user", ALNUM, handle_user),
@ -237,7 +240,6 @@ struct {
STDCONF ("basicauth", ALNUM WS ALNUM, handle_basicauth), STDCONF ("basicauth", ALNUM WS ALNUM, handle_basicauth),
STDCONF ("errorfile", INT WS STR, handle_errorfile), STDCONF ("errorfile", INT WS STR, handle_errorfile),
STDCONF ("addheader", STR WS STR, handle_addheader), STDCONF ("addheader", STR WS STR, handle_addheader),
#ifdef FILTER_ENABLE #ifdef FILTER_ENABLE
/* filtering */ /* filtering */
STDCONF ("filter", STR, handle_filter), STDCONF ("filter", STR, handle_filter),
@ -255,15 +257,14 @@ struct {
#endif #endif
#ifdef UPSTREAM_SUPPORT #ifdef UPSTREAM_SUPPORT
{ {
BEGIN "(upstream)" WS "(none)" WS STR END, handle_upstream_no, NULL BEGIN "(upstream)" WS "(none)" WS STR END, handle_upstream_no, NULL},
},
{ {
BEGIN "(upstream)" WS "(http|socks4|socks5)" WS BEGIN "(upstream)" WS "(http|socks4|socks5)" WS
"(" USERNAME /*username*/ ":" PASSWORD /*password*/ "@" ")?" "(" USERNAME /*username */ ":" PASSWORD /*password */ "@"
"(" IP "|" ALNUM ")" ")?"
":" INT "(" WS STR ")?" "(" IP "|" ALNUM ")" ":" INT "(" "(" PIPE "(" IP
END, handle_upstream, NULL "|" ALNUM ")" ":" INT ")+" ")?" "(" WS STR ")?"
}, END, handle_upstream, NULL},
#endif #endif
/* loglevel */ /* loglevel */
STDCONF ("loglevel", "(critical|error|warning|notice|connect|info)", STDCONF ("loglevel", "(critical|error|warning|notice|connect|info)",
@ -272,8 +273,7 @@ struct {
const unsigned int ndirectives = sizeof (directives) / sizeof (directives[0]); const unsigned int ndirectives = sizeof (directives) / sizeof (directives[0]);
static void static void free_added_headers (vector_t add_headers)
free_added_headers (vector_t add_headers)
{ {
ssize_t i; ssize_t i;
@ -288,7 +288,7 @@ free_added_headers (vector_t add_headers)
vector_delete (add_headers); vector_delete (add_headers);
} }
static void free_config (struct config_s *conf) void free_config (struct config_s *conf)
{ {
safefree (conf->config_file); safefree (conf->config_file);
safefree (conf->logf_name); safefree (conf->logf_name);
@ -327,8 +327,7 @@ static void free_config (struct config_s *conf)
* *
* Returns 0 on success; negative upon failure. * Returns 0 on success; negative upon failure.
*/ */
int int config_compile_regex (void)
config_compile_regex (void)
{ {
unsigned int i, r; unsigned int i, r;
@ -356,8 +355,7 @@ config_compile_regex (void)
* Frees pre-compiled regular expressions used by the configuration * Frees pre-compiled regular expressions used by the configuration
* file. This function is registered to be automatically called at exit. * file. This function is registered to be automatically called at exit.
*/ */
static void static void config_free_regex (void)
config_free_regex (void)
{ {
unsigned int i; unsigned int i;
@ -384,7 +382,6 @@ static int check_match (struct config_s *conf, const char *line)
unsigned int i; unsigned int i;
assert (ndirectives > 0); assert (ndirectives > 0);
for (i = 0; i != ndirectives; ++i) { for (i = 0; i != ndirectives; ++i) {
assert (directives[i].cre); assert (directives[i].cre);
if (!regexec if (!regexec
@ -486,7 +483,6 @@ static void initialize_with_defaults (struct config_s *conf,
} }
} }
#ifdef FILTER_ENABLE #ifdef FILTER_ENABLE
if (defaults->filter) { if (defaults->filter) {
conf->filter = safestrdup (defaults->filter); conf->filter = safestrdup (defaults->filter);
@ -521,6 +517,10 @@ static void initialize_with_defaults (struct config_s *conf,
conf->idletimeout = defaults->idletimeout; conf->idletimeout = defaults->idletimeout;
#ifdef UPSTREAM_SUPPORT
conf->deadtime = defaults->deadtime;
#endif
if (defaults->bind_address) { if (defaults->bind_address) {
conf->bind_address = safestrdup (defaults->bind_address); conf->bind_address = safestrdup (defaults->bind_address);
} }
@ -589,6 +589,15 @@ int reload_config_file (const char *config_fname, struct config_s *conf,
MAX_IDLE_TIME); MAX_IDLE_TIME);
conf->idletimeout = MAX_IDLE_TIME; conf->idletimeout = MAX_IDLE_TIME;
} }
#ifdef UPSTREAM_SUPPORT
if (conf->deadtime == 0) {
log_message (LOG_WARNING, "Invalid dead time setting. "
"Only values greater than zero are allowed. "
"Therefore setting idle timeout to %u seconds.",
MAX_DEAD_TIME);
conf->deadtime = MAX_DEAD_TIME;
}
#endif
done: done:
return ret; return ret;
@ -659,8 +668,7 @@ set_bool_arg (unsigned int *var, const char *line, regmatch_t * match)
return 0; return 0;
} }
static unsigned long static unsigned long get_long_arg (const char *line, regmatch_t * match)
get_long_arg (const char *line, regmatch_t * match)
{ {
assert (line); assert (line);
assert (match && match->rm_so != -1); assert (match && match->rm_so != -1);
@ -668,8 +676,7 @@ get_long_arg (const char *line, regmatch_t * match)
return strtoul (line + match->rm_so, NULL, 0); return strtoul (line + match->rm_so, NULL, 0);
} }
static int static int set_int_arg (unsigned int *var, const char *line, regmatch_t * match)
set_int_arg (unsigned int *var, const char *line, regmatch_t * match)
{ {
assert (var); assert (var);
assert (line); assert (line);
@ -726,8 +733,7 @@ static HANDLE_FUNC (handle_viaproxyname)
if (r) if (r)
return r; return r;
log_message (LOG_INFO, log_message (LOG_INFO,
"Setting \"Via\" header to '%s'", "Setting \"Via\" header to '%s'", conf->via_proxy_name);
conf->via_proxy_name);
return 0; return 0;
} }
@ -739,8 +745,7 @@ static HANDLE_FUNC (handle_disableviaheader)
return r; return r;
} }
log_message (LOG_INFO, log_message (LOG_INFO, "Disabling transmission of the \"Via\" header.");
"Disabling transmission of the \"Via\" header.");
return 0; return 0;
} }
@ -811,15 +816,13 @@ static HANDLE_FUNC (handle_maxclients)
static HANDLE_FUNC (handle_maxspareservers) static HANDLE_FUNC (handle_maxspareservers)
{ {
child_configure (CHILD_MAXSPARESERVERS, child_configure (CHILD_MAXSPARESERVERS, get_long_arg (line, &match[2]));
get_long_arg (line, &match[2]));
return 0; return 0;
} }
static HANDLE_FUNC (handle_minspareservers) static HANDLE_FUNC (handle_minspareservers)
{ {
child_configure (CHILD_MINSPARESERVERS, child_configure (CHILD_MINSPARESERVERS, get_long_arg (line, &match[2]));
get_long_arg (line, &match[2]));
return 0; return 0;
} }
@ -841,6 +844,13 @@ static HANDLE_FUNC (handle_timeout)
return set_int_arg (&conf->idletimeout, line, &match[2]); return set_int_arg (&conf->idletimeout, line, &match[2]);
} }
#ifdef UPSTREAM_SUPPORT
static HANDLE_FUNC (handle_deadtime)
{
return set_int_arg (&conf->deadtime, line, &match[2]);
}
#endif
static HANDLE_FUNC (handle_connectport) static HANDLE_FUNC (handle_connectport)
{ {
add_connect_port_allowed (get_long_arg (line, &match[2]), add_connect_port_allowed (get_long_arg (line, &match[2]),
@ -1106,11 +1116,13 @@ static enum proxy_type pt_from_string(const char *s)
static HANDLE_FUNC (handle_upstream) static HANDLE_FUNC (handle_upstream)
{ {
char *ip; struct upstream_proxy_list *pltr, *plist;
int port, mi = 2; int mi = 2;
char *domain = 0, *user = 0, *pass = 0, *tmp; char *domain = 0, *user = 0, *pass = 0, *tmp;
enum proxy_type pt; enum proxy_type pt;
pltr = plist = (upstream_proxy_list_t *)
safemalloc (sizeof (upstream_proxy_list_t));
tmp = get_string_arg (line, &match[mi]); tmp = get_string_arg (line, &match[mi]);
pt = pt_from_string (tmp); pt = pt_from_string (tmp);
safefree (tmp); safefree (tmp);
@ -1123,24 +1135,54 @@ static HANDLE_FUNC (handle_upstream)
if (match[mi].rm_so != -1) if (match[mi].rm_so != -1)
pass = get_string_arg (line, &match[mi]); pass = get_string_arg (line, &match[mi]);
mi++; mi++;
plist->host = get_string_arg (line, &match[mi]);
ip = get_string_arg (line, &match[mi]); if (!plist->host)
if (!ip)
return -1; return -1;
mi += 5; mi += 5;
plist->port = (int) get_long_arg (line, &match[mi]);
plist->last_failed_connect = (time_t) 0;
port = (int) get_long_arg (line, &match[mi]); mi += 2;
mi += 3; /* if != -1 we have a list of proxy hosts seperated by |. */
if (match[mi].rm_so != -1) {
/* loop over proxy host list */
char *phl, *pptr;
phl = get_string_arg (line, &match[mi]);
if (!phl)
return -1;
pptr = strtok (phl, "|");
while (pptr) {
char *cptr;
plist->next = (upstream_proxy_list_t *)
safemalloc (sizeof (upstream_proxy_list_t));
plist = plist->next;
cptr = strchr (pptr, ':');
*cptr++ = '\0';
plist->host = strdup (pptr);
plist->port = strtoul (cptr, NULL, 0);
plist->last_failed_connect = (time_t) 0;
pptr = strtok (NULL, "|");
}
safefree (phl);
}
mi += 10;
if (match[mi].rm_so != -1) if (match[mi].rm_so != -1)
domain = get_string_arg (line, &match[mi]); domain = get_string_arg (line, &match[mi]);
upstream_add (ip, port, domain, user, pass, pt, &conf->upstream_list); upstream_add (pltr, domain, user, pass, pt, &conf->upstream_list);
safefree (user); safefree (user);
safefree (pass); safefree (pass);
safefree (domain); safefree (domain);
safefree (ip); while (pltr) {
struct upstream_proxy_list *tmpp = pltr;
pltr = pltr->next;
safefree (tmpp->host);
safefree (tmpp);
}
return 0; return 0;
} }
@ -1153,7 +1195,7 @@ static HANDLE_FUNC (handle_upstream_no)
if (!domain) if (!domain)
return -1; return -1;
upstream_add (NULL, 0, domain, 0, 0, PT_NONE, &conf->upstream_list); upstream_add (NULL, domain, 0, 0, PT_NONE, &conf->upstream_list);
safefree (domain); safefree (domain);
return 0; return 0;

View File

@ -68,6 +68,9 @@ struct config_s {
#endif /* UPSTREAM_SUPPORT */ #endif /* UPSTREAM_SUPPORT */
char *pidpath; char *pidpath;
unsigned int idletimeout; unsigned int idletimeout;
#ifdef UPSTREAM_SUPPORT
unsigned int deadtime;
#endif /* UPSTREAM_SUPPORT */
char *bind_address; char *bind_address;
unsigned int bindsame; unsigned int bindsame;
@ -116,6 +119,8 @@ struct config_s {
extern int reload_config_file (const char *config_fname, struct config_s *conf, extern int reload_config_file (const char *config_fname, struct config_s *conf,
struct config_s *defaults); struct config_s *defaults);
extern void free_config (struct config_s *conf);
int config_compile_regex (void); int config_compile_regex (void);
#endif #endif

View File

@ -42,8 +42,7 @@ void makedaemon (void)
exit (0); exit (0);
if (chdir ("/") != 0) { if (chdir ("/") != 0) {
log_message (LOG_WARNING, log_message (LOG_WARNING, "Could not change directory to /");
"Could not change directory to /");
} }
umask (0177); umask (0177);

View File

@ -105,12 +105,10 @@ void filter_init (void)
continue; continue;
if (!p) /* head of list */ if (!p) /* head of list */
fl = p = fl = p = (struct filter_list *)
(struct filter_list *)
safecalloc (1, sizeof (struct filter_list)); safecalloc (1, sizeof (struct filter_list));
else { /* next entry */ else { /* next entry */
p->next = p->next = (struct filter_list *)
(struct filter_list *)
safecalloc (1, sizeof (struct filter_list)); safecalloc (1, sizeof (struct filter_list));
p = p->next; p = p->next;
} }

View File

@ -508,8 +508,7 @@ char *lookup_variable (hashmap_t map, const char *varname)
if (hashmap_is_end (map, result_iter)) if (hashmap_is_end (map, result_iter))
return (NULL); return (NULL);
if (hashmap_return_entry (map, result_iter, if (hashmap_return_entry (map, result_iter, &key, (void **) &data) < 0)
&key, (void **) &data) < 0)
return (NULL); return (NULL);
return (data); return (data);

View File

@ -86,8 +86,7 @@ static char *get_html_file (unsigned int errornum)
/* /*
* Send an already-opened file to the client with variable substitution. * Send an already-opened file to the client with variable substitution.
*/ */
int int send_html_file (FILE * infile, struct conn_s *connptr)
send_html_file (FILE *infile, struct conn_s *connptr)
{ {
char *inbuf; char *inbuf;
char *varstart = NULL; char *varstart = NULL;
@ -105,7 +104,8 @@ send_html_file (FILE *infile, struct conn_s *connptr)
if (in_variable) { if (in_variable) {
*p = '\0'; *p = '\0';
varval = (const char *) varval = (const char *)
lookup_variable (connptr->error_variables, lookup_variable
(connptr->error_variables,
varstart); varstart);
if (!varval) if (!varval)
varval = "(unknown)"; varval = "(unknown)";
@ -160,25 +160,21 @@ int send_http_headers (struct conn_s *connptr, int code, const char *message)
const char headers[] = const char headers[] =
"HTTP/1.0 %d %s\r\n" "HTTP/1.0 %d %s\r\n"
"Server: %s/%s\r\n" "Server: %s/%s\r\n"
"Content-Type: text/html\r\n" "Content-Type: text/html\r\n" "%s" "Connection: close\r\n" "\r\n";
"%s"
"Connection: close\r\n" "\r\n";
const char p_auth_str[] = const char p_auth_str[] =
"Proxy-Authenticate: Basic realm=\"" "Proxy-Authenticate: Basic realm=\"" PACKAGE_NAME "\"\r\n";
PACKAGE_NAME "\"\r\n";
const char w_auth_str[] = const char w_auth_str[] =
"WWW-Authenticate: Basic realm=\"" "WWW-Authenticate: Basic realm=\"" PACKAGE_NAME "\"\r\n";
PACKAGE_NAME "\"\r\n";
/* according to rfc7235, the 407 error must be accompanied by /* according to rfc7235, the 407 error must be accompanied by
a Proxy-Authenticate header field. */ * a Proxy-Authenticate header field. */
const char *add = code == 407 ? p_auth_str : (code == 401 ? w_auth_str : ""); const char *add =
code == 407 ? p_auth_str : (code == 401 ? w_auth_str : "");
return (write_message (connptr->client_fd, headers, return (write_message (connptr->client_fd, headers,
code, message, PACKAGE, VERSION, code, message, PACKAGE, VERSION, add));
add));
} }
/* /*
@ -207,12 +203,12 @@ int send_http_error_message (struct conn_s *connptr)
error_file = get_html_file (connptr->error_number); error_file = get_html_file (connptr->error_number);
if (!(infile = fopen (error_file, "r"))) { if (!(infile = fopen (error_file, "r"))) {
char *detail = lookup_variable (connptr->error_variables, "detail"); char *detail =
return (write_message (connptr->client_fd, fallback_error, lookup_variable (connptr->error_variables, "detail");
connptr->error_number, return (write_message
connptr->error_string, (connptr->client_fd, fallback_error,
connptr->error_string, connptr->error_number, connptr->error_string,
detail, PACKAGE, VERSION)); connptr->error_string, detail, PACKAGE, VERSION));
} }
ret = send_html_file (infile, connptr); ret = send_html_file (infile, connptr);
@ -274,8 +270,7 @@ int add_standard_vars (struct conn_s *connptr)
gmtime (&global_time)); gmtime (&global_time));
add_error_variable (connptr, "date", timebuf); add_error_variable (connptr, "date", timebuf);
add_error_variable (connptr, "website", add_error_variable (connptr, "website", "https://tinyproxy.github.io/");
"https://tinyproxy.github.io/");
add_error_variable (connptr, "version", VERSION); add_error_variable (connptr, "version", VERSION);
add_error_variable (connptr, "package", PACKAGE); add_error_variable (connptr, "package", PACKAGE);

View File

@ -54,8 +54,7 @@ unsigned int received_sighup = FALSE; /* boolean */
/* /*
* Handle a signal * Handle a signal
*/ */
static void static void takesig (int sig)
takesig (int sig)
{ {
pid_t pid; pid_t pid;
int status; int status;
@ -80,8 +79,7 @@ takesig (int sig)
/* /*
* Display the version information for the user. * Display the version information for the user.
*/ */
static void static void display_version (void)
display_version (void)
{ {
printf ("%s %s\n", PACKAGE, VERSION); printf ("%s %s\n", PACKAGE, VERSION);
} }
@ -89,8 +87,7 @@ display_version (void)
/* /*
* Display usage to the user. * Display usage to the user.
*/ */
static void static void display_usage (void)
display_usage (void)
{ {
int features = 0; int features = 0;
@ -143,8 +140,7 @@ display_usage (void)
"<https://tinyproxy.github.io/>.\n"); "<https://tinyproxy.github.io/>.\n");
} }
static int static int get_id (char *str)
get_id (char *str)
{ {
char *tstr; char *tstr;
@ -168,8 +164,7 @@ get_id (char *str)
* *
* This function parses command line arguments. * This function parses command line arguments.
**/ **/
static void static void process_cmdline (int argc, char **argv, struct config_s *conf)
process_cmdline (int argc, char **argv, struct config_s *conf)
{ {
int opt; int opt;
@ -215,8 +210,7 @@ process_cmdline (int argc, char **argv, struct config_s *conf)
* the config file. This function is typically called during * the config file. This function is typically called during
* initialization when the effective user is root. * initialization when the effective user is root.
**/ **/
static void static void change_user (const char *program)
change_user (const char *program)
{ {
if (config.group && strlen (config.group) > 0) { if (config.group && strlen (config.group) > 0) {
int gid = get_id (config.group); int gid = get_id (config.group);
@ -240,7 +234,6 @@ change_user (const char *program)
program, config.group); program, config.group);
exit (EX_NOPERM); exit (EX_NOPERM);
} }
#ifdef HAVE_SETGROUPS #ifdef HAVE_SETGROUPS
/* Drop all supplementary groups, otherwise these are inherited from the calling process */ /* Drop all supplementary groups, otherwise these are inherited from the calling process */
if (setgroups (0, NULL) < 0) { if (setgroups (0, NULL) < 0) {
@ -300,6 +293,9 @@ static void initialize_config_defaults (struct config_s *conf)
conf->errorpages = NULL; conf->errorpages = NULL;
conf->stathost = safestrdup (TINYPROXY_STATHOST); conf->stathost = safestrdup (TINYPROXY_STATHOST);
conf->idletimeout = MAX_IDLE_TIME; conf->idletimeout = MAX_IDLE_TIME;
#ifdef UPSTREAM_SUPPORT
conf->deadtime = MAX_DEAD_TIME;
#endif
conf->logf_name = NULL; conf->logf_name = NULL;
conf->pidpath = NULL; conf->pidpath = NULL;
} }
@ -326,8 +322,7 @@ done:
return ret; return ret;
} }
int int main (int argc, char **argv)
main (int argc, char **argv)
{ {
/* Only allow u+rw bits. This may be required for some versions /* Only allow u+rw bits. This may be required for some versions
* of glibc so that mkstemp() doesn't make us vulnerable. * of glibc so that mkstemp() doesn't make us vulnerable.
@ -344,8 +339,7 @@ main (int argc, char **argv)
process_cmdline (argc, argv, &config_defaults); process_cmdline (argc, argv, &config_defaults);
if (reload_config_file (config_defaults.config_file, if (reload_config_file (config_defaults.config_file,
&config, &config, &config_defaults)) {
&config_defaults)) {
exit (EX_SOFTWARE); exit (EX_SOFTWARE);
} }
@ -373,7 +367,6 @@ main (int argc, char **argv)
argv[0]); argv[0]);
exit (EX_OSERR); exit (EX_OSERR);
} }
#ifdef FILTER_ENABLE #ifdef FILTER_ENABLE
if (config.filter) if (config.filter)
filter_init (); filter_init ();
@ -451,12 +444,13 @@ main (int argc, char **argv)
"Could not remove PID file \"%s\": %s.", "Could not remove PID file \"%s\": %s.",
config.pidpath, strerror (errno)); config.pidpath, strerror (errno));
} }
#ifdef FILTER_ENABLE #ifdef FILTER_ENABLE
if (config.filter) if (config.filter)
filter_destroy (); filter_destroy ();
#endif /* FILTER_ENABLE */ #endif /* FILTER_ENABLE */
free_config (&config);
shutdown_logging (); shutdown_logging ();
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -27,6 +27,9 @@
/* Global variables for the main controls of the program */ /* Global variables for the main controls of the program */
#define MAXBUFFSIZE ((size_t)(1024 * 96)) /* Max size of buffer */ #define MAXBUFFSIZE ((size_t)(1024 * 96)) /* Max size of buffer */
#define MAX_IDLE_TIME (60 * 10) /* 10 minutes of no activity */ #define MAX_IDLE_TIME (60 * 10) /* 10 minutes of no activity */
#ifdef UPSTREAM_SUPPORT
#define MAX_DEAD_TIME (60 * 10) /* 10 minutes of no activity */
#endif
/* Global Structures used in the program */ /* Global Structures used in the program */
extern struct config_s config; extern struct config_s config;

View File

@ -204,8 +204,7 @@ ssize_t readline (int fd, char **whole_buffer)
break; break;
} }
line_ptr->next = line_ptr->next = (struct read_lines_s *)
(struct read_lines_s *)
safecalloc (sizeof (struct read_lines_s), 1); safecalloc (sizeof (struct read_lines_s), 1);
if (!line_ptr->next) { if (!line_ptr->next) {
ret = -ENOMEM; ret = -ENOMEM;

View File

@ -1417,12 +1417,13 @@ connect_to_upstream (struct conn_s *connptr, struct request_s *request)
*/ */
return -1; return -1;
#else #else
struct upstream_proxy_list *upp;
char *combined_string; char *combined_string;
int len; int len;
struct upstream *cur_upstream = connptr->upstream_proxy; struct upstream *cur_upstream = connptr->upstream_proxy;
if (!cur_upstream) { if (!cur_upstream || !cur_upstream->plist) {
log_message (LOG_WARNING, log_message (LOG_WARNING,
"No upstream proxy defined for %s.", "No upstream proxy defined for %s.",
request->host); request->host);
@ -1431,11 +1432,39 @@ connect_to_upstream (struct conn_s *connptr, struct request_s *request)
return -1; return -1;
} }
upp = cur_upstream->plist;
while (upp) {
double tdiff;
if (upp->last_failed_connect > 0) {
tdiff =
difftime (time (NULL), upp->last_failed_connect);
if (tdiff < config.deadtime) {
log_message (LOG_INFO,
"Won't try to connect to upstream "
"proxy %s:%d during dead time.",
upp->host, upp->port);
upp = upp->next;
continue;
} else {
upp->last_failed_connect = (time_t) 0;
}
}
connptr->server_fd = connptr->server_fd =
opensock (cur_upstream->host, cur_upstream->port, opensock (upp->host, upp->port, connptr->server_ip_addr);
connptr->server_ip_addr);
if (connptr->server_fd < 0) { if (connptr->server_fd < 0) {
log_message (LOG_WARNING,
"Could not connect to upstream proxy. "
"Try next in list if available.");
upp->last_failed_connect = time (NULL);
} else {
cur_upstream->host = upp->host;
cur_upstream->port = upp->port;
break;
}
upp = upp->next;
}
if (!upp || connptr->server_fd < 0) {
log_message (LOG_WARNING, log_message (LOG_WARNING,
"Could not connect to upstream proxy."); "Could not connect to upstream proxy.");
indicate_http_error (connptr, 404, indicate_http_error (connptr, 404,

View File

@ -139,13 +139,10 @@ char *reverse_rewrite_url (struct conn_s *connptr, hashmap_t hashofheaders,
&& (reverse = && (reverse =
reversepath_get (cookieval + reversepath_get (cookieval +
strlen (REVERSE_COOKIE) + 1, strlen (REVERSE_COOKIE) + 1,
config.reversepath_list))) config.reversepath_list))) {
{
rewrite_url = (char *) safemalloc rewrite_url = (char *) safemalloc
(strlen (url) + (strlen (url) + strlen (reverse->url) + 1);
strlen (reverse->url) +
1);
strcpy (rewrite_url, reverse->url); strcpy (rewrite_url, reverse->url);
strcat (rewrite_url, url + 1); strcat (rewrite_url, url + 1);

View File

@ -50,8 +50,7 @@ static const char * get_gai_error (int n)
* returned if the bind succeeded. Otherwise, -1 is returned * returned if the bind succeeded. Otherwise, -1 is returned
* to indicate an error. * to indicate an error.
*/ */
static int static int bind_socket (int sockfd, const char *addr, int family)
bind_socket (int sockfd, const char *addr, int family)
{ {
struct addrinfo hints, *res, *ressave; struct addrinfo hints, *res, *ressave;
int n; int n;
@ -67,7 +66,8 @@ bind_socket (int sockfd, const char *addr, int family)
n = getaddrinfo (addr, NULL, &hints, &res); n = getaddrinfo (addr, NULL, &hints, &res);
if (n != 0) { if (n != 0) {
log_message (LOG_INFO, log_message (LOG_INFO,
"bind_socket: getaddrinfo failed for %s: ", addr, get_gai_error (n)); "bind_socket: getaddrinfo failed for %s: ", addr,
get_gai_error (n));
return -1; return -1;
} }
@ -112,7 +112,8 @@ int opensock (const char *host, int port, const char *bind_to)
n = getaddrinfo (host, portstr, &hints, &res); n = getaddrinfo (host, portstr, &hints, &res);
if (n != 0) { if (n != 0) {
log_message (LOG_ERR, log_message (LOG_ERR,
"opensock: Could not retrieve address info for %s:%d: %s", host, port, get_gai_error (n)); "opensock: Could not retrieve address info for %s:%d: %s",
host, port, get_gai_error (n));
return -1; return -1;
} }
@ -128,8 +129,7 @@ int opensock (const char *host, int port, const char *bind_to)
/* Bind to the specified address */ /* Bind to the specified address */
if (bind_to) { if (bind_to) {
if (bind_socket (sockfd, bind_to, if (bind_socket (sockfd, bind_to, res->ai_family) < 0) {
res->ai_family) < 0) {
close (sockfd); close (sockfd);
continue; /* can't bind, so try again */ continue; /* can't bind, so try again */
} }
@ -151,8 +151,7 @@ int opensock (const char *host, int port, const char *bind_to)
if (res == NULL) { if (res == NULL) {
log_message (LOG_ERR, log_message (LOG_ERR,
"opensock: Could not establish a connection to %s:%d", "opensock: Could not establish a connection to %s:%d",
host, host, port);
port);
return -1; return -1;
} }
@ -185,7 +184,6 @@ int socket_blocking (int sock)
return fcntl (sock, F_SETFL, flags & ~O_NONBLOCK); return fcntl (sock, F_SETFL, flags & ~O_NONBLOCK);
} }
/** /**
* Try to listen on one socket based on the addrinfo * Try to listen on one socket based on the addrinfo
* as returned from getaddrinfo. * as returned from getaddrinfo.
@ -203,7 +201,8 @@ static int listen_on_one_socket(struct addrinfo *ad)
ret = getnameinfo (ad->ai_addr, ad->ai_addrlen, ret = getnameinfo (ad->ai_addr, ad->ai_addrlen,
numerichost, NI_MAXHOST, NULL, 0, flags); numerichost, NI_MAXHOST, NULL, 0, flags);
if (ret != 0) { if (ret != 0) {
log_message(LOG_ERR, "getnameinfo failed: %s", get_gai_error (ret)); log_message (LOG_ERR, "getnameinfo failed: %s",
get_gai_error (ret));
return -1; return -1;
} }
@ -291,9 +290,7 @@ int listen_sock (const char *addr, uint16_t port, vector_t listen_fds)
if (n != 0) { if (n != 0) {
log_message (LOG_ERR, log_message (LOG_ERR,
"Unable to getaddrinfo() for %s:%d because of %s", "Unable to getaddrinfo() for %s:%d because of %s",
addr, addr, port, get_gai_error (n));
port,
get_gai_error (n));
return -1; return -1;
} }

View File

@ -59,8 +59,7 @@ void init_stats (void)
/* /*
* Display the statics of the tinyproxy server. * Display the statics of the tinyproxy server.
*/ */
int int showstats (struct conn_s *connptr)
showstats (struct conn_s *connptr)
{ {
char *message_buffer; char *message_buffer;
char opens[16], reqs[16], badconns[16], denied[16], refused[16]; char opens[16], reqs[16], badconns[16], denied[16], refused[16];
@ -102,8 +101,7 @@ showstats (struct conn_s *connptr)
stats->num_badcons, stats->num_denied, stats->num_badcons, stats->num_denied,
stats->num_refused, PACKAGE, VERSION); stats->num_refused, PACKAGE, VERSION);
if (send_http_message (connptr, 200, "OK", if (send_http_message (connptr, 200, "OK", message_buffer) < 0) {
message_buffer) < 0) {
safefree (message_buffer); safefree (message_buffer);
return -1; return -1;
} }

View File

@ -31,6 +31,25 @@
#include "basicauth.h" #include "basicauth.h"
#ifdef UPSTREAM_SUPPORT #ifdef UPSTREAM_SUPPORT
static const char *proxy_list_name (struct upstream_proxy_list *plist)
{
#define MAXBUF ((size_t)(1024 * 96))
static char hostport[MAXBUF];
static char pbuffer[MAXBUF];
struct upstream_proxy_list *upl = plist;
bzero (&pbuffer, MAXBUF);
snprintf (pbuffer, MAXBUF, "%s:%d", upl->host, upl->port);
upl = upl->next;
while (upl) {
bzero (&hostport, MAXBUF);
snprintf (hostport, MAXBUF, "|%s:%d", upl->host, upl->port);
strncat (pbuffer, hostport, MAXBUF - strlen (hostport));
upl = upl->next;
}
return pbuffer;
}
const char *proxy_type_name (proxy_type type) const char *proxy_type_name (proxy_type type)
{ {
switch (type) { switch (type) {
@ -47,15 +66,43 @@ const char *proxy_type_name (proxy_type type)
} }
} }
static struct upstream_proxy_list *uplcpy (const struct upstream_proxy_list
*plist)
{
struct upstream_proxy_list *upr, *upp, *uptr;
if (!plist)
return NULL;
upr = upp = (upstream_proxy_list_t *)
safemalloc (sizeof (upstream_proxy_list_t));
upp->host = safestrdup (plist->host);
upp->port = plist->port;
upp->last_failed_connect = plist->last_failed_connect;
upp->next = NULL;
uptr = plist->next;
while (uptr) {
upp->next = (upstream_proxy_list_t *)
safemalloc (sizeof (upstream_proxy_list_t));
upp = upp->next;
upp->host = safestrdup (uptr->host);
upp->port = uptr->port;
upp->next = NULL;
uptr = uptr->next;
}
return upr;
}
/** /**
* Construct an upstream struct from input data. * Construct an upstream struct from input data.
*/ */
static struct upstream *upstream_build (const char *host, int port, static struct upstream *upstream_build (const struct upstream_proxy_list *plist,
const char *domain, const char *user, const char *domain, const char *user,
const char *pass, proxy_type type) const char *pass, proxy_type type)
{ {
char *ptr; char *ptr;
struct upstream *up; struct upstream *up;
struct upstream_proxy_list *upp;
#ifdef UPSTREAM_REGEX #ifdef UPSTREAM_REGEX
int cflags = REG_NEWLINE | REG_NOSUB; int cflags = REG_NEWLINE | REG_NOSUB;
int rflag = 0; int rflag = 0;
@ -70,7 +117,8 @@ static struct upstream *upstream_build (const char *host, int port,
} }
up->type = type; up->type = type;
up->host = up->domain = up->ua.user = up->pass = NULL; up->domain = up->ua.user = up->pass = NULL;
up->plist = NULL;
#ifdef UPSTREAM_REGEX #ifdef UPSTREAM_REGEX
up->pat = NULL; up->pat = NULL;
up->cpat = NULL; up->cpat = NULL;
@ -124,18 +172,18 @@ static struct upstream *upstream_build (const char *host, int port,
} }
if (domain == NULL) { if (domain == NULL) {
if (!host || host[0] == '\0' || port < 1) { if (!plist || plist->host[0] == '\0' || plist->port < 1) {
log_message (LOG_WARNING, log_message (LOG_WARNING,
"Nonsense upstream rule: invalid host or port"); "Nonsense upstream rule: invalid host or port");
goto fail; goto fail;
} }
up->host = safestrdup (host); up->plist = uplcpy (plist);
up->port = port;
log_message (LOG_INFO, "Added upstream %s %s:%d for [default]", log_message (LOG_INFO, "Added upstream %s %s for [default]",
proxy_type_name (type), host, port); proxy_type_name (type),
} else if (host == NULL || type == PT_NONE) { proxy_list_name (up->plist));
} else if (plist == NULL || type == PT_NONE) {
if (!domain || domain[0] == '\0') { if (!domain || domain[0] == '\0') {
log_message (LOG_WARNING, log_message (LOG_WARNING,
"Nonsense no-upstream rule: empty domain"); "Nonsense no-upstream rule: empty domain");
@ -183,15 +231,14 @@ static struct upstream *upstream_build (const char *host, int port,
log_message (LOG_INFO, "Added no-upstream for %s", domain); log_message (LOG_INFO, "Added no-upstream for %s", domain);
} else { } else {
if (!host || host[0] == '\0' || port < 1 || !domain if (!plist || plist->host[0] == '\0' || plist->port < 1
|| domain[0] == '\0') { || !domain || domain[0] == '\0') {
log_message (LOG_WARNING, log_message (LOG_WARNING,
"Nonsense upstream rule: invalid parameters"); "Nonsense upstream rule: invalid parameters");
goto fail; goto fail;
} }
up->host = safestrdup (host); up->plist = uplcpy (plist);
up->port = port;
up->domain = safestrdup (domain); up->domain = safestrdup (domain);
#ifdef UPSTREAM_REGEX #ifdef UPSTREAM_REGEX
if (rflag) { if (rflag) {
@ -205,19 +252,29 @@ static struct upstream *upstream_build (const char *host, int port,
} }
} }
#endif #endif
log_message (LOG_INFO, "Added upstream %s %s:%d for %s", log_message (LOG_INFO, "Added upstream %s %s for %s",
proxy_type_name (type), host, port, domain); proxy_type_name (type),
proxy_list_name (up->plist), domain);
} }
return up; return up;
fail: fail:
safefree (up->ua.user); safefree (up->ua.user);
safefree (up->ua.authstr);
safefree (up->pass); safefree (up->pass);
safefree (up->host); upp = up->plist;
while (upp) {
struct upstream_proxy_list *tmpp = upp;
upp = upp->next;
safefree (tmpp->host);
safefree (tmpp);
}
safefree (up->domain); safefree (up->domain);
#ifdef UPSTREAM_REGEX #ifdef UPSTREAM_REGEX
safefree (up->pat); safefree (up->pat);
if (up->cpat)
regfree (up->cpat);
safefree (up->cpat); safefree (up->cpat);
#endif #endif
safefree (up); safefree (up);
@ -228,13 +285,14 @@ fail:
/* /*
* Add an entry to the upstream list * Add an entry to the upstream list
*/ */
void upstream_add (const char *host, int port, const char *domain, void upstream_add (const struct upstream_proxy_list *plist, const char *domain,
const char *user, const char *pass, const char *user, const char *pass,
proxy_type type, struct upstream **upstream_list) proxy_type type, struct upstream **upstream_list)
{ {
struct upstream *up; struct upstream *up;
struct upstream_proxy_list *upp;
up = upstream_build (host, port, domain, user, pass, type); up = upstream_build (plist, domain, user, pass, type);
if (up == NULL) { if (up == NULL) {
return; return;
} }
@ -265,8 +323,23 @@ void upstream_add (const char *host, int port, const char *domain,
return; return;
upstream_cleanup: upstream_cleanup:
safefree (up->host); upp = up->plist;
while (upp) {
struct upstream_proxy_list *tmpp = upp;
upp = upp->next;
safefree (tmpp->host);
safefree (tmpp);
}
safefree (up->domain); safefree (up->domain);
safefree (up->ua.user);
safefree (up->ua.authstr);
safefree (up->pass);
#ifdef UPSTREAM_REGEX
safefree (up->pat);
if (up->cpat)
regfree (up->cpat);
safefree (up->cpat);
#endif
safefree (up); safefree (up);
return; return;
@ -323,14 +396,14 @@ struct upstream *upstream_get (struct request_s *request, struct upstream *up)
up = up->next; up = up->next;
} }
if (up && !up->plist)
if (up && (!up->host || !up->port))
up = NULL; up = NULL;
if (up) if (up)
log_message (LOG_INFO, "Found upstream proxy %s %s:%d for %s", log_message (LOG_INFO,
proxy_type_name (up->type), up->host, up->port, "Found upstream proxy/proxies %s %s for %s",
host); proxy_type_name (up->type),
proxy_list_name (up->plist), host);
else else
log_message (LOG_INFO, "No upstream proxy for %s", host); log_message (LOG_INFO, "No upstream proxy for %s", host);
@ -341,9 +414,24 @@ void free_upstream_list (struct upstream *up)
{ {
while (up) { while (up) {
struct upstream *tmp = up; struct upstream *tmp = up;
struct upstream_proxy_list *upp = up->plist;
up = up->next; up = up->next;
while (upp) {
struct upstream_proxy_list *tmpp = upp;
upp = upp->next;
safefree (tmpp->host);
safefree (tmpp);
}
safefree (tmp->domain); safefree (tmp->domain);
safefree (tmp->host); safefree (tmp->ua.user);
safefree (tmp->ua.authstr);
safefree (tmp->pass);
#ifdef UPSTREAM_REGEX
safefree (tmp->pat);
if (tmp->cpat)
regfree (tmp->cpat);
safefree (tmp->cpat);
#endif
safefree (tmp); safefree (tmp);
} }
} }

View File

@ -39,16 +39,25 @@ typedef enum proxy_type {
PT_SOCKS5 PT_SOCKS5
} proxy_type; } proxy_type;
typedef struct upstream_proxy_list {
struct upstream_proxy_list *next;
char *host;
int port;
time_t last_failed_connect;
} upstream_proxy_list_t;
struct upstream { struct upstream {
struct upstream *next; struct upstream *next;
char *domain; /* optional */ char *domain; /* optional */
struct upstream_proxy_list *plist;
char *host; char *host;
int port;
union { union {
char *user; char *user;
char *authstr; char *authstr;
} ua; } ua;
char *pass; char *pass;
int port;
in_addr_t ip, mask; in_addr_t ip, mask;
proxy_type type; proxy_type type;
#if defined(UPSTREAM_SUPPORT) && defined(UPSTREAM_REGEX) #if defined(UPSTREAM_SUPPORT) && defined(UPSTREAM_REGEX)
@ -59,9 +68,10 @@ struct upstream {
#ifdef UPSTREAM_SUPPORT #ifdef UPSTREAM_SUPPORT
const char *proxy_type_name (proxy_type type); const char *proxy_type_name (proxy_type type);
extern void upstream_add (const char *host, int port, const char *domain, extern void upstream_add (const struct upstream_proxy_list *phost,
const char *user, const char *pass, const char *domain, const char *user,
proxy_type type, struct upstream **upstream_list); const char *pass, proxy_type type,
struct upstream **upstream_list);
extern struct upstream *upstream_get (struct request_s *request, extern struct upstream *upstream_get (struct request_s *request,
struct upstream *up); struct upstream *up);
extern void free_upstream_list (struct upstream *up); extern void free_upstream_list (struct upstream *up);

View File

@ -185,8 +185,7 @@ int create_file_safely (const char *filename, unsigned int truncate_file)
* *
* Returns: %0 on success, non-zero values on errors. * Returns: %0 on success, non-zero values on errors.
**/ **/
int int pidfile_create (const char *filename)
pidfile_create (const char *filename)
{ {
int fildes; int fildes;
FILE *fd; FILE *fd;

View File

@ -111,10 +111,7 @@ typedef enum {
} vector_pos_t; } vector_pos_t;
static int static int
vector_insert (vector_t vector, vector_insert (vector_t vector, void *data, size_t len, vector_pos_t pos)
void *data,
size_t len,
vector_pos_t pos)
{ {
struct vectorentry_s *entry; struct vectorentry_s *entry;