From: Nick Mathewson Date: Wed, 5 Jul 2017 15:01:17 +0000 (-0400) Subject: Extract "not an HTTP proxy" messages. X-Git-Tag: tor-0.3.2.1-alpha~265^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=03b6cfd5911740471eac13e82f678fe50b4d18f9;p=thirdparty%2Ftor.git Extract "not an HTTP proxy" messages. --- diff --git a/src/or/buffers.c b/src/or/buffers.c index b071725474..aff113ff6a 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -1478,6 +1478,32 @@ socks_request_set_socks5_error(socks_request_t *req, req->reply[3] = 0x01; // ATYP field. } +const char SOCKS_PROXY_IS_NOT_AN_HTTP_PROXY_MSG[] = + "HTTP/1.0 501 Tor is not an HTTP Proxy\r\n" + "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" + "\n" + "\n" + "Tor is not an HTTP Proxy\n" + "\n" + "\n" + "

Tor is not an HTTP Proxy

\n" + "

\n" + "It appears you have configured your web browser to use Tor as " + "an HTTP proxy.\n\n" + "This is not correct: Tor is a SOCKS proxy, not an HTTP proxy.\n" + "Please configure your client accordingly.\n" + "

\n" + "

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

\n" + "\n" + "\n"; + /** Implementation helper to implement fetch_from_*_socks. Instead of looking * at a buffer's contents, we look at the datalen bytes of data in * data. Instead of removing data from the buffer, we set @@ -1834,32 +1860,8 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req, case 'H': /* head */ case 'P': /* put/post */ case 'C': /* connect */ - strlcpy((char*)req->reply, -"HTTP/1.0 501 Tor is not an HTTP Proxy\r\n" -"Content-Type: text/html; charset=iso-8859-1\r\n\r\n" -"\n" -"\n" -"Tor is not an HTTP Proxy\n" -"\n" -"\n" -"

Tor is not an HTTP Proxy

\n" -"

\n" -"It appears you have configured your web browser to use Tor as an HTTP proxy." -"\n" -"This is not correct: Tor is a SOCKS proxy, not an HTTP proxy.\n" -"Please configure your client accordingly.\n" -"

\n" -"

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

\n" -"\n" -"\n" - , MAX_SOCKS_REPLY_LEN); + strlcpy((char*)req->reply, SOCKS_PROXY_IS_NOT_AN_HTTP_PROXY_MSG, + MAX_SOCKS_REPLY_LEN); req->replylen = strlen((char*)req->reply)+1; /* fall through */ default: /* version is not socks4 or socks5 */ diff --git a/src/or/control.c b/src/or/control.c index ee9a3ae29b..20a0b0b89e 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -4888,6 +4888,32 @@ peek_connection_has_http_command(connection_t *conn) return peek_buf_has_http_command(conn->inbuf); } +const char CONTROLPORT_IS_NOT_AN_HTTP_PROXY_MSG[] = + "HTTP/1.0 501 Tor ControlPort is not an HTTP proxy" + "\r\nContent-Type: text/html; charset=iso-8859-1\r\n\r\n" + "\n" + "\n" + "Tor's ControlPort is not an HTTP proxy\n" + "\n" + "\n" + "

Tor's ControlPort is not an HTTP proxy

\n" + "

\n" + "It appears you have configured your web browser to use Tor's control port" + " as an HTTP proxy.\n" + "This is not correct: Tor's default SOCKS proxy port is 9050.\n" + "Please configure your client accordingly.\n" + "

\n" + "

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

\n" + "\n" + "\n"; + /** Called when data has arrived on a v1 control connection: Try to fetch * commands from conn->inbuf, and execute them. */ @@ -4930,30 +4956,7 @@ connection_control_process_inbuf(control_connection_t *conn) /* If the user has the HTTP proxy port and the control port confused. */ if (conn->base_.state == CONTROL_CONN_STATE_NEEDAUTH && peek_connection_has_http_command(TO_CONN(conn))) { - connection_write_str_to_buf("HTTP/1.0 501 Tor ControlPort is not a proxy" -"\r\nContent-Type: text/html; charset=iso-8859-1\r\n\r\n" -"\n" -"\n" -"Tor's ControlPort is not proxy\n" -"\n" -"\n" -"

Tor's ControlPort is not a proxy

\n" -"

\n" -"It appears you have configured your web browser to use Tor's control port" -" as an HTTP proxy.\n" -"This is not correct: Tor's default SOCKS proxy port is 9050.\n" -"Please configure your client accordingly.\n" -"

\n" -"

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

\n" -"\n" -"\n", conn); + connection_write_str_to_buf(CONTROLPORT_IS_NOT_AN_HTTP_PROXY_MSG, conn); log_notice(LD_CONTROL, "Received HTTP request on ControlPort"); connection_mark_and_flush(TO_CONN(conn)); return 0;