From 728d20ed08122d2f34b001217faa009040fb2fee Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 17 Apr 2019 17:58:40 +1000 Subject: [PATCH 1/3] connection_edge: Return a web page when HTTPTunnelPort is misconfigured Return an informative web page when the HTTPTunnelPort is used as an HTTP proxy. Closes ticket 27821, patch by "eighthave". --- changes/ticket27821 | 3 +++ src/core/or/connection_edge.c | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 changes/ticket27821 diff --git a/changes/ticket27821 b/changes/ticket27821 new file mode 100644 index 0000000000..158f308fbf --- /dev/null +++ b/changes/ticket27821 @@ -0,0 +1,3 @@ + o Minor features (HTTP tunnel): + - Return an informative web page when the HTTPTunnelPort is used as an + HTTP proxy. Closes ticket 27821, patch by "eighthave". diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c index 071a8c91ed..4f7cbafe07 100644 --- a/src/core/or/connection_edge.c +++ b/src/core/or/connection_edge.c @@ -2810,6 +2810,31 @@ connection_ap_process_natd(entry_connection_t *conn) return connection_ap_rewrite_and_attach_if_allowed(conn, NULL, NULL); } +static const char HTTP_CONNECT_IS_NOT_AN_HTTP_PROXY_MSG[] = + "HTTP/1.0 405 Method Not Allowed\r\n"; + "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" + "\n" + "\n" + "This is an HTTP CONNECT tunnel, not an full HTTP Proxy\n" + "\n" + "\n" + "

This is an HTTP CONNECT tunnel, not an HTTP proxy.

\n" + "

\n" + "It appears you have configured your web browser to use this Tor port as\n" + "an HTTP proxy.\n" + "

\n" + "This is not correct: This port is configured as a CONNECT tunnel, not\n" + "an HTTP proxy. Please configure your client accordingly. You can also\n" + "use HTTPS, then the client should automatically use HTTP CONNECT." + "

\n" + "

\n" + "See " + "https://www.torproject.org/documentation.html for more " + "information.\n" + "

\n" + "\n" + "\n"; + /** Called on an HTTP CONNECT entry connection when some bytes have arrived, * but we have not yet received a full HTTP CONNECT request. Try to parse an * HTTP CONNECT request from the connection's inbuf. On success, set up the @@ -2850,7 +2875,7 @@ connection_ap_process_http_connect(entry_connection_t *conn) tor_assert(command); tor_assert(addrport); if (strcasecmp(command, "connect")) { - errmsg = "HTTP/1.0 405 Method Not Allowed\r\n\r\n"; + errmsg = HTTP_CONNECT_IS_NOT_AN_HTTP_PROXY_MSG; goto err; } From c483ccf1c9e8fc1c4026dbf8c3e685ec55e8d8bb Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 17 Apr 2019 18:43:20 +1000 Subject: [PATCH 2/3] connection_edge: remove an extra ; --- src/core/or/connection_edge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c index 4f7cbafe07..33ba723971 100644 --- a/src/core/or/connection_edge.c +++ b/src/core/or/connection_edge.c @@ -2811,7 +2811,7 @@ connection_ap_process_natd(entry_connection_t *conn) } static const char HTTP_CONNECT_IS_NOT_AN_HTTP_PROXY_MSG[] = - "HTTP/1.0 405 Method Not Allowed\r\n"; + "HTTP/1.0 405 Method Not Allowed\r\n" "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" "\n" "\n" From f12b990bbf6876fd019b9d9d5e8ef42c1bde2550 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 17 Apr 2019 18:44:26 +1000 Subject: [PATCH 3/3] practracker: accept the extra 25 line string from 27821 --- scripts/maint/practracker/exceptions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt index 7d03bf27d6..d77e788654 100644 --- a/scripts/maint/practracker/exceptions.txt +++ b/scripts/maint/practracker/exceptions.txt @@ -102,7 +102,7 @@ problem function-size /src/core/or/circuituse.c:circuit_get_open_circ_or_launch( problem function-size /src/core/or/circuituse.c:connection_ap_handshake_attach_circuit() 244 problem function-size /src/core/or/command.c:command_process_create_cell() 156 problem function-size /src/core/or/command.c:command_process_relay_cell() 132 -problem file-size /src/core/or/connection_edge.c 4550 +problem file-size /src/core/or/connection_edge.c 4575 problem include-count /src/core/or/connection_edge.c 64 problem function-size /src/core/or/connection_edge.c:connection_ap_expire_beginning() 117 problem function-size /src/core/or/connection_edge.c:connection_ap_handshake_rewrite() 192