1 #ifndef PROJECT_H_INCLUDED
2 #define PROJECT_H_INCLUDED
3 #define PROJECT_H_VERSION "$Id: project.h,v 1.42 2001/11/05 21:42:41 steudten Exp $"
4 /*********************************************************************
6 * File : $Source: /cvsroot/ijbswa/current/project.h,v $
8 * Purpose : Defines data structures which are widely used in the
9 * project. Does not define any variables or functions
10 * (though it does declare some macros).
12 * Copyright : Written by and Copyright (C) 2001 the SourceForge
13 * IJBSWA team. http://ijbswa.sourceforge.net
15 * Based on the Internet Junkbuster originally written
16 * by and Copyright (C) 1997 Anonymous Coders and
17 * Junkbusters Corporation. http://www.junkbusters.com
19 * This program is free software; you can redistribute it
20 * and/or modify it under the terms of the GNU General
21 * Public License as published by the Free Software
22 * Foundation; either version 2 of the License, or (at
23 * your option) any later version.
25 * This program is distributed in the hope that it will
26 * be useful, but WITHOUT ANY WARRANTY; without even the
27 * implied warranty of MERCHANTABILITY or FITNESS FOR A
28 * PARTICULAR PURPOSE. See the GNU General Public
29 * License for more details.
31 * The GNU General Public License should be included with
32 * this file. If not, you can view it at
33 * http://www.gnu.org/copyleft/gpl.html
34 * or write to the Free Software Foundation, Inc., 59
35 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 * Revision 1.42 2001/11/05 21:42:41 steudten
40 * Include DBG() macro.
42 * Revision 1.41 2001/10/28 19:12:06 jongfoster
43 * Adding ijb_toupper()
45 * Revision 1.40 2001/10/26 17:40:47 oes
46 * Moved ijb_isspace and ijb_tolower to project.h
47 * Removed http->user_agent, csp->referrer and csp->accept_types
49 * Revision 1.39 2001/10/25 03:45:02 david__schmidt
50 * Adding a (void*) cast to freez() because Visual Age C++ won't expand the
51 * macro when called with a cast; so moving the cast to the macro def'n
52 * seems to both eliminate compiler warnings (on darwin and OS/2, anyway) and
53 * doesn't make macro expansion complain. Hope this works for everyone else
56 * Revision 1.38 2001/10/23 21:19:04 jongfoster
57 * New error-handling support: jb_err type and JB_ERR_xxx constants
58 * CGI functions now return a jb_err, and their parameters map is const.
59 * Support for RUNTIME_FEATUREs to enable/disable config editor
60 * Adding a few comments
62 * Revision 1.37 2001/10/14 22:14:01 jongfoster
63 * Removing name_length field from struct cgi_dispatcher, as this is
64 * now calculated at runtime from the "name" field.
66 * Revision 1.36 2001/10/10 16:45:15 oes
67 * Added LIMIT_CONNECT action and string
68 * Fixed HTTP message line termination
69 * Added CFORBIDDEN HTTP message
71 * Revision 1.35 2001/10/07 18:06:43 oes
72 * Added status member to struct http_request
74 * Revision 1.34 2001/10/07 15:45:25 oes
75 * Added url member to struct http_request and commented all
80 * Added ACTION_DOWNGRADE and ACTION_NO_COMPRESSION
82 * Replaced struct client_state members rejected,
83 * force, active and toggled_on with "flags" bitmap.
85 * Added CSP_FLAG_MODIFIED and CSP_FLAG_CHUNKED
87 * Added buffer_limit to struct configuration_spec
89 * Revision 1.33 2001/09/20 13:30:08 steudten
91 * Make freez() more secure in case of: if (exp) { free(z) ; a=*z }
92 * Last case will set z to NULL in free(z) and thats bad..
94 * Revision 1.32 2001/09/16 23:02:51 jongfoster
97 * Revision 1.31 2001/09/16 13:20:29 jongfoster
98 * Rewrite of list library. Now has seperate header and list_entry
99 * structures. Also added a large sprinking of assert()s to the list
102 * Revision 1.30 2001/09/13 23:52:00 jongfoster
103 * Support for both static and dynamically generated CGI pages
105 * Revision 1.29 2001/09/13 23:29:43 jongfoster
106 * Defining FORWARD_SPEC_INITIALIZER
108 * Revision 1.28 2001/09/13 23:05:50 jongfoster
109 * Changing the string paramater to the header parsers a "const".
111 * Revision 1.27 2001/08/05 16:06:20 jongfoster
112 * Modifiying "struct map" so that there are now separate header and
113 * "map_entry" structures. This means that functions which modify a
114 * map no longer need to return a pointer to the modified map.
115 * Also, it no longer reverses the order of the entries (which may be
116 * important with some advanced template substitutions).
118 * Revision 1.26 2001/07/30 22:08:36 jongfoster
119 * Tidying up #defines:
120 * - All feature #defines are now of the form FEATURE_xxx
121 * - Permanently turned off WIN_GUI_EDIT
122 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
124 * Revision 1.25 2001/07/29 18:43:08 jongfoster
125 * Changing #ifdef _FILENAME_H to FILENAME_H_INCLUDED, to conform to
128 * Revision 1.24 2001/07/25 17:20:27 oes
129 * Introduced http->user_agent
131 * Revision 1.23 2001/07/18 12:32:23 oes
132 * - Added ACTION_STRING_DEANIMATE
133 * - moved #define freez from jcc.h to project.h
135 * Revision 1.22 2001/07/15 17:51:41 jongfoster
136 * Renaming #define STATIC to STATIC_PCRE
138 * Revision 1.21 2001/07/13 14:03:19 oes
139 * - Reorganized regex header inclusion and #defines to
140 * comply to the scheme in configure.in
141 * - Added csp->content_type and its CT_* keys
142 * - Added ACTION_DEANIMATE
143 * - Removed all #ifdef PCRS
145 * Revision 1.20 2001/06/29 21:45:41 oes
146 * Indentation, CRLF->LF, Tab-> Space
148 * Revision 1.19 2001/06/29 13:33:36 oes
149 * - Improved comments
150 * - Introduced http_request.host_ip_addr_str
151 * - Introduced http_response.head_length
152 * - Introduced config.my_ip_addr_str, config.my_hostname,
153 * config.admin_address and config.proxy_info_url
154 * - Removed config.proxy_args_header and config.proxy_args_trailer,
155 * renamed config.proxy_args_invocation to config.proxy_args
156 * - Removed HTML snipplets and GIFs
157 * - Removed logentry from cancelled commit
159 * Revision 1.18 2001/06/09 10:57:39 jongfoster
160 * Adding definition of BUFFER_SIZE.
161 * Changing struct cgi_dispatcher to use "const" strings.
163 * Revision 1.17 2001/06/07 23:15:09 jongfoster
164 * Merging ACL and forward files into config file.
165 * Moving struct gateway members into struct forward_spec
166 * Removing config->proxy_args_gateways
167 * Cosmetic: Adding a few comments
169 * Revision 1.16 2001/06/04 18:31:58 swa
170 * files are now prefixed with either `confdir' or `logdir'.
171 * `make redhat-dist' replaces both entries confdir and logdir
174 * Revision 1.15 2001/06/04 11:28:53 swa
175 * redirect did not work due to missing /
177 * Revision 1.14 2001/06/03 11:03:48 oes
179 * added struct http_response,
180 * changed struct interceptors to struct cgi_dispatcher,
181 * moved HTML stuff to cgi.h
183 * Revision 1.13 2001/06/01 20:05:36 jongfoster
184 * Support for +image-blocker{}: added ACTION_IMAGE_BLOCKER
185 * constant, and removed csp->tinygif.
187 * Revision 1.12 2001/06/01 18:49:17 jongfoster
188 * Replaced "list_share" with "list" - the tiny memory gain was not
189 * worth the extra complexity.
191 * Revision 1.11 2001/06/01 10:32:47 oes
192 * Added constants for anchoring selection bitmap
194 * Revision 1.10 2001/05/31 21:33:53 jongfoster
195 * Changes for new actions file, replacing permissionsfile
196 * and parts of the config file. Also added support for
199 * Revision 1.9 2001/05/31 17:32:31 oes
201 * - Enhanced domain part globbing with infix and prefix asterisk
202 * matching and optional unanchored operation
204 * Revision 1.8 2001/05/29 20:09:15 joergs
205 * HTTP_REDIRECT_TEMPLATE fixed.
207 * Revision 1.7 2001/05/29 09:50:24 jongfoster
208 * Unified blocklist/imagelist/actionslist.
209 * File format is still under discussion, but the internal changes
212 * Also modified interceptor behaviour:
213 * - We now intercept all URLs beginning with one of the following
214 * prefixes (and *only* these prefixes):
216 * * http://ijbswa.sf.net/config/
217 * * http://ijbswa.sourceforge.net/config/
218 * - New interceptors "home page" - go to http://i.j.b/ to see it.
219 * - Internal changes so that intercepted and fast redirect pages
220 * are not replaced with an image.
221 * - Interceptors now have the option to send a binary page direct
222 * to the client. (i.e. ijb-send-banner uses this)
223 * - Implemented show-url-info interceptor. (Which is why I needed
224 * the above interceptors changes - a typical URL is
225 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
226 * The previous mechanism would not have intercepted that, and
227 * if it had been intercepted then it then it would have replaced
230 * Revision 1.6 2001/05/27 22:17:04 oes
232 * - re_process_buffer no longer writes the modified buffer
233 * to the client, which was very ugly. It now returns the
234 * buffer, which it is then written by chat.
236 * - content_length now adjusts the Content-Length: header
237 * for modified documents rather than crunch()ing it.
238 * (Length info in csp->content_length, which is 0 for
239 * unmodified documents)
241 * - For this to work, sed() is called twice when filtering.
243 * Revision 1.5 2001/05/26 00:28:36 jongfoster
244 * Automatic reloading of config file.
245 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
246 * Most of the global variables have been moved to a new
247 * struct configuration_spec, accessed through csp->config->globalname
248 * Most of the globals remaining are used by the Win32 GUI.
250 * Revision 1.4 2001/05/22 18:46:04 oes
252 * - Enabled filtering banners by size rather than URL
253 * by adding patterns that replace all standard banner
254 * sizes with the "Junkbuster" gif to the re_filterfile
256 * - Enabled filtering WebBugs by providing a pattern
257 * which kills all 1x1 images
259 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
260 * which is selected by the (nonstandard and therefore
261 * capital) letter 'U' in the option string.
262 * It causes the quantifiers to be ungreedy by default.
263 * Appending a ? turns back to greedy (!).
265 * - Added a new interceptor ijb-send-banner, which
266 * sends back the "Junkbuster" gif. Without imagelist or
267 * MSIE detection support, or if tinygif = 1, or the
268 * URL isn't recognized as an imageurl, a lame HTML
269 * explanation is sent instead.
271 * - Added new feature, which permits blocking remote
272 * script redirects and firing back a local redirect
274 * The feature is conditionally compiled, i.e. it
275 * can be disabled with --disable-fast-redirects,
276 * plus it must be activated by a "fast-redirects"
277 * line in the config file, has its own log level
278 * and of course wants to be displayed by show-proxy-args
279 * Note: Boy, all the #ifdefs in 1001 locations and
280 * all the fumbling with configure.in and acconfig.h
281 * were *way* more work than the feature itself :-(
283 * - Because a generic redirect template was needed for
284 * this, tinygif = 3 now uses the same.
286 * - Moved GIFs, and other static HTTP response templates
291 * - Removed some >400 CRs again (Jon, you really worked
294 * Revision 1.3 2001/05/20 01:21:20 jongfoster
295 * Version 2.9.4 checkin.
296 * - Merged popupfile and cookiefile, and added control over PCRS
297 * filtering, in new "actionsfile".
298 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
299 * file error you now get a message box (in the Win32 GUI) rather
300 * than the program exiting with no explanation.
301 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
303 * - Removed tabs from "config"
304 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
305 * - Bumped up version number.
307 * Revision 1.2 2001/05/17 23:01:01 oes
308 * - Cleaned CRLF's from the sources and related files
310 * Revision 1.1.1.1 2001/05/15 13:59:03 oes
311 * Initial import of version 2.9.3 source tree
314 *********************************************************************/
317 /* Declare struct FILE for vars and funcs. */
320 /* Need time_t for file_list */
324 * Include appropriate regular expression libraries.
325 * Note that pcrs and pcre (native) are needed for cgi
326 * and are included anyway.
329 #if defined(REGEX_PCRE) || defined (REGEX_GNU)
331 #endif /* defined(REGEX_PCRE) || defined (REGEX_GNU) */
345 #if defined(REGEX_PCRE)
347 # include "pcreposix.h"
349 # include <pcreposix.h>
351 #endif /* defined(REGEX_PCRE) */
353 #if defined(REGEX_GNU)
354 # include "gnu_regex.h"
359 #endif /* def AMIGA */
367 #define DBG(a,b) { if ( ldebug >= a ) { printf b ; }}
375 * Error codes. Functions returning these should return a jb_err
377 #define JB_ERR_OK 0 /* Success, no error */
378 #define JB_ERR_MEMORY 1 /* Out of memory */
379 #define JB_ERR_CGI_PARAMS 2 /* Missing or corrupt CGI parameters */
380 #define JB_ERR_FILE 3 /* Error opening, reading or writing a file */
381 #define JB_ERR_PARSE 4 /* Error parsing file */
382 #define JB_ERR_MODIFIED 5 /* File has been modified outside of the */
383 /* CGI actions editor. */
388 * This macro is used to free a pointer that may be NULL
390 #define freez(X) { if(X) { free((void*)X); X = NULL ; } }
393 /* Fix a problem with Solaris. There should be no effect on other
395 * Solaris's isspace() is a macro which uses it's argument directly
396 * as an array index. Therefore we need to make sure that high-bit
397 * characters generate +ve values, and ideally we also want to make
398 * the argument match the declared parameter type of "int".
400 * Note: Remember to #include <ctype.h> if you use these macros.
402 #define ijb_toupper(__X) toupper((int)(unsigned char)(__X))
403 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
404 #define ijb_isspace(__X) isspace((int)(unsigned char)(__X))
407 * Use for statically allocated buffers if you have no other choice.
408 * Remember to check the length of what you write into the buffer
409 * - we don't want any buffer overflows!
411 #define BUFFER_SIZE 5000
414 * So you can say "while (FOREVER) { ...do something... }"
418 /* Default IP and port to listen on */
419 #define HADDR_DEFAULT "127.0.0.1"
420 #define HADDR_PORT 8000
423 /* Forward defs for various structures */
425 /* Need this for struct client_state */
426 struct configuration_spec;
429 /* Generic linked list of strings */
434 struct list_entry *next;
439 struct list_entry *first;
440 struct list_entry *last;
444 /* A map from a string to another string */
450 struct map_entry *next;
455 struct map_entry *first;
456 struct map_entry *last;
462 char *cmd; /* Whole command line: method, URL, Version */
463 char *gpc; /* HTTP method: GET, POST, .. */
464 char *url; /* The URL */
465 char *ver; /* Protocol version */
466 int status; /* HTTP Status */
468 char *host; /* Host part of URL */
469 int port; /* Port of URL or 80 (default) */
470 char *path; /* Path of URL */
471 char *hostport; /* host[:port] */
472 int ssl; /* Flag if protocol is https */
474 char *host_ip_addr_str; /* String with dotted decimal representation
475 * of host's IP. NULL before connect_to() */
478 /* Response generated by CGI, blocker, or error handler */
481 char *status; /* HTTP status (string)*/
482 struct list headers[1]; /* List of header lines */
483 char *head; /* Formatted http response head */
484 int head_length; /* Length of http response head */
485 char *body; /* HTTP document body */
486 int content_length; /* Length of body, REQUIRED if binary body */
487 int is_static; /* Nonzero if the content will never change and
488 * should be cached by the broser (e.g. images) */
494 char *spec; /* The string which was parsed to produce this */
495 /* url_spec. Used for debugging or display only. */
497 /* Hostname matching: */
498 char *domain; /* Fully qalified domain name (FQDN) pattern. */
499 /* May contain "*". */
500 char *dbuf; /* Buffer with '\0'-delimited fqdn */
501 char **dvec; /* Domain ptr vector into dbuf */
502 int dcnt; /* How many domains in fqdn? */
503 int unanchored; /* Bitmap - flags are ANCHOR_LEFT and ANCHOR_RIGHT */
506 int port; /* The port number, or 0 to match all ports. */
509 char *path; /* The path prefix (if not using regex), or source */
511 int pathlen; /* ==strlen(path). Needed for prefix matching. */
513 regex_t *preg; /* Regex for matching path part */
517 #define URL_SPEC_INITIALIZER { NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL }
518 #else /* ifndef REGEX */
519 #define URL_SPEC_INITIALIZER { NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0 }
520 #endif /* ndef REGEX */
522 /* Constants for host part matching in URLs */
523 #define ANCHOR_LEFT 1
524 #define ANCHOR_RIGHT 2
536 #define IOB_PEEK(CSP) ((CSP->iob->cur > CSP->iob->eod) ? (CSP->iob->eod - CSP->iob->cur) : 0)
537 #define IOB_RESET(CSP) if(CSP->iob->buf) free(CSP->iob->buf); memset(CSP->iob, '\0', sizeof(CSP->iob));
539 /* Keys for csp->content_type */
540 #define CT_TEXT 1 /* Suitable for pcrs filtering */
541 #define CT_GIF 2 /* Suitable for GIF filtering */
542 #define CT_TABOO 3 /* DONT filter */
544 #define ACTION_MASK_ALL (~0U)
546 #define ACTION_MOST_COMPATIBLE 0x00000000UL
548 #define ACTION_BLOCK 0x00000001UL
549 #define ACTION_DEANIMATE 0x00000002UL
550 #define ACTION_DOWNGRADE 0x00000004UL
551 #define ACTION_FAST_REDIRECTS 0x00000008UL
552 #define ACTION_FILTER 0x00000010UL
553 #define ACTION_HIDE_FORWARDED 0x00000020UL
554 #define ACTION_HIDE_FROM 0x00000040UL
555 #define ACTION_HIDE_REFERER 0x00000080UL /* sic - follow HTTP, not English */
556 #define ACTION_HIDE_USER_AGENT 0x00000100UL
557 #define ACTION_IMAGE 0x00000200UL
558 #define ACTION_IMAGE_BLOCKER 0x00000400UL
559 #define ACTION_NO_COMPRESSION 0x00000800UL
560 #define ACTION_NO_COOKIE_KEEP 0x00001000UL
561 #define ACTION_NO_COOKIE_READ 0x00002000UL
562 #define ACTION_NO_COOKIE_SET 0x00004000UL
563 #define ACTION_NO_POPUPS 0x00008000UL
564 #define ACTION_VANILLA_WAFER 0x00010000UL
565 #define ACTION_LIMIT_CONNECT 0x00020000UL
567 #define ACTION_STRING_DEANIMATE 0
568 #define ACTION_STRING_FROM 1
569 #define ACTION_STRING_IMAGE_BLOCKER 2
570 #define ACTION_STRING_REFERER 3
571 #define ACTION_STRING_USER_AGENT 4
572 #define ACTION_STRING_LIMIT_CONNECT 5
573 #define ACTION_STRING_COUNT 6
575 #define ACTION_MULTI_ADD_HEADER 0
576 #define ACTION_MULTI_WAFER 1
577 #define ACTION_MULTI_COUNT 2
580 * This structure contains a list of actions to apply to a URL.
581 * It only contains positive instructions - no "-" options.
582 * It is not used to store the actions list itself, only for
583 * url_actions() to return the current values.
585 struct current_action_spec
587 unsigned long flags; /* a bit set to "1" = add action */
589 /* For those actions that require parameters: */
591 /* each entry is valid if & only if corresponding entry in "add" set. */
592 char * string[ACTION_STRING_COUNT];
595 struct list multi[ACTION_MULTI_COUNT][1];
600 * This structure contains a set of changes to actions.
601 * It can contain both positive and negative instructions.
602 * It is used to store an entry in the actions list.
606 unsigned long mask; /* a bit set to "0" = remove action */
607 unsigned long add; /* a bit set to "1" = add action */
609 /* For those actions that require parameters: */
611 /* each entry is valid if & only if corresponding entry in "add" set. */
612 char * string[ACTION_STRING_COUNT];
614 /* Strings to remove. */
615 struct list multi_remove[ACTION_MULTI_COUNT][1];
617 /* If nonzero, remove *all* strings. */
618 int multi_remove_all[ACTION_MULTI_COUNT];
621 struct list multi_add[ACTION_MULTI_COUNT][1];
625 * This structure is used to store the actions list.
627 * It contains a URL pattern, and the chages to the actions.
628 * It is a linked list.
632 struct url_spec url[1];
634 struct action_spec action[1];
636 struct url_actions * next;
641 * Flags for use in csp->flags
643 #define CSP_FLAG_ACTIVE 0x01 /* Set if this client is processing data.
644 * Cleared when the thread associated with
645 * this structure dies. */
646 #define CSP_FLAG_CHUNKED 0x02 /* Set if the server's reply is in "chunked"
647 * transfer encoding */
648 #define CSP_FLAG_FORCED 0x04 /* Set if this request was enforced, although
649 * it would normally have been blocked. */
650 #define CSP_FLAG_MODIFIED 0x08 /* Set if any modification to the body was done */
651 #define CSP_FLAG_REJECTED 0x10 /* Set if request was blocked. */
652 #define CSP_FLAG_TOGGLED_ON 0x20 /* Set if we are toggled on (FEATURE_TOGGLE) */
655 * The state of a JunkBuster processing thread.
659 /* The proxy's configuration */
660 struct configuration_spec * config;
662 /* The actions to perform on the current request */
663 struct current_action_spec action[1];
665 /* socket to talk to client (web browser) */
668 /* socket to talk to server (web server or proxy) */
671 /* Multi-purpose flag container, see CSP_FLAG_* above */
672 unsigned short int flags;
675 * Client PC's IP address, as reported by the accept()_ function.
676 * Both as string and number
682 /* Our IP address and hostname, i.e. the IP address that
683 the client used to reach us, and the associated hostname,
686 char *my_ip_addr_str;
689 /* The URL that was requested */
690 struct http_request http[1];
692 /* An I/O buffer used for buffering data read from the client */
695 /* List of all headers for this request */
696 struct list headers[1];
698 /* List of all cookies for this request */
699 struct list cookie_list[1];
701 /* MIME-Type key, see CT_* above */
702 unsigned short int content_type;
704 /* The "X-Forwarded-For:" header sent by the client */
707 /* files associated with this client */
708 struct file_list *actions_list;
710 struct file_list *rlist; /* pcrs job file */
711 size_t content_length; /* Length after content modification */
714 struct file_list *tlist; /* trustfile */
715 #endif /* def FEATURE_TRUST */
717 struct client_state *next;
722 * List of functions to run on a list of headers
728 char *(*parser)(const struct parsers *, const char *, struct client_state *);
733 * List of available CGI functions.
735 struct cgi_dispatcher
737 const char * const name;
738 jb_err (* const handler)(struct client_state *csp, struct http_response *rsp, const struct map *parameters);
739 const char * const description;
744 * A data file used by JunkBuster. Kept in a linked list.
749 * this is a pointer to the data structures associated with the file.
750 * Read-only once the structure has been created.
754 /* Normally NULL. When we are finished with file (i.e. when we have
755 * loaded a new one), set to a pointer to an unloader function.
756 * Unloader will be called by sweep() (called from main loop) when
757 * all clients using this file are done. This prevents threading
760 void (*unloader)(void *);
762 /* Used internally by sweep(). Do not access from elsewhere. */
765 /* Following variables allow us to check if file has been changed.
766 * Read-only once the structure has been created.
771 /* Pointer to next entry in the linked list of all "file_list"s.
772 * This linked list is so that sweep() can navigate it.
773 * Since sweep() can remove items from the list, we must be careful
774 * to only access this value from main thread (when we know sweep
777 struct file_list *next;
784 struct url_spec url[1];
786 struct block_spec *next;
788 #endif /* def FEATURE_TRUST */
791 #define SOCKS_NONE 0 /* Don't use a SOCKS server */
792 #define SOCKS_4 40 /* original SOCKS 4 protocol */
793 #define SOCKS_4A 41 /* as modified for hosts w/o external DNS */
797 struct url_spec url[1];
799 /* Connection type - must be a SOCKS_xxx constant */
806 /* Parent HTTP proxy */
810 /* For the linked list */
811 struct forward_spec *next;
813 #define FORWARD_SPEC_INITIALIZER { { URL_SPEC_INITIALIZER }, 0, NULL, 0, NULL, 0, NULL }
816 struct re_filterfile_spec
820 struct list patterns[1];
825 #define ACL_PERMIT 1 /* accept connection request */
826 #define ACL_DENY 2 /* reject connection request */
828 struct access_control_addr
835 struct access_control_list
837 struct access_control_addr src[1];
838 struct access_control_addr dst[1];
841 struct access_control_list *next;
843 #endif /* def FEATURE_ACL */
846 /* Maximum number of loaders (actions, re_filter, ...) */
850 #define RUNTIME_FEATURE_CGI_EDIT_ACTIONS 1
851 #define RUNTIME_FEATURE_CGI_TOGGLE 2
855 * Data loaded from the configuration file.
857 * (Anomaly: toggle is still handled through a global, not this structure)
859 struct configuration_spec
864 /* Features that can be enabled/disabled throuigh the config file */
865 unsigned feature_flags;
871 const char *actions_file;
873 /* The administrator's email address */
876 /* A URL with info on this proxy */
877 char *proxy_info_url;
879 const char *re_filterfile;
881 #ifdef FEATURE_COOKIE_JAR
882 const char * jarfile;
884 #endif /* def FEATURE_COOKIE_JAR */
887 * Port and IP to bind to.
888 * Defaults to HADDR_DEFAULT:HADDR_PORT == 127.0.0.1:8000
893 /* Size limit for IOB */
897 const char * trustfile;
899 struct list trust_info[1];
900 struct url_spec *trust_list[64];
901 #endif /* def FEATURE_TRUST */
904 struct access_control_list *acl;
905 #endif /* def FEATURE_ACL */
907 struct forward_spec *forward;
909 /* All options from the config file, HTML-formatted */
912 /* the configuration file object. */
913 struct file_list *config_file_list;
915 /* List of loaders */
916 int (*loaders[NLOADERS])(struct client_state *);
918 /* bool, nonzero if we need to bind() to the new port */
923 #define SZ(X) (sizeof(X) / sizeof(*X))
925 #ifdef FEATURE_FORCE_LOAD
926 #define FORCE_PREFIX "/IJB-FORCE-LOAD"
927 #endif /* def FEATURE_FORCE_LOAD */
930 #define HOME_PAGE_URL "http://ijbswa.sourceforge.net"
931 #define REDIRECT_URL HOME_PAGE_URL "/redirect.php?v=" VERSION "&to="
932 #define CGI_PREFIX_HOST "i.j.b"
935 static const char CSUCCEED[] =
936 "HTTP/1.0 200 Connection established\n"
937 "Proxy-Agent: IJ/" VERSION "\r\n\r\n";
939 static const char CHEADER[] =
940 "HTTP/1.0 400 Invalid header received from browser\r\n\r\n";
942 static const char CFORBIDDEN[] =
943 "HTTP/1.0 403 Connection not allowable\r\nX-Hint: If you read this message interactively, then you know why this happens ,-)\r\n\r\n";
949 #endif /* ndef PROJECT_H_INCLUDED */