diff options
author | Ravi Chandra Padmala <neenaoffline@gmail.com> | 2012-02-21 08:52:03 +0530 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-06-21 10:34:26 -0400 |
commit | 417d778652770a8f4b0b6f8e5d8e139e193b8b1e (patch) | |
tree | 18b468cfcda2991224a463850becf2de6f0447a9 /src/or/control.c | |
parent | 884c0ffe3b4266e66adbd6bb914c3b3b00401acb (diff) | |
download | tor-417d778652770a8f4b0b6f8e5d8e139e193b8b1e.tar.gz tor-417d778652770a8f4b0b6f8e5d8e139e193b8b1e.zip |
Respond meaningfully to HTTP requests on the control port. Fix #1667
(Squashed with bufferevents portions removed, by nickm)
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/or/control.c b/src/or/control.c index 9454a7ab67..3e31f17248 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -4882,6 +4882,12 @@ peek_connection_has_control0_command(connection_t *conn) return peek_buf_has_control0_command(conn->inbuf); } +static int +peek_connection_has_http_command(connection_t *conn) +{ + return peek_buf_has_http_command(conn->inbuf); +} + /** Called when data has arrived on a v1 control connection: Try to fetch * commands from conn->inbuf, and execute them. */ @@ -4921,6 +4927,38 @@ connection_control_process_inbuf(control_connection_t *conn) return 0; } + /* 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" +"<html>\n" +"<head>\n" +"<title>Tor's ControlPort is not proxy</title>\n" +"</head>\n" +"<body>\n" +"<h1>Tor's ControlPort is not a proxy</h1>\n" +"<p>\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" +"</p>\n" +"<p>\n" +"See <a href=\"https://www.torproject.org/documentation.html\">" + "https://www.torproject.org/documentation.html</a> for more " + "information.\n" +"<!-- Plus this comment, to make the body response more than 512 bytes, so " +" IE will be willing to display it. Comment comment comment comment " +" comment comment comment comment comment comment comment comment.-->\n" +"</p>\n" +"</body>\n" +"</html>\n", conn); + log_notice(LD_CONTROL, "Received HTTP request on ControlPort"); + connection_mark_and_flush(TO_CONN(conn)); + return 0; + } + again: while (1) { size_t last_idx; |