- Added remote (server) host IP to csp->http->host_ip_addr_str
[privoxy.git] / filters.h
1 #ifndef _FILTERS_H
2 #define _FILTERS_H
3 #define FILTERS_H_VERSION "$Id: filters.h,v 1.9 2001/06/07 23:10:53 jongfoster Exp $"
4 /*********************************************************************
5  *
6  * File        :  $Source: /cvsroot/ijbswa/current/filters.h,v $
7  *
8  * Purpose     :  Declares functions to parse/crunch headers and pages.
9  *                Functions declared include:
10  *                   `acl_addr', `add_stats', `block_acl', `block_imageurl',
11  *                   `block_url', `url_actions', `domaincmp', `dsplit',
12  *                   `filter_popups', `forward_url'
13  *                   `ij_untrusted_url', `intercept_url', `re_process_buffer',
14  *                   `show_proxy_args', and `trust_url'
15  *
16  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
17  *                IJBSWA team.  http://ijbswa.sourceforge.net
18  *
19  *                Based on the Internet Junkbuster originally written
20  *                by and Copyright (C) 1997 Anonymous Coders and 
21  *                Junkbusters Corporation.  http://www.junkbusters.com
22  *
23  *                This program is free software; you can redistribute it 
24  *                and/or modify it under the terms of the GNU General
25  *                Public License as published by the Free Software
26  *                Foundation; either version 2 of the License, or (at
27  *                your option) any later version.
28  *
29  *                This program is distributed in the hope that it will
30  *                be useful, but WITHOUT ANY WARRANTY; without even the
31  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
32  *                PARTICULAR PURPOSE.  See the GNU General Public
33  *                License for more details.
34  *
35  *                The GNU General Public License should be included with
36  *                this file.  If not, you can view it at
37  *                http://www.gnu.org/copyleft/gpl.html
38  *                or write to the Free Software Foundation, Inc., 59
39  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
40  *
41  * Revisions   :
42  *    $Log: filters.h,v $
43  *    Revision 1.9  2001/06/07 23:10:53  jongfoster
44  *    Replacing struct gateway with struct forward_spec
45  *
46  *    Revision 1.8  2001/06/03 19:12:00  oes
47  *    extracted-CGI relevant stuff
48  *
49  *    Revision 1.7  2001/05/31 21:21:30  jongfoster
50  *    Permissionsfile / actions file changes:
51  *    - Changed "permission" to "action" throughout
52  *    - changes to file format to allow string parameters
53  *    - Moved helper functions to actions.c
54  *
55  *    Revision 1.6  2001/05/29 09:50:24  jongfoster
56  *    Unified blocklist/imagelist/permissionslist.
57  *    File format is still under discussion, but the internal changes
58  *    are (mostly) done.
59  *
60  *    Also modified interceptor behaviour:
61  *    - We now intercept all URLs beginning with one of the following
62  *      prefixes (and *only* these prefixes):
63  *        * http://i.j.b/
64  *        * http://ijbswa.sf.net/config/
65  *        * http://ijbswa.sourceforge.net/config/
66  *    - New interceptors "home page" - go to http://i.j.b/ to see it.
67  *    - Internal changes so that intercepted and fast redirect pages
68  *      are not replaced with an image.
69  *    - Interceptors now have the option to send a binary page direct
70  *      to the client. (i.e. ijb-send-banner uses this)
71  *    - Implemented show-url-info interceptor.  (Which is why I needed
72  *      the above interceptors changes - a typical URL is
73  *      "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
74  *      The previous mechanism would not have intercepted that, and
75  *      if it had been intercepted then it then it would have replaced
76  *      it with an image.)
77  *
78  *    Revision 1.5  2001/05/27 22:17:04  oes
79  *
80  *    - re_process_buffer no longer writes the modified buffer
81  *      to the client, which was very ugly. It now returns the
82  *      buffer, which it is then written by chat.
83  *
84  *    - content_length now adjusts the Content-Length: header
85  *      for modified documents rather than crunch()ing it.
86  *      (Length info in csp->content_length, which is 0 for
87  *      unmodified documents)
88  *
89  *    - For this to work, sed() is called twice when filtering.
90  *
91  *    Revision 1.4  2001/05/26 15:26:15  jongfoster
92  *    ACL feature now provides more security by immediately dropping
93  *    connections from untrusted hosts.
94  *
95  *    Revision 1.3  2001/05/22 18:46:04  oes
96  *
97  *    - Enabled filtering banners by size rather than URL
98  *      by adding patterns that replace all standard banner
99  *      sizes with the "Junkbuster" gif to the re_filterfile
100  *
101  *    - Enabled filtering WebBugs by providing a pattern
102  *      which kills all 1x1 images
103  *
104  *    - Added support for PCRE_UNGREEDY behaviour to pcrs,
105  *      which is selected by the (nonstandard and therefore
106  *      capital) letter 'U' in the option string.
107  *      It causes the quantifiers to be ungreedy by default.
108  *      Appending a ? turns back to greedy (!).
109  *
110  *    - Added a new interceptor ijb-send-banner, which
111  *      sends back the "Junkbuster" gif. Without imagelist or
112  *      MSIE detection support, or if tinygif = 1, or the
113  *      URL isn't recognized as an imageurl, a lame HTML
114  *      explanation is sent instead.
115  *
116  *    - Added new feature, which permits blocking remote
117  *      script redirects and firing back a local redirect
118  *      to the browser.
119  *      The feature is conditionally compiled, i.e. it
120  *      can be disabled with --disable-fast-redirects,
121  *      plus it must be activated by a "fast-redirects"
122  *      line in the config file, has its own log level
123  *      and of course wants to be displayed by show-proxy-args
124  *      Note: Boy, all the #ifdefs in 1001 locations and
125  *      all the fumbling with configure.in and acconfig.h
126  *      were *way* more work than the feature itself :-(
127  *
128  *    - Because a generic redirect template was needed for
129  *      this, tinygif = 3 now uses the same.
130  *
131  *    - Moved GIFs, and other static HTTP response templates
132  *      to project.h
133  *
134  *    - Some minor fixes
135  *
136  *    - Removed some >400 CRs again (Jon, you really worked
137  *      a lot! ;-)
138  *
139  *    Revision 1.2  2001/05/20 01:21:20  jongfoster
140  *    Version 2.9.4 checkin.
141  *    - Merged popupfile and cookiefile, and added control over PCRS
142  *      filtering, in new "permissionsfile".
143  *    - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
144  *      file error you now get a message box (in the Win32 GUI) rather
145  *      than the program exiting with no explanation.
146  *    - Made killpopup use the PCRS MIME-type checking and HTTP-header
147  *      skipping.
148  *    - Removed tabs from "config"
149  *    - Moved duplicated url parsing code in "loaders.c" to a new funcition.
150  *    - Bumped up version number.
151  *
152  *    Revision 1.1.1.1  2001/05/15 13:58:52  oes
153  *    Initial import of version 2.9.3 source tree
154  *
155  *
156  *********************************************************************/
157 \f
158
159 #include "project.h"
160
161 #ifdef __cplusplus
162 extern "C" {
163 #endif
164
165 /*
166  * ACL checking
167  */
168 #ifdef ACL_FILES
169 extern int block_acl(struct access_control_addr *dst, struct client_state *csp);
170 extern int acl_addr(char *aspec, struct access_control_addr *aca);
171 #endif /* def ACL_FILES */
172
173 /*
174  * Interceptors
175  */
176 extern struct http_response *block_url(struct client_state *csp);
177 extern struct http_response *redirect_url(struct client_state *csp);
178 #ifdef TRUST_FILES
179 extern struct http_response *trust_url(struct client_state *csp);
180 #endif /* def TRUST_FILES */
181
182 /*
183  * Request inspectors
184  */
185 #ifdef TRUST_FILES
186 extern int is_untrusted_url(struct client_state *csp);
187 #endif /* def TRUST_FILES */
188 #ifdef IMAGE_BLOCKING
189 extern int is_imageurl(struct client_state *csp);
190 #endif /* def IMAGE_BLOCKING */
191
192 /*
193  * Determining applicable actions
194  */
195 extern void url_actions(struct http_request *http, 
196                         struct client_state *csp);
197 extern void apply_url_actions(struct current_action_spec *action, 
198                               struct http_request *http, 
199                               struct url_actions *b);
200 /*
201  * Determining parent proxies
202  */
203 extern const struct forward_spec *forward_url(struct http_request *http, struct client_state *csp);
204
205 extern struct url_spec dsplit(char *domain);
206 extern int domaincmp(struct url_spec *pattern, struct url_spec *fqdn);
207
208 /*
209  * Content modification
210  */
211 #ifdef PCRS
212 extern char *re_process_buffer(struct client_state *csp);
213 #endif /* def PCRS */
214
215 /* Revision control strings from this header and associated .c file */
216 extern const char filters_rcs[];
217 extern const char filters_h_rcs[];
218
219 #ifdef __cplusplus
220 } /* extern "C" */
221 #endif
222
223 #endif /* ndef _FILTERS_H */
224
225 /*
226   Local Variables:
227   tab-width: 3
228   end:
229 */