3 #define PROJECT_H_VERSION "$Id: project.h,v 1.3 2001/05/20 01:21:20 jongfoster 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.3 2001/05/20 01:21:20 jongfoster
40 * Version 2.9.4 checkin.
41 * - Merged popupfile and cookiefile, and added control over PCRS
42 * filtering, in new "permissionsfile".
43 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
44 * file error you now get a message box (in the Win32 GUI) rather
45 * than the program exiting with no explanation.
46 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
48 * - Removed tabs from "config"
49 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
50 * - Bumped up version number.
52 * Revision 1.2 2001/05/17 23:01:01 oes
53 * - Cleaned CRLF's from the sources and related files
55 * Revision 1.1.1.1 2001/05/15 13:59:03 oes
56 * Initial import of version 2.9.3 source tree
59 *********************************************************************/
62 /* Declare struct FILE for vars and funcs. */
65 /* Need time_t for file_list */
69 * Include appropriate regular expression libraries.
71 * PCRS ==> Include pcre
72 * REGEX && PCRE ==> Include pcre and pcreposix
73 * REGEX && !PCRE ==> Include gnu_regex
75 * STATIC ==> Use #include "pcre.h" (compiling at same time)
76 * !STATIC ==> Use #include <pcre.h> (System library)
79 #if (defined(REGEX) && defined(PCRE)) || defined(PCRS)
85 #endif /* (defined(REGEX) && defined(PCRE)) || defined(PCRS) */
87 #if defined(REGEX) && defined(PCRE)
89 # include "pcreposix.h"
91 # include <pcreposix.h>
93 #endif /* defined(REGEX) && defined(PCRE) */
95 #if defined(REGEX) && !defined(PCRE)
96 # include "gnu_regex.h"
101 #endif /* def PCRS */
105 #endif /* def AMIGA */
113 /* Default IP and port to listen on */
114 #define HADDR_DEFAULT "127.0.0.1"
115 #define HADDR_PORT 8000
118 /* Need this for struct gateway */
130 char *hostport; /* "host[:port]" */
136 /* generic attributes */
138 int (*conn)(const struct gateway *, struct http_request *, struct client_state *);
141 /* domain specific attributes */
174 #define IOB_PEEK(CSP) ((CSP->iob->cur > CSP->iob->eod) ? (CSP->iob->eod - CSP->iob->cur) : 0)
175 #define IOB_RESET(CSP) if(CSP->iob->buf) free(CSP->iob->buf); memset(CSP->iob, '\0', sizeof(CSP->iob));
178 /* Constants defining bitmask for csp->accept_types */
180 #ifdef DETECT_MSIE_IMAGES
182 /* MSIE detected by user-agent string */
183 #define ACCEPT_TYPE_IS_MSIE 0x0001
186 * *If* this is MSIE, it wants an image. (Or this is a shift-reload, or
187 * it's got an image from this URL before... yuck!)
188 * Only meaningful if ACCEPT_TYPE_IS_MSIE set
190 #define ACCEPT_TYPE_MSIE_IMAGE 0x0002
193 * *If* this is MSIE, it wants a HTML document.
194 * Only meaningful if ACCEPT_TYPE_IS_MSIE set
196 #define ACCEPT_TYPE_MSIE_HTML 0x0004
198 #endif /* def DETECT_MSIE_IMAGES */
209 /* 1 if this URL was rejected, 0 otherwise. Allows actual stats inc to
210 * occur in main thread only for thread-safety.
213 #endif /* def STATISTICS */
217 #endif /* def FORCE_LOAD */
221 * by haroon - most of credit to srt19170
222 * We add an "on/off" toggle here that is used to effectively toggle
223 * the Junkbuster off or on
232 #if defined(DETECT_MSIE_IMAGES)
233 /* Types the client will accept.
234 * Bitmask - see ACCEPT_TYPE_XXX constants.
237 #endif /* defined(DETECT_MSIE_IMAGES) */
239 const struct gateway *gw;
240 struct http_request http[1];
244 struct list headers[1];
245 struct list cookie_list[1];
246 #if defined(PCRS) || defined(KILLPOPUPS)
248 #endif /* defined(PCRS) || defined(KILLPOPUPS) */
254 /* files associated with this client */
255 struct file_list *blist; /* blockfile */
256 struct file_list *flist; /* forwardfile */
257 struct file_list *permissions_list;
261 struct file_list *alist; /* aclfile */
262 #endif /* def ACL_FILES */
264 #ifdef USE_IMAGE_LIST
265 struct file_list *ilist; /* imagefile */
266 #endif /* def USE_IMAGE_LIST */
269 struct file_list *rlist; /* Perl re_filterfile */
270 #endif /* def PCRS */
273 struct file_list *tlist; /* trustfile */
274 #endif /* def TRUST_FILES */
276 struct client_state *next;
284 char *(*parser)(const struct parsers *, char *, struct client_state *);
292 char *(*interceptor)(struct http_request *http, struct client_state *csp);
296 /* this allows the proxy to permit/block access to any host and/or path */
319 * this is a pointer to the data structures associated with the file.
320 * Read-only once the structure has been created.
324 /* Normally NULL. When we are finished with file (i.e. when we have
325 * loaded a new one), set to a pointer to an unloader function.
326 * Unloader will be called by sweep() (called from main loop) when
327 * all clients using this file are done. This prevents threading
330 void (*unloader)(void *);
332 /* Used internally by sweep(). Do not access from elsewhere. */
335 #ifndef SPLIT_PROXY_ARGS
336 /* String to be displayed as part of show-proxy-args display.
337 * Read-only once the structure has been created.
340 #endif /* ndef SPLIT_PROXY_ARGS */
342 /* Following variables allow us to check if file has been changed.
343 * Read-only once the structure has been created.
348 /* Pointer to next entry in the linked list of all "file_list"s.
349 * This linked list is so that sweep() can navigate it.
350 * Since sweep() can remove items from the list, we must be careful
351 * to only access this value from main thread (when we know sweep
354 struct file_list *next;
360 struct url_spec url[1];
362 struct block_spec *next;
366 #define PERMIT_COOKIE_SET 0x0001
367 #define PERMIT_COOKIE_READ 0x0002
368 #define PERMIT_RE_FILTER 0x0004
369 #define PERMIT_POPUPS 0x0008
371 struct permissions_spec
373 struct url_spec url[1];
375 struct permissions_spec * next;
380 struct url_spec url[1];
382 struct gateway gw[1];
383 struct forward_spec *next;
388 struct re_filterfile_spec
390 struct list patterns[1];
391 /* See README.re_filter */
394 #endif /* def PCRS */
398 #define ACL_PERMIT 1 /* accept connection request */
399 #define ACL_DENY 2 /* reject connection request */
401 struct access_control_addr
408 struct access_control_list
410 struct access_control_addr src[1];
411 struct access_control_addr dst[1];
414 struct access_control_list *next;
416 #endif /* def ACL_FILES */
418 #define SZ(X) (sizeof(X) / sizeof(*X))
420 #define WHITEBG "<body bgcolor=\"#ffffff\" link=\"#000078\" alink=\"#ff0022\" vlink=\"#787878\">\n"
421 #define BODY "<body bgcolor=\"#f8f8f0\" link=\"#000078\" alink=\"#ff0022\" vlink=\"#787878\">\n"
422 #define BANNER "<strong>Internet J<small>UNK<i><font color=\"red\">BUSTER</font></i></small></strong>"
425 #define FORCE_PREFIX "/IJB-FORCE-LOAD"
426 #endif /* def FORCE_LOAD */
428 #define HOME_PAGE_URL "http://ijbswa.sourceforge.net/"
429 #define REDIRECT_URL HOME_PAGE_URL "redirect.php?v=" VERSION "&to="
431 static const char CFAIL[] =
432 "HTTP/1.0 503 Connect failed\n"
433 "Content-Type: text/html\n\n"
436 "<title>Internet Junkbuster: Connect failed</title>\n"
442 "TCP connection to '%s' failed: %s.\n<br>"
446 static const char CNXDOM[] =
447 "HTTP/1.0 404 Non-existent domain\n"
448 "Content-Type: text/html\n\n"
451 "<title>Internet Junkbuster: Non-existent domain</title>\n"
457 "No such domain: %s\n"
461 static const char CNOBANNER[] =
462 "HTTP/1.0 200 No Banner\n"
463 "Content-Type: text/html\n\n"
466 "<title>Internet Junkbuster: No Banner</title>\n"
472 "You asked for a banner that this proxy can't produce because either configuration does not permit.\n<br>"
473 "or the URL didn't end with .gif\n"
477 static const char CSUCCEED[] =
478 "HTTP/1.0 200 Connection established\n"
479 "Proxy-Agent: IJ/" VERSION "\n\n";
481 static const char CHEADER[] =
482 "HTTP/1.0 400 Invalid header received from browser\n\n";
484 static const char SHEADER[] =
485 "HTTP/1.0 502 Invalid header received from server\n\n";
487 #if defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST)
490 * Hint: You can encode your own GIFs like that:
491 * perl -e 'while (read STDIN, $c, 1) { printf("\\%.3o,", unpack("C", $c)); }'
494 static const char BLANKGIF[] =
495 "HTTP/1.0 200 OK\r\n"
496 "Pragma: no-cache\r\n"
497 "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
498 "Expires: Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
499 "Content-type: image/gif\r\n\r\n"
500 "GIF89a\001\000\001\000\200\000\000\377\377\377\000\000"
501 "\000!\371\004\001\000\000\000\000,\000\000\000\000\001"
502 "\000\001\000\000\002\002D\001\000;";
504 static const char JBGIF[] =
505 "HTTP/1.0 200 OK\r\n"
506 "Pragma: no-cache\r\n"
507 "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
508 "Expires: Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
509 "Content-type: image/gif\r\n\r\n"
510 "GIF89aD\000\013\000\360\000\000\000\000\000\377\377\377!"
511 "\371\004\001\000\000\001\000,\000\000\000\000D\000\013\000"
512 "\000\002a\214\217\251\313\355\277\000\200G&K\025\316hC\037"
513 "\200\234\230Y\2309\235S\230\266\206\372J\253<\3131\253\271"
514 "\270\215\342\254\013\203\371\202\264\334P\207\332\020o\266"
515 "N\215I\332=\211\312\3513\266:\026AK)\364\370\365aobr\305"
516 "\372\003S\275\274k2\354\254z\347?\335\274x\306^9\374\276"
519 #endif /* defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST) */
521 #if defined(FAST_REDIRECTS) || defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST)
523 static const char HTTP_REDIRECT_TEMPLATE[] =
524 "HTTP/1.0 302 Local Redirect from Junkbuster\r\n"
525 "Pragma: no-cache\r\n"
526 "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
527 "Expires: Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
530 #endif /* defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST) */
536 #endif /* ndef _PROJECT_H */