From faf655c5db2a10e2af0c7a95de9c70b412800ea7 Mon Sep 17 00:00:00 2001 From: Robert James Kaes Date: Mon, 17 Dec 2001 19:10:56 +0000 Subject: Added the code to log the request when in tunnelling mode. --- src/reqs.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/reqs.c b/src/reqs.c index aee7b82..d0c9cde 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -1,4 +1,4 @@ -/* $Id: reqs.c,v 1.43 2001-12-17 00:11:32 rjkaes Exp $ +/* $Id: reqs.c,v 1.44 2001-12-17 19:10:56 rjkaes Exp $ * * This is where all the work in tinyproxy is actually done. Incoming * connections have a new thread created for them. The thread then @@ -41,6 +41,11 @@ #define HTTP500ERROR "Unable to connect to remote server." #define HTTP503ERROR "Internal server error." +/* + * Maximum length of a HTTP line + */ +#define HTTP_LINE_LENGTH (1024 * 16) + /* * Macro to help test if the Upstream proxy supported is compiled in and * enabled. @@ -183,7 +188,6 @@ extract_ssl_url(const char *url, struct request_s *request) /* * Create a connection for HTTP connections. */ -#define HTTP_LINE_LENGTH (1024 * 16) static int establish_http_connection(struct conn_s *connptr, struct request_s *request) { @@ -886,6 +890,7 @@ handle_connection(int fd) "You do not have authorization for using this service."); goto send_error; } + #ifdef TUNNEL_SUPPORT /* * If tunnel has been configured then redirect any connections to @@ -894,6 +899,21 @@ handle_connection(int fd) * - rjkaes */ if (config.tunnel_name && config.tunnel_port != -1) { + char *request_buf; + size_t len; + int pos; + + request_buf = safemalloc(HTTP_LINE_LENGTH); + if (request_buf) { + len = recv(connptr->client_fd, request_buf, HTTP_LINE_LENGTH - 1, MSG_PEEK); + for (pos = 0; pos < len && request_buf[pos] != '\n'; pos++) + ; + request_buf[pos] = '\0'; + + log_message(LOG_CONN, "Request: %s", request_buf); + + safefree(request_buf); + } log_message(LOG_INFO, "Redirecting to %s:%d", config.tunnel_name, config.tunnel_port); -- cgit v1.2.3