1 const char showargs_rcs[] = "$Id: showargs.c,v 1.17 2001/06/29 21:45:41 oes Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/showargs.c,v $
6 * Purpose : Contains various utility routines needed to
7 * generate the show-proxy-args page.
8 * FIXME: Is this really stuff for a separate file?
10 * Copyright : Written by and Copyright (C) 2001 the SourceForge
11 * IJBSWA team. http://ijbswa.sourceforge.net
13 * Based on the Internet Junkbuster originally written
14 * by and Copyright (C) 1997 Anonymous Coders and
15 * Junkbusters Corporation. http://www.junkbusters.com
17 * This program is free software; you can redistribute it
18 * and/or modify it under the terms of the GNU General
19 * Public License as published by the Free Software
20 * Foundation; either version 2 of the License, or (at
21 * your option) any later version.
23 * This program is distributed in the hope that it will
24 * be useful, but WITHOUT ANY WARRANTY; without even the
25 * implied warranty of MERCHANTABILITY or FITNESS FOR A
26 * PARTICULAR PURPOSE. See the GNU General Public
27 * License for more details.
29 * The GNU General Public License should be included with
30 * this file. If not, you can view it at
31 * http://www.gnu.org/copyleft/gpl.html
32 * or write to the Free Software Foundation, Inc., 59
33 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 * $Log: showargs.c,v $
37 * Revision 1.17 2001/06/29 21:45:41 oes
38 * Indentation, CRLF->LF, Tab-> Space
40 * Revision 1.16 2001/06/29 13:35:07 oes
43 * - Removed init_proxy_args
44 * - Renamed end_proxy_args(csp) to show_rcs(void)
45 * - Removed logentry from cancelled commit
46 * - Destroyed support for ndef SPLIT_PROXY_ARGS (Ooops)
47 * - Separated the #define list into show_defines()
49 * Revision 1.15 2001/06/09 10:55:28 jongfoster
50 * Changing BUFSIZ ==> BUFFER_SIZE
52 * Revision 1.14 2001/06/07 23:15:40 jongfoster
53 * Removing config->proxy_args_gateways
54 * Missing return statement added to end_proxy_args().
56 * Revision 1.13 2001/06/06 09:37:59 sarantis
57 * Fix misplaced comment start.
59 * Revision 1.12 2001/06/04 10:41:52 swa
60 * show version string of cgi.h and cgi.c
62 * Revision 1.11 2001/06/03 11:03:48 oes
63 * moved stuff to cgi.c
65 * Revision 1.10 2001/05/31 21:36:07 jongfoster
66 * Added RCS for actions.[ch] and list.[ch]
68 * Revision 1.9 2001/05/29 23:11:38 oes
70 * - Moved strsav() from showargs to miscutil
72 * Revision 1.8 2001/05/29 09:50:24 jongfoster
73 * Unified blocklist/imagelist/permissionslist.
74 * File format is still under discussion, but the internal changes
77 * Also modified interceptor behaviour:
78 * - We now intercept all URLs beginning with one of the following
79 * prefixes (and *only* these prefixes):
81 * * http://ijbswa.sf.net/config/
82 * * http://ijbswa.sourceforge.net/config/
83 * - New interceptors "home page" - go to http://i.j.b/ to see it.
84 * - Internal changes so that intercepted and fast redirect pages
85 * are not replaced with an image.
86 * - Interceptors now have the option to send a binary page direct
87 * to the client. (i.e. ijb-send-banner uses this)
88 * - Implemented show-url-info interceptor. (Which is why I needed
89 * the above interceptors changes - a typical URL is
90 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
91 * The previous mechanism would not have intercepted that, and
92 * if it had been intercepted then it then it would have replaced
95 * Revision 1.7 2001/05/26 00:28:36 jongfoster
96 * Automatic reloading of config file.
97 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
98 * Most of the global variables have been moved to a new
99 * struct configuration_spec, accessed through csp->config->globalname
100 * Most of the globals remaining are used by the Win32 GUI.
102 * Revision 1.6 2001/05/25 22:32:56 jongfoster
105 * Revision 1.5 2001/05/22 18:54:49 oes
107 * - Enabled filtering banners by size rather than URL
108 * by adding patterns that replace all standard banner
109 * sizes with the "Junkbuster" gif to the re_filterfile
111 * - Enabled filtering WebBugs by providing a pattern
112 * which kills all 1x1 images
114 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
115 * which is selected by the (nonstandard and therefore
116 * capital) letter 'U' in the option string.
117 * It causes the quantifiers to be ungreedy by default.
118 * Appending a ? turns back to greedy (!).
120 * - Added a new interceptor ijb-send-banner, which
121 * sends back the "Junkbuster" gif. Without imagelist or
122 * MSIE detection support, or if tinygif = 1, or the
123 * URL isn't recognized as an imageurl, a lame HTML
124 * explanation is sent instead.
126 * - Added new feature, which permits blocking remote
127 * script redirects and firing back a local redirect
129 * The feature is conditionally compiled, i.e. it
130 * can be disabled with --disable-fast-redirects,
131 * plus it must be activated by a "fast-redirects"
132 * line in the config file, has its own log level
133 * and of course wants to be displayed by show-proxy-args
134 * Note: Boy, all the #ifdefs in 1001 locations and
135 * all the fumbling with configure.in and acconfig.h
136 * were *way* more work than the feature itself :-(
138 * - Because a generic redirect template was needed for
139 * this, tinygif = 3 now uses the same.
141 * - Moved GIFs, and other static HTTP response templates
146 * - Removed some >400 CRs again (Jon, you really worked
149 * Revision 1.4 2001/05/20 16:44:47 jongfoster
150 * Removing last hardcoded JunkBusters.com URLs.
152 * Revision 1.3 2001/05/20 01:21:20 jongfoster
153 * Version 2.9.4 checkin.
154 * - Merged popupfile and cookiefile, and added control over PCRS
155 * filtering, in new "permissionsfile".
156 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
157 * file error you now get a message box (in the Win32 GUI) rather
158 * than the program exiting with no explanation.
159 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
161 * - Removed tabs from "config"
162 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
163 * - Bumped up version number.
165 * Revision 1.2 2001/05/17 23:01:01 oes
166 * - Cleaned CRLF's from the sources and related files
168 * Revision 1.1.1.1 2001/05/15 13:59:03 oes
169 * Initial import of version 2.9.3 source tree
172 *********************************************************************/
178 #include <sys/types.h>
184 #include "showargs.h"
189 #include "miscutil.h"
192 const char showargs_h_rcs[] = SHOWARGS_H_VERSION;
195 /*********************************************************************
199 * Description : Called from `load_config'. It saves each non-empty
200 * and non-comment line from config into a list. This
201 * list is used to create the show-proxy-args page.
204 * 1 : c = config setting that was found
205 * 2 : o = the setting's argument (if any)
209 *********************************************************************/
210 void savearg(char *c, char *o, struct configuration_spec * config)
212 char buf[BUFFER_SIZE];
216 if ( ( NULL != c ) && ( '\0' != *c ) )
218 if ((c = html_encode(c)))
220 sprintf(buf, "<a href=\"" REDIRECT_URL "option#%s\">%s</a> ", c, c);
224 if ( ( NULL != o ) && ( '\0' != *o ) )
226 if ((o = html_encode(o)))
228 if (strncmpic(o, "http://", 7) == 0)
230 strcat(buf, "<a href=\"");
244 strcat(buf, "<br>\n");
246 config->proxy_args = strsav(config->proxy_args, buf);
251 /*********************************************************************
253 * Function : show_rcs
255 * Description : Create a string with the rcs info for all sourcefiles
261 *********************************************************************/
265 char buf[BUFFER_SIZE];
267 /* Instead of including *all* dot h's in the project (thus creating a
268 * tremendous amount of dependencies), I will concede to declaring them
269 * as extern's. This forces the developer to add to this list, but oh well.
272 #define SHOW_RCS(__x) \
274 extern const char __x[]; \
275 sprintf(buf, "%s\n", __x); \
276 b = strsav(b, buf); \
279 /* In alphabetical order */
280 SHOW_RCS(actions_h_rcs)
281 SHOW_RCS(actions_rcs)
285 SHOW_RCS(cygwin_h_rcs)
287 SHOW_RCS(encode_h_rcs)
289 SHOW_RCS(errlog_h_rcs)
291 SHOW_RCS(filters_h_rcs)
292 SHOW_RCS(filters_rcs)
293 SHOW_RCS(gateway_h_rcs)
294 SHOW_RCS(gateway_rcs)
296 SHOW_RCS(gnu_regex_h_rcs)
297 SHOW_RCS(gnu_regex_rcs)
298 #endif /* def GNU_REGEX */
299 SHOW_RCS(jbsockets_h_rcs)
300 SHOW_RCS(jbsockets_rcs)
304 SHOW_RCS(killpopup_h_rcs)
305 SHOW_RCS(killpopup_rcs)
306 #endif /* def KILLPOPUPS */
309 SHOW_RCS(loadcfg_h_rcs)
310 SHOW_RCS(loadcfg_rcs)
311 SHOW_RCS(loaders_h_rcs)
312 SHOW_RCS(loaders_rcs)
313 SHOW_RCS(miscutil_h_rcs)
314 SHOW_RCS(miscutil_rcs)
315 SHOW_RCS(parsers_h_rcs)
316 SHOW_RCS(parsers_rcs)
320 #endif /* def PCRS */
321 SHOW_RCS(project_h_rcs)
322 SHOW_RCS(showargs_h_rcs)
323 SHOW_RCS(showargs_rcs)
324 SHOW_RCS(ssplit_h_rcs)
328 SHOW_RCS(w32log_h_rcs)
330 SHOW_RCS(w32res_h_rcs)
331 SHOW_RCS(w32rulesdlg_h_rcs)
332 SHOW_RCS(w32rulesdlg_rcs)
333 SHOW_RCS(w32taskbar_h_rcs)
334 SHOW_RCS(w32taskbar_rcs)
335 #endif /* ndef _WIN_CONSOLE */
336 SHOW_RCS(win32_h_rcs)
338 #endif /* def _WIN32 */
345 /*********************************************************************
347 * Function : show_defines
349 * Description : Create a string with all conditional #defines used
356 *********************************************************************/
357 char *show_defines(void)
362 b = strsav(b, " <li><code>#define <b>REGEX</b></code> - Support for regular expressions in the path specs.</li>\n");
363 #else /* ifndef REGEX */
364 b = strsav(b, " <li><code>#undef <b>REGEX</b></code> - No support for regular expressions in the path specs.</li>\n");
365 #endif /* ndef REGEX */
368 b = strsav(b, " <li><code>#define <b>PCRE</b></code> - Use PCRE rather than old GNU regex library.</li>\n");
369 #else /* ifndef PCRE */
370 b = strsav(b, " <li><code>#undef <b>PCRE</b></code> - Use old GNU regex library rather than PCRE.</li>\n");
371 #endif /* ndef PCRE */
374 b = strsav(b, " <li><code>#define <b>PCRS</b></code> - Enables arbitrary content modification regexps.</li>\n");
375 #else /* ifndef PCRS */
376 b = strsav(b, " <li><code>#undef <b>PCRS</b></code> - Disables arbitrary content modification regexps.</li>\n");
377 #endif /* ndef PCRS */
380 b = strsav(b, " <li><code>#define <b>TOGGLE</b></code> - Allow JunkBuster to be \"disabled\" so it is just a normal non-blocking non-anonymizing proxy.</li>\n");
381 #else /* ifndef TOGGLE */
382 b = strsav(b, " <li><code>#undef <b>TOGGLE</b></code> - Do not allow JunkBuster to be \"disabled\" so it is just a normal non-blocking non-anonymizing proxy.</li>\n");
383 #endif /* ndef TOGGLE */
386 b = strsav(b, " <li><code>#define <b>FORCE_LOAD</b></code> - Enables bypassing filtering for a single page using the prefix \"" FORCE_PREFIX "\".</li>\n");
387 #else /* ifndef FORCE_LOAD */
388 b = strsav(b, " <li><code>#undef <b>FORCE_LOAD</b></code> - Disables bypassing filtering for a single page.</li>\n");
389 #endif /* ndef FORCE_LOAD */
392 b = strsav(b, " <li><code>#define <b>DENY_GZIP</b></code> - Prevents requests from being compressed - required for PCRS on some sites.</li>\n");
393 #else /* ifndef DENY_GZIP */
394 b = strsav(b, " <li><code>#undef <b>DENY_GZIP</b></code> - Allows requests to be compressed if the browser and server support it.</li>\n");
395 #endif /* ndef DENY_GZIP */
398 b = strsav(b, " <li><code>#define <b>STATISTICS</b></code> - Enables statistics function.</li>\n");
399 #else /* ifndef STATISTICS */
400 b = strsav(b, " <li><code>#undef <b>STATISTICS</b></code> - Disables statistics function.</li>\n");
401 #endif /* ndef STATISTICS */
403 #ifdef SPLIT_PROXY_ARGS
404 b = strsav(b, " <li><code>#define <b>SPLIT_PROXY_ARGS</b></code> - Split this page up by placing the configuration files on separate pages.</li>\n");
405 #else /* ifndef SPLIT_PROXY_ARGS */
406 b = strsav(b, " <li><code>#undef <b>SPLIT_PROXY_ARGS</b></code> - This page contains the text of the configuration files, they are not split onto separate pages.</li>\n");
407 #endif /* ndef SPLIT_PROXY_ARGS */
410 b = strsav(b, " <li><code>#define <b>KILLPOPUPS</b></code> - Enables killing JavaScript popups.</li>\n");
411 #else /* ifndef KILLPOPUPS */
412 b = strsav(b, " <li><code>#undef <b>KILLPOPUPS</b></code> - Disables killing JavaScript popups.</li>\n");
413 #endif /* ndef KILLPOPUPS */
416 b = strsav(b, " <li><code>#define <b>WEBDAV</b></code> - Enables support for webDAV - e.g. stops Microsoft Outlook from accessing HotMail e-mail.</li>\n");
417 #else /* ifndef WEBDAV */
418 b = strsav(b, " <li><code>#undef <b>WEBDAV</b></code> - Disables support for webDAV - e.g. so Microsoft Outlook can access HotMail e-mail.</li>\n");
419 #endif /* ndef WEBDAV */
421 #ifdef DETECT_MSIE_IMAGES
422 b = strsav(b, " <li><code>#define <b>DETECT_MSIE_IMAGES</b></code> - Enables detecting image requests automatically for MSIE.</li>\n");
423 #else /* ifndef DETECT_MSIE_IMAGES */
424 b = strsav(b, " <li><code>#undef <b>DETECT_MSIE_IMAGES</b></code> - Disables detecting image requests automatically for MSIE.</li>\n");
425 #endif /* ndef DETECT_MSIE_IMAGES */
427 #ifdef IMAGE_BLOCKING
428 b = strsav(b, " <li><code>#define <b>IMAGE_BLOCKING</b></code> - Enables sending \"blocked\" images instead of HTML.</li>\n");
429 #else /* ifndef IMAGE_BLOCKING */
430 b = strsav(b, " <li><code>#undef <b>IMAGE_BLOCKING</b></code> - Disables sending \"blocked\" images instead of HTML.</li>\n");
431 #endif /* ndef IMAGE_BLOCKING */
434 b = strsav(b, " <li><code>#define <b>ACL_FILES</b></code> - Enables the use of ACL files to control access to the proxy by IP address.</li>\n");
435 #else /* ifndef ACL_FILES */
436 b = strsav(b, " <li><code>#undef <b>ACL_FILES</b></code> - Disables the use of ACL files to control access to the proxy by IP address.</li>\n");
437 #endif /* ndef ACL_FILES */
440 b = strsav(b, " <li><code>#define <b>TRUST_FILES</b></code> - Enables the use of trust files.</li>\n");
441 #else /* ifndef TRUST_FILES */
442 b = strsav(b, " <li><code>#undef <b>TRUST_FILES</b></code> - Disables the use of trust files.</li>\n");
443 #endif /* ndef TRUST_FILES */
446 b = strsav(b, " <li><code>#define <b>JAR_FILES</b></code> - Enables the use of jar files to capture cookies.</li>\n");
447 #else /* ifndef JAR_FILES */
448 b = strsav(b, " <li><code>#undef <b>JAR_FILES</b></code> - Disables the use of jar files to capture cookies.</li>\n");
449 #endif /* ndef JAR_FILES */
451 #ifdef FAST_REDIRECTS
452 b = strsav(b, " <li><code>#define <b>FAST_REDIRECTS</b></code> - Enables intercepting remote script redirects.</li>\n");
453 #else /* ifndef FAST_REDIRECTS */
454 b = strsav(b, " <li><code>#undef <b>FAST_REDIRECTS</b></code> - Disables intercepting remote script redirects.</li>\n");
455 #endif /* ndef FAST_REDIRECTS */