From d4b4342a40e6409c88f94225f0ab148b18403a91 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 6 Sep 2006 10:43:32 +0000 Subject: [PATCH] Added config option enable-remote-http-toggle to specify if Privoxy should recognize special headers (currently only X-Filter) to change its behaviour. Disabled by default. --- loadcfg.c | 23 ++++++++++++++++++++++- parsers.c | 34 +++++++++++++++++++++++++--------- project.h | 16 ++++++++++++---- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/loadcfg.c b/loadcfg.c index eb24cd62..131e9bda 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,4 +1,4 @@ -const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.50 2006/07/18 14:48:46 david__schmidt Exp $"; +const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.51 2006/09/06 09:23:37 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ @@ -35,6 +35,11 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.50 2006/07/18 14:48:46 david__sch * * Revisions : * $Log: loadcfg.c,v $ + * Revision 1.51 2006/09/06 09:23:37 fabiankeil + * Make number of retries in case of forwarded-connect problems + * a config file option (forwarded-connect-retries) and use 0 as + * default. + * * Revision 1.50 2006/07/18 14:48:46 david__schmidt * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch) * with what was really the latest development (the v_3_0_branch branch) @@ -434,6 +439,7 @@ static struct file_list *current_configfile = NULL; #define hash_deny_access 1227333715ul /* "deny-access" */ #define hash_enable_edit_actions 2517097536ul /* "enable-edit-actions" */ #define hash_enable_remote_toggle 2979744683ul /* "enable-remote-toggle" */ +#define hash_enable_remote_http_toggle 110543988ul /* "enable-remote-http-toggle" */ #define hash_filterfile 250887266ul /* "filterfile" */ #define hash_forward 2029845ul /* "forward" */ #define hash_forward_socks4 3963965521ul /* "forward-socks4" */ @@ -643,6 +649,7 @@ struct configuration_spec * load_config(void) config->usermanual = strdup(USER_MANUAL_URL); config->proxy_args = strdup(""); config->forwarded_connect_retries = 0; + config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE; if ((configfp = fopen(configfile, "r")) == NULL) { @@ -871,6 +878,20 @@ struct configuration_spec * load_config(void) continue; #endif /* def FEATURE_CGI_EDIT_ACTIONS */ +/* ************************************************************************* + * enable-remote-http-toggle 0|1 + * *************************************************************************/ + case hash_enable_remote_http_toggle: + if ((*arg != '\0') && (0 != atoi(arg))) + { + config->feature_flags |= RUNTIME_FEATURE_HTTP_TOGGLE; + } + else + { + config->feature_flags &= ~RUNTIME_FEATURE_HTTP_TOGGLE; + } + continue; + /* ************************************************************************* * filterfile file-name * In confdir by default. diff --git a/parsers.c b/parsers.c index c6f9c66f..3e524c24 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.66 2006/09/03 19:38:28 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.67 2006/09/04 11:01:26 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -40,6 +40,15 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.66 2006/09/03 19:38:28 fabiankeil * * Revisions : * $Log: parsers.c,v $ + * Revision 1.67 2006/09/04 11:01:26 fabiankeil + * After filtering de-chunked instances, remove + * "Transfer-Encoding" header entirely instead of changing + * it to "Transfer-Encoding: identity", which is invalid. + * Thanks Michael Shields . Fixes PR 1318658. + * + * Don't use localtime in parse_header_time. An empty time struct + * is good enough, it gets overwritten by strptime anyway. + * * Revision 1.66 2006/09/03 19:38:28 fabiankeil * Use gmtime_r if available, fallback to gmtime with mutex * protection for MacOSX and use vanilla gmtime for the rest. @@ -2397,17 +2406,24 @@ jb_err client_x_filter(struct client_state *csp, char **header) { if ( 0 == strcmpic(*header, "X-Filter: No")) { - if (csp->action->flags & ACTION_FORCE_TEXT_MODE) + if (!(csp->config->feature_flags & RUNTIME_FEATURE_HTTP_TOGGLE)) { - log_error(LOG_LEVEL_HEADER, "force-text-mode overruled the client's request to disable filtering!"); + log_error(LOG_LEVEL_INFO, "Ignored the client's request to fetch without filtering."); } - else - { - csp->content_type = CT_TABOO; - log_error(LOG_LEVEL_HEADER, "Disabled filter mode on behalf of the client."); + else + { + if (csp->action->flags & ACTION_FORCE_TEXT_MODE) + { + log_error(LOG_LEVEL_HEADER, "force-text-mode overruled the client's request to fetch without filtering!"); + } + else + { + csp->content_type = CT_TABOO; + log_error(LOG_LEVEL_HEADER, "Accepted the client's request to fetch without filtering."); + } + log_error(LOG_LEVEL_HEADER, "Crunching %s", *header); + freez(*header); } - log_error(LOG_LEVEL_HEADER, "Crunching %s", *header); - freez(*header); } return JB_ERR_OK; } diff --git a/project.h b/project.h index 36025dcd..bb7ee921 100644 --- a/project.h +++ b/project.h @@ -1,7 +1,7 @@ #ifndef PROJECT_H_INCLUDED #define PROJECT_H_INCLUDED /** Version string. */ -#define PROJECT_H_VERSION "$Id: project.h,v 1.78 2006/08/31 16:25:06 fabiankeil Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.79 2006/09/06 09:23:37 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -37,6 +37,11 @@ * * Revisions : * $Log: project.h,v $ + * Revision 1.79 2006/09/06 09:23:37 fabiankeil + * Make number of retries in case of forwarded-connect problems + * a config file option (forwarded-connect-retries) and use 0 as + * default. + * * Revision 1.78 2006/08/31 16:25:06 fabiankeil * Work around a buffer overflow that caused Privoxy to * segfault if too many trusted referrers were used. Good @@ -1391,6 +1396,8 @@ struct access_control_list /** configuration_spec::feature_flags: Web-based toggle. */ #define RUNTIME_FEATURE_CGI_TOGGLE 2 +/** configuration_spec::feature_flags: HTTP-header-based toggle. */ +#define RUNTIME_FEATURE_HTTP_TOGGLE 4 /** * Data loaded from the configuration file. @@ -1405,15 +1412,13 @@ struct configuration_spec /** Nonzero to enable multithreading. */ int multi_threaded; - /** Number of retries in case a forwarded connection attempt fails */ - int forwarded_connect_retries; - /** * Bitmask of features that can be enabled/disabled through the config * file. Currently defined bits: * * - RUNTIME_FEATURE_CGI_EDIT_ACTIONS * - RUNTIME_FEATURE_CGI_TOGGLE + * - RUNTIME_FEATURE_HTTP_TOGGLE */ unsigned feature_flags; @@ -1489,6 +1494,9 @@ struct configuration_spec /** Information about parent proxies (forwarding). */ struct forward_spec *forward; + /** Number of retries in case a forwarded connection attempt fails */ + int forwarded_connect_retries; + /** All options from the config file, HTML-formatted. */ char *proxy_args; -- 2.39.2