X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=cgi.c;h=bd0c8f6f7c529c13a3577da983e1f4bf6321e9ba;hp=0d7a08553062bd6103cca44ee10f5c902f72b24b;hb=68b322072bd0c1db8aca5df74601eb18c6bfaac5;hpb=d1f0bf4be6a9646658b5ae04df01f81474b65f5b diff --git a/cgi.c b/cgi.c index 0d7a0855..bd0c8f6f 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.99 2007/08/05 13:42:22 fabiankeil Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.101 2008/02/03 15:45:06 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -38,6 +38,13 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.99 2007/08/05 13:42:22 fabiankeil Exp $"; * * Revisions : * $Log: cgi.c,v $ + * Revision 1.101 2008/02/03 15:45:06 fabiankeil + * Add SOCKS5 support for "Forwarding failure" CGI page. + * + * Revision 1.100 2007/10/17 18:40:53 fabiankeil + * - Send CGI pages as HTTP/1.1 unless the client asked for HTTP/1.0. + * - White space fix. + * * Revision 1.99 2007/08/05 13:42:22 fabiankeil * #1763173 from Stefan Huehner: declare some more functions static. * @@ -1428,7 +1435,8 @@ struct http_response *error_response(struct client_state *csp, } else if (!strcmp(templatename, "forwarding-failed")) { - const struct forward_spec * fwd = forward_url(csp->http, csp); + const struct forward_spec *fwd = forward_url(csp, csp->http); + char *socks_type = NULL; if (fwd == NULL) { log_error(LOG_LEVEL_FATAL, "gateway spec is NULL. This shouldn't happen!"); @@ -1454,8 +1462,27 @@ struct http_response *error_response(struct client_state *csp, csp->error_message = strdup("Failure reason missing. Check the log file for details."); } if (!err) err = map(exports, "gateway", 1, fwd->gateway_host, 1); - if (!err) err = map(exports, "forwarding-type", 1, (fwd->type == SOCKS_4) ? - "socks4-" : "socks4a-", 1); + + /* + * XXX: this is almost the same code as in cgi_show_url_info() + * and thus should be factored out and shared. + */ + switch (fwd->type) + { + case SOCKS_4: + socks_type = "socks4-"; + break; + case SOCKS_4A: + socks_type = "socks4a-"; + break; + case SOCKS_5: + socks_type = "socks5-"; + break; + default: + log_error(LOG_LEVEL_FATAL, "Unknown socks type: %d.", fwd->type); + } + + if (!err) err = map(exports, "forwarding-type", 1, socks_type, 1); if (!err) err = map(exports, "error-message", 1, html_encode(csp->error_message), 0); if (!err) rsp->status = strdup("503 Forwarding failure");