diff --git a/CHANGES b/CHANGES index 1fa117b..d04f713 100755 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,8 @@ Changes to proxytunnel version 1.6.4 -- xxx - Suggested changes (From Dag Wieers) to install-target applied - Change debug-output line-endings - Change error message on 'connection closed' in analyze_HTTP +- Reworked debug-output (dag-) +- Signal handling (dag-) Changes to proxytunnel version 1.6.3 -- Mon Apr 10 12:48:02 CEST 2006 diff --git a/http.c b/http.c index 25ba83c..8de4f65 100644 --- a/http.c +++ b/http.c @@ -93,6 +93,16 @@ void analyze_HTTP() } } +void print_line(char *buf) +{ + char *buf2 = strdup(buf); + char *p = strtok(buf2, "\r\n"); + while ( p != NULL) { + message( "-> %s\n", p ); + p = strtok(NULL, "\r\n"); + } +} + /* * Execute the basic proxy protocol of CONNECT and response, until the * last line of the response has been read. The tunnel is then open. @@ -145,8 +155,13 @@ void proxy_protocol() sprintf( buf, "%sProxy-Connection: Keep-Alive\r\n\r\n", buf ); - if( args_info.verbose_flag ) - message( "Connect string sent to Proxy: '%s'\n", buf); + /* + * Print the CONNECT instruction before sending to proxy + */ + if( args_info.verbose_flag ) { + message( "Connect string sent to local proxy:\n"); + print_line(buf); + } /* * Send the CONNECT instruction to the proxy @@ -159,6 +174,9 @@ void proxy_protocol() /* * Read the first line of the response and analyze it */ + if( args_info.verbose_flag ) + message( "Received from local proxy:\n"); + analyze_HTTP(); if (args_info.remproxy_given ) @@ -168,7 +186,8 @@ void proxy_protocol() */ while ( strcmp( buf, "\r\n" ) != 0 ) readline(); - message( "Tunneling to %s (destination)\n", args_info.dest_arg ); + if( args_info.verbose_flag ) + message( "Tunneling to %s (destination)\n", args_info.dest_arg ); sprintf( buf, "CONNECT %s HTTP/1.0\r\n", args_info.dest_arg ); /* @@ -178,9 +197,14 @@ void proxy_protocol() sprintf( buf, "%s%s\r\n", buf, args_info.header_arg ); sprintf( buf, "%sProxy-Connection: Keep-Alive\r\n\r\n", buf ); - if( args_info.verbose_flag ) - message( "DEBUG: Send: '%s'\n", buf); - + /* + * Print the CONNECT instruction before sending to proxy + */ + if( args_info.verbose_flag ) { + message( "Connect string sent to remote proxy:\n"); + print_line(buf); + } + /* * Send the CONNECT instruction to the proxy */ @@ -193,6 +217,9 @@ void proxy_protocol() /* * Read the first line of the response and analyze it */ + if( args_info.verbose_flag ) + message( "Received from remote proxy:\n"); + analyze_HTTP(); } diff --git a/io.c b/io.c index c9bc6be..84fc480 100644 --- a/io.c +++ b/io.c @@ -70,7 +70,8 @@ int readline() { char * dstr = malloc(sizeof(buf-1) ); strlcpy( dstr, buf, strlen(buf) -1 ); - message( "DEBUG: recv: '%s'\n", dstr ); + if (strcmp(dstr, "")) + message( "<- %s\n", dstr ); } return strlen( buf ); } @@ -219,10 +220,8 @@ void cpio() */ FD_ZERO( &writefds ); - if( ! args_info.quiet_flag ) - { - message( "Starting tunnel\n" ); - } + if( args_info.verbose_flag ) + message( "Tunnel established\n" ); /* * Only diamonds are forever :-) diff --git a/proxytunnel.c b/proxytunnel.c index ca32cfa..1a0189e 100755 --- a/proxytunnel.c +++ b/proxytunnel.c @@ -61,8 +61,9 @@ SSL_METHOD *meth; */ void signal_handler( int signal ) { - message( "Tunnel closed on signal %d\n", signal ); - closeall(); + if( args_info.verbose_flag ) + message( "Tunnel received signal %d. Ignoring signal.\n", signal ); +// closeall(); } /* @@ -91,7 +92,9 @@ void tunnel_connect() { exit(1); } - if( args_info.verbose_flag ) + char ip[16]; + snprintf(ip, 16, "%d.%d.%d.%d", he->h_addr[0] & 255, he->h_addr[1] & 255, he->h_addr[2] & 255, he->h_addr[3] & 255); + if( args_info.verbose_flag && strcmp(args_info.proxyhost_arg, ip)) { message( "%s is %d.%d.%d.%d\n", args_info.proxyhost_arg, @@ -120,7 +123,7 @@ void tunnel_connect() { if( ! args_info.quiet_flag ) { - message( "Connected to %s:%d\n", + message( "Connected to %s:%d (local proxy)\n", args_info.proxyhost_arg, args_info.proxyport_arg ); } @@ -152,7 +155,7 @@ void do_ssl() * Leave a goodbye message */ void closeall() { - message( "In closeall\n"); +// message( "In closeall\n"); if( args_info.verbose_flag ) {