From 3a19d0fecf054afa4937b83267b21936d2d7fd44 Mon Sep 17 00:00:00 2001 From: oes Date: Tue, 2 Oct 2001 15:31:20 +0000 Subject: [PATCH] Introduced show-request cgi --- cgi.c | 10 ++- cgisimple.c | 52 ++++++++++++++- cgisimple.h | 12 +++- templates/show-request | 144 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 templates/show-request diff --git a/cgi.c b/cgi.c index d9d6f28d..09feb3a9 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.28 2001/09/19 18:00:37 oes Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.29 2001/09/20 15:47:44 steudten Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -38,6 +38,11 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.28 2001/09/19 18:00:37 oes Exp $"; * * Revisions : * $Log: cgi.c,v $ + * Revision 1.29 2001/09/20 15:47:44 steudten + * + * Fix BUG: Modify int size to size_t size in fill_template() + * - removes big trouble on machines where sizeof(int) != sizeof(size_t). + * * Revision 1.28 2001/09/19 18:00:37 oes * - Deletef time() FIXME (Can't fail under Linux either, if * the argument is guaranteed to be in out address space, @@ -253,6 +258,9 @@ const struct cgi_dispatcher cgi_dispatcher[] = { 12, cgi_edit_actions, "HIDE Edit the actions for (a) specified URL(s)" }, #endif /* def FEATURE_CGI_EDIT_ACTIONS */ + { "show-request", + 12, cgi_show_request, + "Show the client's request headers." }, { "", 0, cgi_default, "Junkbuster main page" }, diff --git a/cgisimple.c b/cgisimple.c index f3318c3b..7fa0d613 100644 --- a/cgisimple.c +++ b/cgisimple.c @@ -1,4 +1,4 @@ -const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.2 2001/09/19 18:01:11 oes Exp $"; +const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.3 2001/09/22 16:34:44 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $ @@ -36,6 +36,9 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.2 2001/09/19 18:01:11 oes Exp * * Revisions : * $Log: cgisimple.c,v $ + * Revision 1.3 2001/09/22 16:34:44 jongfoster + * Removing unneeded #includes + * * Revision 1.2 2001/09/19 18:01:11 oes * Fixed comments; cosmetics * @@ -69,6 +72,7 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.2 2001/09/19 18:01:11 oes Exp #include "actions.h" #include "miscutil.h" #include "loadcfg.h" +#include "parsers.h" const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION; @@ -97,7 +101,7 @@ int cgi_default(struct client_state *csp, struct http_response *rsp, { char *p; char *tmp = NULL; - struct map * exports = default_exports(csp, ""); + struct map *exports = default_exports(csp, ""); /* If there were other parameters, export a dump as "cgi-parameters" */ if(parameters) @@ -122,6 +126,50 @@ int cgi_default(struct client_state *csp, struct http_response *rsp, } +/********************************************************************* + * + * Function : cgi_show_request + * + * Description : Show the client's request and what sed() would have + * made of it. + * + * Parameters : + * 1 : csp = Current client state (buffers, headers, etc...) + * 2 : rsp = http_response data structure for output + * 3 : parameters = map of cgi parameters + * + * Returns : 0 + * + *********************************************************************/ +int cgi_show_request(struct client_state *csp, struct http_response *rsp, + struct map *parameters) +{ + char *p; + struct map *exports = default_exports(csp, "show-request"); + + /* + * Repair the damage done to the IOB by get_header() + */ + for (p = csp->iob->buf; p < csp->iob->eod; p++) + { + if (*p == '\0') *p = '\n'; + } + + /* + * Export the original client's request and the one we would + * be sending to the server if this wasn't a CGI call + */ + map(exports, "client-request", 1, csp->iob->buf, 1); + map(exports, "processed-request", 1, sed(client_patterns, add_client_headers, csp), 0); + + rsp->body = template_load(csp, "show-request"); + template_fill(&rsp->body, exports); + free_map(exports); + return(0); + +} + + /********************************************************************* * * Function : cgi_send_banner diff --git a/cgisimple.h b/cgisimple.h index d5aa6282..37f9b200 100644 --- a/cgisimple.h +++ b/cgisimple.h @@ -1,9 +1,9 @@ #ifndef CGISIMPLE_H_INCLUDED #define CGISIMPLE_H_INCLUDED -#define CGISIMPLE_H_VERSION "$Id: cgi.h,v 1.15 2001/09/16 15:02:35 jongfoster Exp $" +#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.1 2001/09/16 17:08:54 jongfoster Exp $" /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/cgi.h,v $ + * File : $Source: /cvsroot/ijbswa/current/cgisimple.h,v $ * * Purpose : Declares functions to intercept request, generate * html or gif answers, and to compose HTTP resonses. @@ -37,7 +37,10 @@ * Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Revisions : - * $Log: cgi.h,v $ + * $Log: cgisimple.h,v $ + * Revision 1.1 2001/09/16 17:08:54 jongfoster + * Moving simple CGI functions from cgi.c to new file cgisimple.c + * * **********************************************************************/ @@ -69,6 +72,9 @@ extern int cgi_show_url_info (struct client_state *csp, extern int cgi_show_version (struct client_state *csp, struct http_response *rsp, struct map *parameters); +extern int cgi_show_request (struct client_state *csp, + struct http_response *rsp, + struct map *parameters); /* Revision control strings from this header and associated .c file */ extern const char cgisimple_rcs[]; diff --git a/templates/show-request b/templates/show-request new file mode 100644 index 00000000..ea4a78f5 --- /dev/null +++ b/templates/show-request @@ -0,0 +1,144 @@ +########################################################## +# +# Show-Request-CGI Output template for junkbuster 2.9.x. +# +# +# USING HTML TEMPLATES: +# --------------------- +# +# Template files are written win plain HTML, with a few +# additions: +# +# - Lines that start with a '#' character like this one +# are ignored +# +# - Each item in the below list of exported symbols will +# be replaced by dynamically generated text, if they +# are enclosed in '@'-characters. E.g. The string @version@ +# will be replaced by the version number of Junkbuster. +# +# - One special application of this is to make whole blocks +# of the HTML template disappear if the condition +# is not given. Simply enclose the block between the two +# strings @if-start and if--end@. The strings +# should be placed in HTML comments (), so the +# html structure won't be messed when the magic happens. +# +# USABLE SYMBOLS IN THIS TEMPLATE: +# -------------------------------- +# +# my-ip-addr: +# The IP-address that the client used to reach this proxy +# my-hostname: +# The hostname associated with my-ip-addr +# admin-address: +# The email address of the pxoxy's administrator, as configured +# in the config file +# default-cgi: +# The URL for the "main menu" builtin CGI of this proxy +# menu: +# List of
  • elements linking to the other available CGIs +# version: +# The version number of the proxy software +# code-status: +# The development status of the proxy software: "alpha", "beta", +# or "stable". +# homepage: +# The URL of the SourceForge ijbswa project, who maintains this +# software. +# client-request: +# The request and headers that the client sent. +# processed-request: +# What we would have rewritten this request to, if this had not +# been intercepted. +# +# CONDITIONAL SYMBOLS FOR THIS TEMPLATE AND THEIR DEPANDANT SYMBOLS: +# ------------------------------------------------------------------ +# +# unstable: +# this is an alpha or beta release of the proxy software +# have-proxy-info: +# A URL for online documentation about this proxy has been +# specified and is available through the "proxy-info-url" +# symbol +# + + + + Junkbuster@@my-hostname@ + + + + + + + + + + + +# This will only appear if CODE_STATUS is "alpha" or "beta". See configure.in + + + + + + + + + + + + + + + + +
    +

    This is the Internet JUNKBUSTER + @version@ on @my-hostname@ (@my-ip-address@), port @my-port@

    +
    +

    Please note that this @code-status@ release + of the proxy software is not intended for production systems! +
    Use at your own risk. See the license for details.
    +

    + +

    Feel free to mail the developers + with any problems you encounter. +

    +
    +

    Show-Request

    +
    + Here you see the original headers that your client sent when requesting this page, along with + the headers that JunkBuster would have sent to the remote server if this request hadn't been + intercepted. +
    + +

    Original Client Request:

    +
    +
    @client-request@
    +
    + +

    Processed Request:

    +
    +
    @processed-request@
    +
    +
    +

    More Junkbuster:

    +
      @menu@
    +
    +

    If you have any questions about this service, + + + consult the online documentation or + + + send mail to @admin-address@ + who will be glad to help you. +

    +
    + + + -- 2.39.2