From d51ecc85d592ae919c8d114cd8c1eb82107d99c7 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 16 Jan 2016 12:30:43 +0000 Subject: [PATCH] Introduce the new forwarding type 'forward-webserver' Currently it is only supported by the forward-override{} action and there's no config directive with the same name. The forwarding type is similar to 'forward', but the request line only contains the path instead of the complete URL. This makes it more convenient to use Privoxy to make existing websites available as onion services as well. Many websites serve content with hardcoded URLs and can't be easily adjusted to change the domain based on the one used by the client. Putting Privoxy between Tor and the webserver (or an stunnel that forwards to the webserver) allows to rewrite headers and content to make client and server happy at the same time. --- filters.c | 10 +++++++++- gateway.c | 3 ++- jcc.c | 6 +++--- project.h | 8 +++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/filters.c b/filters.c index d425e3c7..e6dae108 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.196 2015/12/27 12:53:39 fabiankeil Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.197 2016/01/16 12:29:17 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -2441,6 +2441,14 @@ static const struct forward_spec *get_forward_override_settings(struct client_st /* Parse the parent HTTP proxy host:port */ http_parent = vec[1]; + } + else if ((vec_count == 2) && !strcasecmp(vec[0], "forward-webserver")) + { + fwd->type = FORWARD_WEBSERVER; + + /* Parse the parent HTTP server host:port */ + http_parent = vec[1]; + } else if (vec_count == 3) { diff --git a/gateway.c b/gateway.c index e42fec79..22efba5e 100644 --- a/gateway.c +++ b/gateway.c @@ -1,4 +1,4 @@ -const char gateway_rcs[] = "$Id: gateway.c,v 1.94 2015/06/18 15:26:40 fabiankeil Exp $"; +const char gateway_rcs[] = "$Id: gateway.c,v 1.95 2015/08/12 10:37:11 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/gateway.c,v $ @@ -635,6 +635,7 @@ jb_socket forwarded_connect(const struct forward_spec * fwd, switch (fwd->type) { case SOCKS_NONE: + case FORWARD_WEBSERVER: sfd = connect_to(dest_host, dest_port, csp); break; case SOCKS_4: diff --git a/jcc.c b/jcc.c index 86f4a70b..a95b5b95 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.436 2015/03/27 12:40:08 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.437 2015/12/28 18:55:49 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -918,7 +918,7 @@ static void build_request_line(struct client_state *csp, const struct forward_sp *request_line = strdup(http->gpc); string_append(request_line, " "); - if (fwd->forward_host) + if (fwd->forward_host && fwd->type != FORWARD_WEBSERVER) { string_append(request_line, http->url); } @@ -1986,7 +1986,7 @@ static void chat(struct client_state *csp) if (csp->server_connection.sfd == JB_INVALID_SOCKET) { - if (fwd->type != SOCKS_NONE) + if ((fwd->type != SOCKS_NONE) && (fwd->type != FORWARD_WEBSERVER)) { /* Socks error. */ rsp = error_response(csp, "forwarding-failed"); diff --git a/project.h b/project.h index 67f841fe..9b548792 100644 --- a/project.h +++ b/project.h @@ -1,7 +1,7 @@ #ifndef PROJECT_H_INCLUDED #define PROJECT_H_INCLUDED /** Version string. */ -#define PROJECT_H_VERSION "$Id: project.h,v 1.210 2015/12/27 12:46:46 fabiankeil Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.211 2016/01/16 12:30:28 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -652,6 +652,12 @@ enum forwarder_type { SOCKS_5 = 50, /**< Like SOCKS5, but uses non-standard Tor extensions (currently only optimistic data) */ SOCKS_5T, + /**< + * Don't use a SOCKS server, forward to the specified webserver. + * The difference to SOCKS_NONE is that a request line without + * full URL is sent. + */ + FORWARD_WEBSERVER, }; /* -- 2.39.2