Signal Handling (dag-)

Reworked debug output (dag-)


git-svn-id: https://proxytunnel.svn.sourceforge.net/svnroot/proxytunnel/trunk/proxytunnel@135 bc163920-b10d-0410-b2c5-a5491ca2ceef
This commit is contained in:
Mark Janssen 2006-09-01 08:32:53 +00:00
parent cfd9302f98
commit 4e5e275810
4 changed files with 47 additions and 16 deletions

View file

@ -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

39
http.c
View file

@ -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();
}

9
io.c
View file

@ -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 :-)

View file

@ -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 )
{