#
# For information, see http://ijbswa.sourceforge.net/
#
-# $Id: permissionsfile,v 1.10 2001/06/09 14:15:11 swa Exp $
+# $Id: actionsfile,v 1.1 2001/06/29 13:17:24 oes Exp $
#
#############################################################################
# Syntax
/.*/werb\..*
/.*/werbebanner/
/.*/werbung/.*\.(gif|jpe?g)
-/.*/adv\. # www.telegraaf.nl
+/.*/adv\. # www.telegraaf.nl
/.*/advert[0-9]+\.jpg
/.*bann\.gif
/Media/Images/Adds/
www.newscientist.com/houseads
www.nextcard.com/affiliates/
www.nikkeibp.asiabiztech.com/image/NAIS4\.gif
-www.nordlys.no/imaker/.*/.*/.*/.....\.gif # alvin brattli
-www.nordlys.no/imaker/.*/.*/.*/..003 # alvin brattli
+www.nordlys.no/imaker/.*/.*/.*/.....\.gif # alvin brattli
+www.nordlys.no/imaker/.*/.*/.*/..003 # alvin brattli
www.oanda.com/server/banner
.omdispatch.co.uk
www.oneandonlynetwork.com
-const char cgi_rcs[] = "$Id: cgi.c,v 1.7 2001/06/09 10:51:58 jongfoster Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.8 2001/06/29 13:21:46 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.c,v $
*
* Revisions :
* $Log: cgi.c,v $
+ * Revision 1.8 2001/06/29 13:21:46 oes
+ * - Cosmetics: renamed and reordered functions, variables,
+ * texts, improved comments etc
+ *
+ * - Removed ij_untrusted_url() The relevant
+ * info is now part of the "untrusted" page,
+ * which is generated by filters.c:trust_url()
+ *
+ * - Generators of content now call finish_http_response()
+ * themselves, making jcc.c:chat() a little less
+ * cluttered
+ *
+ * - Removed obsolete "Pragma: no-cache" from our headers
+ *
+ * - http_responses now know their head length
+ *
+ * - fill_template now uses the new interface to pcrs, so that
+ * - long jobs (like whole files) no longer have to be assembled
+ * in a fixed size buffer
+ * - the new T (trivial) option is used, and the replacement may
+ * contain Perl syntax backrefs without confusing pcrs
+ *
+ * - Introduced default_exports() which generates a set of exports
+ * common to all CGIs and other content generators
+ *
+ * - Introduced convenience function map_block_killer()
+ *
+ * - Introduced convenience function make_menu()
+ *
+ * - Introduced CGI-like function error_response() which generates
+ * the "No such domain" and "Connect failed" messages using the
+ * CGI platform
+ *
+ * - cgi_show_url_info:
+ * - adapted to new CGI features
+ * - form and answers now generated from same template
+ * - http:// prefix in URL now OK
+ *
+ * - cgi_show_status:
+ * - adapted to new CGI features
+ * - no longer uses csp->init_proxy_args
+ *
+ * - cgi_default:
+ * - moved menu generation to make_menu()
+ *
+ * - add_stats now writes single export map entries instead
+ * of a fixed string
+ *
+ * - Moved redirect_url() to filters.c
+ *
+ * - Fixed mem leak in free_http_response(), map_block_killer(),
+ *
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.7 2001/06/09 10:51:58 jongfoster
* Changing "show URL info" handler to new style.
* Changing BUFSIZ ==> BUFFER_SIZE
{
param_list = parse_cgi_parameters(argstring + d->name_length);
if ((d->handler)(csp, rsp, param_list))
- {
- freez(rsp);
- }
+ {
+ freez(rsp);
+ }
- free_map(param_list);
- return(finish_http_response(rsp));
+ free_map(param_list);
+ return(finish_http_response(rsp));
}
}
{
if(strcmp(lookup(parameters, "type"), "trans"))
{
- rsp->body = bindup(JBGIF, sizeof(JBGIF));
- rsp->content_length = sizeof(JBGIF);
+ rsp->body = bindup(JBGIF, sizeof(JBGIF));
+ rsp->content_length = sizeof(JBGIF);
}
else
{
- rsp->body = bindup(BLANKGIF, sizeof(BLANKGIF));
- rsp->content_length = sizeof(BLANKGIF);
+ rsp->body = bindup(BLANKGIF, sizeof(BLANKGIF));
+ rsp->content_length = sizeof(BLANKGIF);
}
enlist(rsp->headers, "Content-Type: image/gif");
return(0);
+
}
if (csp->tlist)
{
exports = map(exports, "trust-filename", 1, csp->tlist->filename, 1);
- }
+ }
else
- {
- exports = map(exports, "trust-filename", 1, "None specified", 1);
- }
+ {
+ exports = map(exports, "trust-filename", 1, "None specified", 1);
+ }
#else
exports = map_block_killer(exports, "trust-support");
#endif /* ndef TRUST_FILES */
* Returns : 0
*
*********************************************************************/
-int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,\r
- struct map *parameters)\r
+int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,
+ struct map *parameters)
{
struct map *exports = default_exports(csp, "show-url-info");
char *url_param, *host = NULL;
host = url_param;
host += (strncmp(url_param, "http://", 7)) ? 0 : 7;
- exports = map(exports, "url", 1, host, 1);\r
- exports = map(exports, "url-html", 1, html_encode(host), 0);\r\r
+ exports = map(exports, "url", 1, host, 1);
+ exports = map(exports, "url-html", 1, html_encode(host), 0);
init_current_action(action);
s = current_action_to_text(action);
- exports = map(exports, "default", 1, s , 0);\r
-
- if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))\r
- {\r
- exports = map(exports, "matches", 1, "none" , 1);\r
- exports = map(exports, "final", 1, lookup(exports, "default"), 1);\r
-\r
- freez(url_param);\r
- free_current_action(action);\r
-\r
- rsp->body = fill_template(csp, "show-url-info", exports);\r
- free_map(exports);\r
-\r
- return 0;\r
- }\r
-\r
+ exports = map(exports, "default", 1, s , 0);
+
+ if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
+ {
+ exports = map(exports, "matches", 1, "none" , 1);
+ exports = map(exports, "final", 1, lookup(exports, "default"), 1);
+
+ freez(url_param);
+ free_current_action(action);
+
+ rsp->body = fill_template(csp, "show-url-info", exports);
+ free_map(exports);
+
+ return 0;
+ }
+
s = strchr(host, '/');
if (s != NULL)
{
{
*s++ = '\0';
port = atoi(s);
- s = NULL;\r
+ s = NULL;
}
*url = dsplit(host);
/* if splitting the domain fails, punt */
if (url->dbuf == NULL)
{
- exports = map(exports, "matches", 1, "none" , 1);\r
- exports = map(exports, "final", 1, lookup(exports, "default"), 1);\r
-\r
- freez(url_param);\r
- freez(path);\r
- free_current_action(action);\r
-\r
- rsp->body = fill_template(csp, "show-url-info", exports);\r
- free_map(exports);\r
-\r
- return 0;\r
+ exports = map(exports, "matches", 1, "none" , 1);
+ exports = map(exports, "final", 1, lookup(exports, "default"), 1);
+
+ freez(url_param);
+ freez(path);
+ free_current_action(action);
+
+ rsp->body = fill_template(csp, "show-url-info", exports);
+ free_map(exports);
+
+ return 0;
}
for (b = b->next; NULL != b; b = b->next)
{
exports = map(exports, "matches", 1, "none", 1);
}
- matches = NULL;\r
-\r
+ matches = NULL;
+
freez(url->dbuf);
freez(url->dvec);
freez(url_param);
freez(path);
-\r
+
s = current_action_to_text(action);
- exports = map(exports, "final", 1, s, 0);\r
- s = NULL;\r
+ exports = map(exports, "final", 1, s, 0);
+ s = NULL;
free_current_action(action);
}
- rsp->body = fill_template(csp, "show-url-info", exports);\r
- free_map(exports);\r
+ rsp->body = fill_template(csp, "show-url-info", exports);
+ free_map(exports);
return 0;
}
*********************************************************************/
struct http_response *finish_http_response(struct http_response *rsp)
{
- char buf[BUFFER_SIZE];
-
- /*
- * Fill in the HTTP Status
- */
- sprintf(buf, "HTTP/1.0 %s", rsp->status ? rsp->status : "200 OK");
- enlist_first(rsp->headers, buf);
-
- /*
- * Set the Content-Length
- */
- if (rsp->content_length == 0)
- {
- rsp->content_length = rsp->body ? strlen(rsp->body) : 0;
- }
- sprintf(buf, "Content-Length: %d", rsp->content_length);
- enlist(rsp->headers, buf);
-
- /*
- * Fill in the default headers FIXME: Are these correct? sequence OK? check rfc!
- */
- enlist_unique(rsp->headers, "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT", 14);
- enlist_unique(rsp->headers, "Expires: Thu Jul 31, 1997 07:42:22 pm GMT", 8);
- enlist_unique(rsp->headers, "Content-Type: text/html", 13);
- enlist(rsp->headers, "");
+ char buf[BUFFER_SIZE];
+
+ /*
+ * Fill in the HTTP Status
+ */
+ sprintf(buf, "HTTP/1.0 %s", rsp->status ? rsp->status : "200 OK");
+ enlist_first(rsp->headers, buf);
+
+ /*
+ * Set the Content-Length
+ */
+ if (rsp->content_length == 0)
+ {
+ rsp->content_length = rsp->body ? strlen(rsp->body) : 0;
+ }
+ sprintf(buf, "Content-Length: %d", rsp->content_length);
+ enlist(rsp->headers, buf);
+
+ /*
+ * Fill in the default headers FIXME: Are these correct? sequence OK? check rfc!
+ */
+ enlist_unique(rsp->headers, "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT", 14);
+ enlist_unique(rsp->headers, "Expires: Thu Jul 31, 1997 07:42:22 pm GMT", 8);
+ enlist_unique(rsp->headers, "Content-Type: text/html", 13);
+ enlist(rsp->headers, "");
- /*
- * Write the head
- */
- if (NULL == (rsp->head = list_to_text(rsp->headers)))
- {
- free_http_response(rsp);
- return(NULL);
- }
- rsp->head_length = strlen(rsp->head);
+ /*
+ * Write the head
+ */
+ if (NULL == (rsp->head = list_to_text(rsp->headers)))
+ {
+ free_http_response(rsp);
+ return(NULL);
+ }
+ rsp->head_length = strlen(rsp->head);
- return(rsp);
+ return(rsp);
}
log_error(LOG_LEVEL_ERROR, "error loading template %s: %E", buf);
return NULL;
}
-
+
/*
* Assemble pcrs joblist from exports map
{
/* skip lines starting with '#' */
if(*buf == '#') continue;
-
+
old = strsav(old, buf);
}
fclose(fp);
if (strncmp(d->description, "HIDE", 4) && strcmp(d->name, self))
{
snprintf(buf, BUFFER_SIZE, "<li><a href=%s/config/%s>%s</a></li>\n",
- HOME_PAGE_URL, d->name, d->description);
+ HOME_PAGE_URL, d->name, d->description);
tmp = strsav(tmp, buf);
}
}
struct map *p = map;
char *ret = NULL;
-
ret = strsav(ret, "<table>\n");
while (p)
#ifndef _CGI_H
#define _CGI_H
-#define CGI_H_VERSION "$Id: cgi.h,v 1.4 2001/06/09 10:50:58 jongfoster Exp $"
+#define CGI_H_VERSION "$Id: cgi.h,v 1.5 2001/06/29 13:22:44 oes Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.h,v $
*
* Revisions :
* $Log: cgi.h,v $
+ * Revision 1.5 2001/06/29 13:22:44 oes
+ * - Cleaned up
+ * - Added new functions: default_exports(), make_menu(),
+ * error_response() etc, ranamed others and changed
+ * param and return types.
+ * - Removed HTTP/HTML snipplets
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.4 2001/06/09 10:50:58 jongfoster
* Changing "show URL info" handler to new style.
* Adding "extern" to some function prototypes.
struct map *parameters);
extern int cgi_show_status(struct client_state *csp, struct http_response *rsp,
struct map *parameters);
-extern int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,\r
+extern int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,
struct map *parameters);
extern int cgi_send_banner(struct client_state *csp, struct http_response *rsp,
- struct map *parameters);
+ struct map *parameters);
/* Not exactly a CGI */
extern struct http_response *error_response(struct client_state *csp, const char *template, int err);
# Sample Configuration file for the Internet Junkbuster 2.9.x
#
-# $Id: config,v 1.14 2001/06/08 00:25:01 jongfoster Exp $
+# $Id: config,v 1.15 2001/06/29 13:23:20 oes Exp $
#
# Table of Contents
# There is an implicit line equivalent to the following, which specifies that
# anything not finding a match on the list is to go out without forwarding
# or gateway protocol; like so:
-# forward .* . # implicit
+# forward .* . # implicit
#
# In the following common configuration, everything goes to Lucent's LPWA,
# except SSL on port 443 (which it doesn't handle)
| --no-cr | --no-c) ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
ac_configure_args="$ac_configure_args '$ac_arg'" ;;
*) ac_configure_args="$ac_configure_args $ac_arg" ;;
esac
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
ac_n= ac_c='
-' ac_t=' '
+' ac_t=' '
else
ac_n=-n ac_c= ac_t=
fi
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_prog_rejected=no
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
if test -f $ac_dir/$ac_word; then
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
- continue
+ continue
fi
ac_cv_prog_CC="cc"
break
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
# the first set of double-colon rules, so remove it if not needed.
# If there is a colon in the path, we need to keep it.
if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
fi
trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
# NAME is the cpp macro being defined and VALUE is the value it is being given.
#
# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
ac_dC='\3'
ac_dD='%g'
# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='\([ ]\)%\1#\2define\3'
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
ac_uC=' '
ac_uD='\4%g'
# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_eB='$%\1#\2define\3'
ac_eC=' '
ac_eD='%g'
# example, in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
cat >> conftest.vals <<\EOF
-s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
EOF
# Break up conftest.vals because some shells have a limit on
-const char filters_rcs[] = "$Id: filters.c,v 1.17 2001/06/09 10:55:28 jongfoster Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.18 2001/06/29 13:27:38 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.c,v $
*
* Revisions :
* $Log: filters.c,v $
+ * Revision 1.18 2001/06/29 13:27:38 oes
+ * - Cleaned up, renamed and reorderd functions
+ * and improved comments
+ *
+ * - block_url:
+ * - Ported to CGI platform. Now delivers
+ * http_response or NULL
+ * - Unified HTML and GIF generation (moved image detection
+ * and GIF generation here from jcc.c:chat())
+ * - Fixed HTTP status to:
+ * - 403 (Forbidden) for the "blocked" HTML message
+ * - 200 (OK) for GIF answers
+ * - 302 (Redirect) for redirect to GIF
+ *
+ * - trust_url:
+ * - Ported to CGI platform. Now delivers
+ * http_response or NULL
+ * - Separated detection of untrusted URL into
+ * (bool)is_untrusted_url
+ * - Added enforcement of untrusted requests
+ *
+ * - Moved redirect_url() from cgi.c to here
+ * and ported it to the CGI platform
+ *
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.17 2001/06/09 10:55:28 jongfoster
* Changing BUFSIZ ==> BUFFER_SIZE
*
* Returns : 0 = FALSE (don't block) and 1 = TRUE (do block)
*
*********************************************************************/
-int block_acl(struct access_control_addr *dst,
- struct client_state *csp)
+int block_acl(struct access_control_addr *dst, struct client_state *csp)
{
struct access_control_list *acl = csp->config->acl;
struct http_response *block_url(struct client_state *csp)
{
char *p;
- struct http_response *rsp;
+ struct http_response *rsp;
struct map *exports = NULL;
/*
* as specified by the relevant +image action
*/
#ifdef IMAGE_BLOCKING
- if (((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
+ if (((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
&& is_imageurl(csp))
- {
- /* determine HOW images should be blocked */
+ {
+ /* determine HOW images should be blocked */
p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
/* and handle accordingly: */
*/
{
- exports = default_exports(csp, NULL);
+ exports = default_exports(csp, NULL);
#ifdef FORCE_LOAD
exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1);
#else
*/
if (!is_untrusted_url(csp))
{
- return NULL;
+ return NULL;
}
/*
/*
* Export the host, port, and referrer information
- */
+ */
exports = map(exports, "hostport", 1, csp->http->hostport, 1);
exports = map(exports, "path", 1, csp->http->path, 1);
exports = map(exports, "hostport-html", 1, html_encode(csp->http->hostport), 0);
for (l = csp->config->trust_info->next; l ; l = l->next)
{
- sprintf(buf,
- "<li> <a href=%s>%s</a><br>\n",
- l->str, l->str);
+ sprintf(buf, "<li> <a href=%s>%s</a><br>\n",l->str, l->str);
p = strsav(p, buf);
}
exports = map(exports, "trust-info", 1, p, 0);
}
else
- {
- exports = map_block_killer(exports, "have-trust-info");
- }
+ {
+ exports = map_block_killer(exports, "have-trust-info");
+ }
/*
* Export the force prefix or the force conditional block killer
*/
#ifdef FORCE_LOAD
- exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1);
+ exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1);
#else
- exports = map_block_killer(exports, "force-support");
+ exports = map_block_killer(exports, "force-support");
#endif /* ndef FORCE_LOAD */
/*
if ((csp->referrer == NULL)|| (strlen(csp->referrer) <= 9))
{
/* no referrer was supplied */
- return(1);
+ return(1);
}
/* forge a URL from the referrer so we can use
}
apply_url_actions(csp->action, http, b);
+
}
if (domain[strlen(domain) - 1] == '.')
{
- ret->unanchored |= ANCHOR_RIGHT;
- }
- if (domain[0] == '.')
+ ret->unanchored |= ANCHOR_RIGHT;
+ }
+
+ if (domain[0] == '.')
{
- ret->unanchored |= ANCHOR_LEFT;
- }
+ ret->unanchored |= ANCHOR_LEFT;
+ }
ret->dbuf = strdup(domain);
memcpy(ret->dvec, v, size);
}
-
return(*ret);
}
}
return 0;
+
}
}
return 1;
}
-}
+}
/*
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.9 2001/06/07 23:06:09 jongfoster Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.10 2001/06/29 13:29:15 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
*
* Revisions :
* $Log: jbsockets.c,v $
+ * Revision 1.10 2001/06/29 13:29:15 oes
+ * - Added remote (server) host IP to csp->http->host_ip_addr_str
+ * - Added detection of local socket IP and fqdn
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.9 2001/06/07 23:06:09 jongfoster
* The host parameter to connect_to() is now const.
*
if ((addr = resolve_hostname_to_ip(host)) == -1)
{
- csp->http->host_ip_addr_str = strdup("unknown");
+ csp->http->host_ip_addr_str = strdup("unknown");
return(-1);
}
* and the hostname associated with that address
*/
if (!getsockname(afd, &laddr, &laddrlen))
- {
+ {
csp->my_ip_addr_str = strdup(inet_ntoa(lap->sin_addr));
host = gethostbyaddr(laddr.sa_data + 2, 4, AF_INET);
log_error(LOG_LEVEL_ERROR, "Unable to get my own hostname: %s\n", hstrerror(h_errno));
}
else
- {
+ {
csp->my_hostname = strdup(host->h_name);
}
- }
+ }
csp->cfd = afd;
csp->ip_addr_str = strdup(inet_ntoa(rap->sin_addr));
csp->ip_addr_long = ntohl(rap->sin_addr.s_addr);
return 1;
+
}
-const char jcc_rcs[] = "$Id: jcc.c,v 1.20 2001/06/09 10:55:28 jongfoster Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.21 2001/06/29 13:29:36 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.21 2001/06/29 13:29:36 oes
+ * - Cleaned up, improved comments
+ * - Unified all possible interceptors (CGI,
+ * block, trust, fast_redirect) in one
+ * place, with one (CGI) answer generation
+ * mechansim. Much clearer now.
+ * - Removed the GIF image generation, which
+ * is now done in filters.c:block_url()
+ * - Made error conditions like domain lookup
+ * failiure or (various) problems while talking
+ * to the server use cgi.c:error_response()
+ * instead of generating HTML/HTTP in chat() (yuck!)
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.20 2001/06/09 10:55:28 jongfoster
* Changing BUFSIZ ==> BUFFER_SIZE
*
#define IS_ENABLED_AND IS_TOGGLED_ON_AND IS_NOT_FORCED_AND
- char buf[BUFFER_SIZE];\r
+ char buf[BUFFER_SIZE];
char *hdr, *p, *req;
char *err = NULL;
fd_set rfds;
if (
/* a CGI call was detected and answered */
- (NULL != (rsp = dispatch_cgi(csp)))
+ (NULL != (rsp = dispatch_cgi(csp)))
/* or we are enabled and... */
|| (IS_ENABLED_AND (
- /* ..the request was blocked */
- ( NULL != (rsp = block_url(csp)))
+ /* ..the request was blocked */
+ ( NULL != (rsp = block_url(csp)))
/* ..or untrusted */
#ifdef TRUST_FILES
/* ..or a fast redirect kicked in */
#ifdef FAST_REDIRECTS
|| (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) &&
- (NULL != (rsp = redirect_url(csp))))
+ (NULL != (rsp = redirect_url(csp))))
#endif /* def FAST_REDIRECTS */
- ))
- )
+ ))
+ )
{
- /* Write the answer to the client */
+ /* Write the answer to the client */
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
- }
+ }
#ifdef STATISTICS
/* Count as a rejected request */
if (errno == EINVAL)
{
- rsp = error_response(csp, "no-such-domain", errno);
+ rsp = error_response(csp, "no-such-domain", errno);
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0",
csp->ip_addr_str, http->cmd);
}
else
{
- rsp = error_response(csp, "connect-failed", errno);
+ rsp = error_response(csp, "connect-failed", errno);
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
csp->ip_addr_str, http->cmd);
}
- /* Write the answer to the client */
+ /* Write the answer to the client */
if(rsp)
- {
+ {
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
- }
- }
+ }
+ }
free_http_response(rsp);
freez(hdr);
rsp = error_response(csp, "connect-failed", errno);
- if(rsp)
+ if(rsp)
{
if ((write_socket(csp->cfd, rsp->head, n) != n)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
- }
- }
+ }
+ }
free_http_response(rsp);
freez(hdr);
rsp = error_response(csp, "connect-failed", errno);
- if(rsp)
+ if(rsp)
{
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
- }
- }
+ }
+ }
free_http_response(rsp);
return;
#ifdef __BEOS__
-
/*********************************************************************
*
* Function : server_thread
return 0;
}
-
#endif
-const char list_rcs[] = "$Id: list.c,v 1.3 2001/06/03 19:12:24 oes Exp $";
+const char list_rcs[] = "$Id: list.c,v 1.4 2001/06/29 13:30:22 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/list.c,v $
*
* Revisions :
* $Log: list.c,v $
+ * Revision 1.4 2001/06/29 13:30:22 oes
+ * - Added Convenience function enlist_unique_header(),
+ * which takes the Header name and value as separate
+ * arguments and thus saves the pain of sprintf()ing
+ * and determining the Header name length to enlist_unique
+ * - Improved comments
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.3 2001/06/03 19:12:24 oes
* functions for new struct map, extended enlist_unique
*
if (name == NULL || value == NULL) return;
dummy = strdup(name);
- dummy = strsav(dummy, ": ");
+ dummy = strsav(dummy, ": ");
length = strlen(dummy);
while (cur != NULL)
{
if ((cur->str != NULL) &&
- (0 == strncmp(dummy, cur->str, length)))
+ (0 == strncmp(dummy, cur->str, length)))
{
/* Already there */
return;
if (cur != NULL)
{
- cur->str = strsav(dummy, value);
+ cur->str = strsav(dummy, value);
cur->next = NULL;
last = header->last;
p = p->next;
}
return "";
+
}
-const char loaders_rcs[] = "$Id: loaders.c,v 1.16 2001/06/09 10:55:28 jongfoster Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.17 2001/06/29 13:31:51 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loaders.c,v $
*
* Revisions :
* $Log: loaders.c,v $
+ * Revision 1.17 2001/06/29 13:31:51 oes
+ * Various adaptions
+ *
* Revision 1.16 2001/06/09 10:55:28 jongfoster
* Changing BUFSIZ ==> BUFFER_SIZE
*
#include "gateway.h"
#include "actions.h"
-#ifndef SPLIT_PROXY_ARGS
-/* For strsav */
-#include "showargs.h"
-#endif /* ndef SPLIT_PROXY_ARGS */
-
const char loaders_h_rcs[] = LOADERS_H_VERSION;
/* Fix a problem with Solaris. There should be no effect on other
(REG_EXTENDED|REG_NOSUB|REG_ICASE));
if (errcode)
{
- size_t errlen =
- regerror(errcode,
- url->preg, buf, sizeof(buf));
+ size_t errlen = regerror(errcode,
+ url->preg, buf, sizeof(buf));
buf[errlen] = '\0';
log_error(LOG_LEVEL_ERROR, "error compiling %s: %s",
- url->spec, buf);
+ url->spec, buf);
freez(url->spec);
freez(url->path);
url->unanchored = tmp_url->unanchored;
return 0; /* OK */
+
}
*newfl = fs;
return 1;
+
}
if (contflag)
{
contflag = 0;
- continue;
+ continue;
}
/* Remove leading and trailing whitespace */
struct block_spec *b = (struct block_spec *)f;
if (b == NULL) return;
- unload_trustfile(b->next);
+ unload_trustfile(b->next); /* Stack is cheap, isn't it? */
free_url(b->url);
if (b == NULL) return;
destroy_list(b->patterns);
-
pcrs_free_joblist(b->joblist);
-
freez(b);
+ return;
}
/*********************************************************************
/* vim:ts=3: */
-const char miscutil_rcs[] = "$Id: miscutil.c,v 1.12 2001/06/09 10:55:28 jongfoster Exp $";
+const char miscutil_rcs[] = "$Id: miscutil.c,v 1.13 2001/06/29 13:32:14 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $
*
* Revisions :
* $Log: miscutil.c,v $
+ * Revision 1.13 2001/06/29 13:32:14 oes
+ * Removed logentry from cancelled commit
+ *
* Revision 1.12 2001/06/09 10:55:28 jongfoster
* Changing BUFSIZ ==> BUFFER_SIZE
*
#include <malloc.h>
#include <ctype.h>
-/*\r
- * FIXME: Only need project.h for BUFFER_SIZE. It would be nice\r
- * to remove this dependency.\r
- */\r
-#include "project.h"\r
-#include "miscutil.h"\r
+/*
+ * FIXME: Only need project.h for BUFFER_SIZE. It would be nice
+ * to remove this dependency.
+ */
+#include "project.h"
+#include "miscutil.h"
#include "errlog.h"
const char miscutil_h_rcs[] = MISCUTIL_H_VERSION;
if (NULL == (dup = (char *)malloc(n)))
{
- return NULL;
- }
+ return NULL;
+ }
else
- {
- memcpy(dup, string, n);
- }
+ {
+ memcpy(dup, string, n);
+ }
return dup;
-const char parsers_rcs[] = "$Id: parsers.c,v 1.15 2001/06/03 19:12:38 oes Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.16 2001/06/29 13:32:42 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
*
* Revisions :
* $Log: parsers.c,v $
+ * Revision 1.16 2001/06/29 13:32:42 oes
+ * - Fixed a comment
+ * - Adapted free_http_request
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.15 2001/06/03 19:12:38 oes
* deleted const struct interceptors
*
char *content_length(const struct parsers *v, char *s, struct client_state *csp)
{
if (csp->content_length != 0) /* Content has been modified */
- {
- s = (char *) zalloc(100);
- sprintf(s, "Content-Length: %d", csp->content_length);
- log_error(LOG_LEVEL_HEADER, "Adjust Content-Length to %d", csp->content_length);
- return(s);
- }
+ {
+ s = (char *) zalloc(100);
+ sprintf(s, "Content-Length: %d", csp->content_length);
+ log_error(LOG_LEVEL_HEADER, "Adjust Content-Length to %d", csp->content_length);
+ return(s);
+ }
else
{
return(strdup(s));
-const char pcrs_rcs[] = "$Id: pcrs.c,v 1.6 2001/06/03 19:12:45 oes Exp $";
+const char pcrs_rcs[] = "$Id: pcrs.c,v 1.7 2001/06/29 13:33:04 oes Exp $";
/*********************************************************************
*
*
* Revisions :
* $Log: pcrs.c,v $
+ * Revision 1.7 2001/06/29 13:33:04 oes
+ * - Cleaned up, renamed and reordered functions,
+ * improved comments
+ * - Removed my_strsep
+ * - Replaced globalflag with a general flags int
+ * that holds PCRS_GLOBAL, PCRS_SUCCESS, and PCRS_TRIVIAL
+ * - Introduced trivial option that will prevent pcrs
+ * from honouring backreferences in the substitute,
+ * which is useful for large substitutes that are
+ * red in from somewhere and saves the pain of escaping
+ * the backrefs
+ * - Introduced convenience function pcrs_free_joblist()
+ * - Split pcrs_make_job() into pcrs_compile(), which still
+ * takes a complete s/// comand as argument and parses it,
+ * and a new function pcrs_make_job, which takes the
+ * three separate components. This should make for a
+ * much friendlier frontend.
+ * - Removed create_pcrs_job() which was useless
+ * - Fixed a bug in pcrs_execute
+ * - Success flag is now handled by pcrs instead of user
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.6 2001/06/03 19:12:45 oes
* added FIXME
*
case 's': rc |= PCRE_DOTALL; break;
case 'x': rc |= PCRE_EXTENDED; break;
case 'U': rc |= PCRE_UNGREEDY; break;
- case 'T': *flags |= PCRS_TRIVIAL; break;
+ case 'T': *flags |= PCRS_TRIVIAL; break;
default: break;
}
}
if (trivialflag)
{
- k = length;
+ k = length;
}
else
- {
+ {
for (i=0; i < length; i++)
{
/* Backslash treatment */
text[k++] = replacement[i];
quoted = 0;
}
- } /* -END- if (!trivialflag) */
+ } /* -END- if (!trivialflag) */
text[k] = '\0';
r->text = text;
*/
limit = strlen(command);
if (limit < 4)
- {
+ {
*errptr = PCRS_ERR_CMDSYNTAX;
return NULL;
}
else
- {
- delimiter = command[1];
- }
+ {
+ delimiter = command[1];
+ }
tokens[l] = (char *) malloc(limit + 1);
if (command[i] == delimiter && !quoted)
{
- if (l == 3)
- {
- l = -1;
+ if (l == 3)
+ {
+ l = -1;
break;
}
- tokens[0][k++] = '\0';
+ tokens[0][k++] = '\0';
tokens[++l] = tokens[0] + k;
- continue;
+ continue;
}
else if (command[i] == '\\' && !quoted && i+1 < limit && command[i+1] == delimiter)
*/
if (l != 3)
{
- *errptr = PCRS_ERR_CMDSYNTAX;
+ *errptr = PCRS_ERR_CMDSYNTAX;
free(tokens[0]);
return NULL;
}
- newjob = pcrs_make_job(tokens[1], tokens[2], tokens[3], errptr);
+ newjob = pcrs_make_job(tokens[1], tokens[2], tokens[3], errptr);
free(tokens[0]);
return newjob;
while ((submatches = pcre_exec(job->pattern, job->hints, subject, subject_length, offset, 0, offsets, 3 * PCRS_MAX_SUBMATCHES)) > 0)
{
- job->flags |= PCRS_SUCCESS;
+ job->flags |= PCRS_SUCCESS;
matches[i].submatches = submatches;
for (k=0; k < submatches; k++)
{
#ifndef _PROJECT_H
#define _PROJECT_H
-#define PROJECT_H_VERSION "$Id: project.h,v 1.18 2001/06/09 10:57:39 jongfoster Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.19 2001/06/29 13:33:36 oes Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
*
* Revisions :
* $Log: project.h,v $
+ * Revision 1.19 2001/06/29 13:33:36 oes
+ * - Improved comments
+ * - Introduced http_request.host_ip_addr_str
+ * - Introduced http_response.head_length
+ * - Introduced config.my_ip_addr_str, config.my_hostname,
+ * config.admin_address and config.proxy_info_url
+ * - Removed config.proxy_args_header and config.proxy_args_trailer,
+ * renamed config.proxy_args_invocation to config.proxy_args
+ * - Removed HTML snipplets and GIFs
+ * - Removed logentry from cancelled commit
+ *
* Revision 1.18 2001/06/09 10:57:39 jongfoster
* Adding definition of BUFFER_SIZE.
* Changing struct cgi_dispatcher to use "const" strings.
#ifdef __cplusplus
extern "C" {
#endif
-\r
-#define BUFFER_SIZE 5000\r
+
+#define BUFFER_SIZE 5000
#define FOREVER 1
-const char showargs_rcs[] = "$Id: showargs.c,v 1.15 2001/06/09 10:55:28 jongfoster Exp $";
+const char showargs_rcs[] = "$Id: showargs.c,v 1.16 2001/06/29 13:35:07 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/showargs.c,v $
*
* Revisions :
* $Log: showargs.c,v $
+ * Revision 1.16 2001/06/29 13:35:07 oes
+ * - Adapted
+ * - Improved comments
+ * - Removed init_proxy_args
+ * - Renamed end_proxy_args(csp) to show_rcs(void)
+ * - Removed logentry from cancelled commit
+ * - Destroyed support for ndef SPLIT_PROXY_ARGS (Ooops)
+ * - Separated the #define list into show_defines()
+ *
* Revision 1.15 2001/06/09 10:55:28 jongfoster
* Changing BUFSIZ ==> BUFFER_SIZE
*
#undef SHOW_RCS
- return(b);
+ return(b);
}
/*********************************************************************