- Add an INSTALL file, and remove these instructions from README.
- Add a demoronizer filter, which fixes MS's abuse of std charsets
(common cases anyway).
+- Add a 'dashboard' to watch activity in real-time - implemented
+ as a GUI in Java
*** Version 3.0 ***
#
# Copyright (C) 2001, 2002 Privoxy Developers http://privoxy.org
#
-# $Id: config,v 1.43 2003/02/20 13:51:50 hal9 Exp $
+# $Id: config,v 1.44 2003/04/20 17:37:28 hal9 Exp $
#
####################################################################
# #
#
#trustfile trust
+#
+# 1.8. image-blocker-custom-file
+# ==============
+#
+# Specifies:
+#
+# The custom image to display for blocked images when
+# +set-image-blocker{custom} is in effect in an action file
+#
+# Type of value:
+#
+# File name, relative to confdir; can be a jpeg, png or gif image
+#
+# Default value:
+#
+# Unset
+#
+# Effect if unset:
+#
+# If a custom image is called for and it is unset, the "pattern"
+# built-in image will be sent instead. I.e. it is as if you had
+# specified "+set-image-blocker{pattern}" instead of
+# "+set-image-blocker{custom}".
+#
+# Notes:
+#
+# If the specified file signature is not found to be jpeg, png
+# or gif, the the built-in "pattern" image will be sent instead.
+#
+#image-blocker-custom-file my-custom-image.jpg
+
#
# 2. LOCAL SET-UP DOCUMENTATION
# =============================
#
# File : $Source: /cvsroot/ijbswa/current/default.action.master,v $
#
-# $Id: default.action.master,v 1.6 2002/10/20 19:33:07 hal9 Exp $
+# $Id: default.action.master,v 1.7 2003/02/20 14:00:55 hal9 Exp $
#
# Purpose : Default actions file, see
# http://www.privoxy.org/user-manual/actions-file.html
#
# +set-image-blocker{blank}
# +set-image-blocker{pattern}
+# +set-image-blocker{custom}
# +set-image-blocker{<URL>} with <url> being any valid image URL
# Decides what to do with URLs that end up tagged with {+block +handle-as-image}.
-# There are 4 options:
+# There are 5 options:
# * "-set-image-blocker" will send a HTML "blocked" page, usually
# resulting in a "broken image" icon.
# * "+set-image-blocker{blank}" will send a 1x1 transparent image
# * "+set-image-blocker{pattern}" will send a 4x4 grey/white pattern
-# which is less intrusive than the logo but easier to recognize
-# than the transparent one.
+# which is easier to recognize than the transparent one.
+# * "+set-image-blocker{custom}" will send an image file as specified
+# in the config file (see image-blocker-custom-file within config).
# * "+set-image-blocker{<URL>}" will send a HTTP temporary redirect
# to the specified image URL.
#
-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 2.1 2002/07/04 14:35:05 oes Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 2.2 2002/12/28 03:58:19 david__schmidt Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/src/cgisimple.c,v $
*
* Revisions :
* $Log: cgisimple.c,v $
+ * Revision 2.2 2002/12/28 03:58:19 david__schmidt
+ * Initial drop of dashboard instrumentation - enabled with
+ * --enable-activity-console
+ *
* Revision 2.1 2002/07/04 14:35:05 oes
* Added ability to send redirects to send-banner CGI, so that it can completely mimic the image blocking action if called with type=auto
*
const struct map *parameters)
{
char imagetype = lookup(parameters, "type")[0];
+ char *image_mimetype = BUILTIN_IMAGE_MIMETYPE;
/*
* If type is auto, then determine the right thing
{
imagetype = 'p';
}
+ else if (0 == strcmpic(p, "custom"))
+ {
+ imagetype = 'c';
+ }
/*
* If the action is to call this CGI, determine
rsp->body = bindup(image_blank_data, image_blank_length);
rsp->content_length = image_blank_length;
}
+ else if (imagetype == 'c')
+ {
+ rsp->body = bindup(csp->config->image_blocker_data, csp->config->image_blocker_length);
+ rsp->content_length = csp->config->image_blocker_length;
+ image_mimetype = csp->config->image_blocker_format;
+ }
else
{
rsp->body = bindup(image_pattern_data, image_pattern_length);
{
return JB_ERR_MEMORY;
}
- if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
+ if (enlist(rsp->headers, "Content-Type: "))
+ {
+ return JB_ERR_MEMORY;
+ }
+ if (enlist(rsp->headers, image_mimetype))
{
return JB_ERR_MEMORY;
}
snprintf(buf, 100, "</td><td class=\"buttons\"><a href=\"/show-status?file=actions&index=%d\">View</a> ", i);
if (!err) err = string_append(&s, buf);
+#ifdef FEATURE_CGI_EDIT_ACTIONS
if (NULL == strstr(csp->actions_list[i]->filename, "standard.action") && NULL != csp->config->actions_file_short[i])
{
snprintf(buf, 100, "<a href=\"/edit-actions-list?f=%s\">Edit</a>", csp->config->actions_file_short[i]);
if (!err) err = string_append(&s, buf);
}
+#endif
if (!err) err = string_append(&s, "</td></tr>\n");
}
-const char filters_rcs[] = "$Id: filters.c,v 2.3 2002/12/28 03:58:19 david__schmidt Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 2.4 2003/01/21 02:49:27 david__schmidt Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/src/filters.c,v $
*
* Revisions :
* $Log: filters.c,v $
+ * Revision 2.4 2003/01/21 02:49:27 david__schmidt
+ * Developer TODO 612294: src: C++ keyword as variable name
+ * I changed all ocurrences of 'new' to 'new_something' wherever I found
+ * one. I also brought up all the source files in MSDEV to see if I could
+ * spot any highlighted keywords that really were variables. Non-scientific,
+ * but at least I tried. :-)
+ *
* Revision 2.3 2002/12/28 03:58:19 david__schmidt
* Initial drop of dashboard instrumentation - enabled with
* --enable-activity-console
}
}
+ else if (0 == strcmpic(p, "custom"))
+ {
+ rsp->body = bindup(csp->config->image_blocker_data, csp->config->image_blocker_length);
+ if (rsp->body == NULL)
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+ rsp->content_length = csp->config->image_blocker_length;
+
+ if (enlist_unique_header(rsp->headers, "Content-Type", csp->config->image_blocker_format))
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+ }
+
else
{
rsp->status = strdup("302 Local Redirect from Privoxy");
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 2.3 2002/09/19 03:48:29 iwanttokeepanon Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 2.4 2002/12/28 03:58:19 david__schmidt Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/src/loadcfg.c,v $
*
* Revisions :
* $Log: loadcfg.c,v $
+ * Revision 2.4 2002/12/28 03:58:19 david__schmidt
+ * Initial drop of dashboard instrumentation - enabled with
+ * --enable-activity-console
+ *
* Revision 2.3 2002/09/19 03:48:29 iwanttokeepanon
* Just moved "int i" up 3 lines in function unload_configfile, out of the "ifdef FEATURE_ACL" clause. I disable ACL and it was not compiling because "int i" was ifdef(d) out. I noticed this in the past, but am just now in a spot where I can change/commit stuff ... long live broadband!
*
#define hash_forward 2029845ul /**< "forward" */
#define hash_forward_socks4 3963965521ul /**< "forward-socks4" */
#define hash_forward_socks4a 2639958518ul /**< "forward-socks4a" */
+#define hash_image_blocker_custom_file 2863352327ul /**< "image-blocker-custom-file" */
#define hash_jarfile 2046641ul /**< "jarfile" */
#define hash_listen_address 1255650842ul /**< "listen-address" */
#define hash_logdir 422889ul /**< "logdir" */
freez(config->re_filterfile);
+ freez(config->image_blocker_data);
+ freez(config->image_blocker_format);
}
struct configuration_spec * load_config(void)
{
char buf[BUFFER_SIZE];
- char *p, *q;
- FILE *configfp = NULL;
+ char *p, *q, *image_buf, *image_path;
+ FILE *configfp = NULL,
+ *imagefp = NULL;
struct configuration_spec * config = NULL;
struct client_state * fake_csp;
struct file_list *fs;
+ struct stat statbuf[1];
unsigned long linenum = 0;
- int i;
+ int i, file_size, bytes_read;
if ( !check_file_changed(current_configfile, configfile, &fs))
{
#endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
+/* *************************************************************************
+ * image-blocker-custom-file
+ * *************************************************************************/
+ case hash_image_blocker_custom_file :
+ freez(config->image_blocker_data);
+ freez(config->image_blocker_format);
+ config->image_blocker_length = 0;
+ image_path = make_path(config->confdir, arg);
+
+ /*
+ * Load up the custom image bitmap file
+ */
+ if (NULL == (imagefp = fopen(image_path, "rb")))
+ {
+ /*
+ * If we can't open the user's requested image, complain
+ */
+ log_error(LOG_LEVEL_ERROR, "Unable to load custom blocker image: %s.", image_path);
+ }
+ else
+ {
+ if (stat(image_path, statbuf) == 0)
+ {
+ file_size = statbuf->st_size;
+ image_buf = zalloc(file_size);
+ if (image_buf != NULL)
+ {
+ bytes_read = fread(image_buf,1,file_size,imagefp);
+ if (bytes_read > 0)
+ {
+ config->image_blocker_data = image_buf;
+ config->image_blocker_length = file_size;
+ /*
+ * Ensure we can look into files for file signatures
+ */
+ if (file_size > 10)
+ {
+ /*
+ * Snoop into the binary data for a filetype signature
+ */
+ if (memcmp(image_buf,"GIF",3) == 0)
+ config->image_blocker_format = IMAGE_MIMETYPE_GIF;
+ else if (memcmp(&image_buf[6],"JFIF",4) == 0)
+ config->image_blocker_format = IMAGE_MIMETYPE_JPG;
+ else if (memcmp(&image_buf[1],"PNG",3) == 0)
+ config->image_blocker_format = IMAGE_MIMETYPE_PNG;
+ else
+ {
+ log_error(LOG_LEVEL_ERROR, "Unsupported custom image file type.");
+ freez(config->image_blocker_data);
+ }
+ }
+ else
+ freez(config->image_blocker_data);
+ }
+ else
+ {
+ log_error(LOG_LEVEL_ERROR, "Unable to read custom blocker image: %s", image_path, bytes_read, file_size);
+ freez(image_buf);
+ config->image_blocker_length = 0;
+ }
+ }
+ else
+ log_error(LOG_LEVEL_ERROR, "Unable to allocate memory for custom blocker image: %s.", image_path);
+ }
+ else
+ log_error(LOG_LEVEL_ERROR, "Unable to get statistics on custom blocker image file: %s", image_path);
+ }
+ freez(image_path);
+ /*
+ * If our load failed for some reason, just give the default
+ * checkerboard pattern
+ */
+ if (config->image_blocker_data == NULL)
+ {
+ log_error(LOG_LEVEL_ERROR, "Custom blocker image processing failed; defaulting to \"pattern\".");
+ config->image_blocker_data = (char*)image_pattern_data;
+ config->image_blocker_length = image_pattern_length;
+ config->image_blocker_format = BUILTIN_IMAGE_MIMETYPE;
+ }
+ continue;
/* *************************************************************************
* Warnings about unsupported features
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 2.3 2002/09/05 08:00:23 oes Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 2.4 2002/12/28 03:58:19 david__schmidt Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/src/project.h,v $
*
* Revisions :
* $Log: project.h,v $
+ * Revision 2.4 2002/12/28 03:58:19 david__schmidt
+ * Initial drop of dashboard instrumentation - enabled with
+ * --enable-activity-console
+ *
* Revision 2.3 2002/09/05 08:00:23 oes
* Synced with the stable branch:
* Revision 1.72.2.1 2002/08/10 11:25:18 oes
/** Nonzero if we need to bind() to the new port. */
int need_bind;
+
+ /** The raw blocker custom bitmap data */
+ char *image_blocker_data;
+
+ /** The length of the blocker custom image data */
+ size_t image_blocker_length;
+
+ /** The mimetype of the blocker custom image data */
+ char *image_blocker_format;
};
/** Calculates the number of elements in an array, using sizeof. */
#define FORCE_PREFIX "/PRIVOXY-FORCE"
#endif /* def FEATURE_FORCE_LOAD */
+#define IMAGE_MIMETYPE_PNG "image/png"
+#define IMAGE_MIMETYPE_GIF "image/gif"
+#define IMAGE_MIMETYPE_JPG "image/jpg"
+
#ifdef FEATURE_NO_GIFS
-/** The MIME type for images ("image/png" or "image/gif"). */
-#define BUILTIN_IMAGE_MIMETYPE "image/png"
+/** The MIME type for built-in images ("image/png" or "image/gif"). */
+#define BUILTIN_IMAGE_MIMETYPE IMAGE_MIMETYPE_PNG
#else
-#define BUILTIN_IMAGE_MIMETYPE "image/gif"
+#define BUILTIN_IMAGE_MIMETYPE IMAGE_MIMETYPE_GIF
#endif /* def FEATURE_NO_GIFS */
##############################################################################
#
-# File : $Source: /cvsroot/ijbswa//current/templates/edit-actions-for-url,v $
+# File : $Source: /cvsroot/ijbswa/current/templates/edit-actions-for-url,v $
#
# Purpose : Template used to edit the actions associated with a
# particular section in an actions file.
#
# Revisions :
# $Log: edit-actions-for-url,v $
+# Revision 1.30 2002/09/05 16:12:02 oes
+# Synced with stable branch:
+# Revision 1.29.2.3 2002/08/23 02:22:53 hal9
+# Fix a perl brain fart with <li> in comments.
+#
+# Revision 1.29.2.1 2002/08/02 12:51:42 oes
+# Added top submit button; Consistency with docs: Change default name for action from hide-referer to hide-referrer
+#
# Revision 1.29.2.3 2002/08/23 02:22:53 hal9
# Fix a perl brain fart with <li> in comments.
#
<input type="radio" name="set_image_blocker_mode" value="blank"
onclick="set_image_blocker_param_disable(true)"
id="set_image_blocker_mode_blank" @set-image-blocker-param-blank@><label
- for="set_image_blocker_mode_blank">Send a 1x1 transparent GIF</label><br>
+ for="set_image_blocker_mode_blank">Send a 1x1 transparent image</label><br>
+ <input type="radio" name="set_image_blocker_mode" value="custom"
+ onclick="set_image_blocker_param_disable(true)"
+ id="set_image_blocker_mode_custom" @set-image-blocker-param-custom@><label
+ for="set_image_blocker_mode_custom">Send a custom image</label><br>
<input type="radio" name="set_image_blocker_mode" value="CUSTOM"
onclick="set_image_blocker_param_disable(false)"
id="set_image_blocker_mode_set" @set-image-blocker-param-custom@><label