diff --git a/CHANGES b/CHANGES index 445c6b5..f2666d6 100755 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +Changes to proxytunnel version 1.1.1 -- Tue May 14 12:09:07 CEST 2002 + +- Added a reworked version of Dieter Heiliger's idea to add a switch to + specify a User-Agent header to the CONNECT message. I made it into a + generic 'Header' function, so you can add whatever you like to the + connect string ( --header "MyCustomHeader: Value" ) + Changes to proxytunnel version 1.1.0 -- Mon Apr 22 22:58:05 CEST 2002 - Ported new features (like stand-alone mode) to CYGWIN and fixed some diff --git a/CREDITS b/CREDITS index 9f2b179..1811869 100644 --- a/CREDITS +++ b/CREDITS @@ -10,6 +10,7 @@ people. patch, rpm Spec file Martin Senft - Solaris patches Andrew Griffiths - String format fixes + Dieter Heiliger - User-agent header idea Furthermore we would like to thank the wonderful people at SourceForge diff --git a/cmdline.c b/cmdline.c index b23d191..f42eb4f 100755 --- a/cmdline.c +++ b/cmdline.c @@ -59,6 +59,7 @@ cmdline_parser_print_help (void) -G INT --proxyport=INT HTTPS Proxy portnumber to connect to\n\ -d STRING --desthost=STRING Destination host to built the tunnel to\n\ -D INT --destport=INT Destination portnumber to built the tunnel to\n\ + -H STRING --header=STRING Add STRING to HTTP headers sent to proxy\n\ -n --dottedquad Convert destination hostname to dotted quad\n\ -v --verbose Turn on verbosity (default=off)\n\ -q --quiet Suppress messages (default=off)\n\ @@ -110,6 +111,7 @@ int cmdline_parser( int argc, char * const *argv, struct gengetopt_args_info *ar args_info->verbose_given = 0; args_info->inetd_given = 0; args_info->quiet_given = 0; + args_info->header_given = 0; /* No... we can't make this a function... -- Maniac */ #define clear_args() \ @@ -118,6 +120,7 @@ int cmdline_parser( int argc, char * const *argv, struct gengetopt_args_info *ar args_info->pass_arg = NULL; \ args_info->proxyhost_arg = NULL; \ args_info->desthost_arg = NULL; \ + args_info->header_arg = NULL; \ args_info->dottedquad_flag = 0; \ args_info->verbose_flag = 0; \ args_info->inetd_flag = 0; \ @@ -140,6 +143,7 @@ int cmdline_parser( int argc, char * const *argv, struct gengetopt_args_info *ar #ifdef HAVE_GETOPT_LONG int option_index = 0; + /* Struct option: Name, Has_arg, Flag, Value */ static struct option long_options[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, @@ -149,6 +153,7 @@ int cmdline_parser( int argc, char * const *argv, struct gengetopt_args_info *ar { "proxyport", 1, NULL, 'G' }, { "desthost", 1, NULL, 'd' }, { "destport", 1, NULL, 'D' }, + { "header", 1, NULL, 'H' }, { "dottedquad", 0, NULL, 'n' }, { "verbose", 0, NULL, 'v' }, { "inetd", 0, NULL, 'i' }, @@ -157,9 +162,9 @@ int cmdline_parser( int argc, char * const *argv, struct gengetopt_args_info *ar { NULL, 0, NULL, 0 } }; - c = getopt_long (argc, argv, "hVia:u:s:g:G:d:D:nvq", long_options, &option_index); + c = getopt_long (argc, argv, "hVia:u:s:g:G:d:D:H:nvq", long_options, &option_index); #else - c = getopt( argc, argv, "hVia:u:s:g:G:d:D:nvq" ); + c = getopt( argc, argv, "hVia:u:s:g:G:d:D:H:nvq" ); #endif if (c == -1) break; /* Exit from `while (1)' loop. */ @@ -264,6 +269,12 @@ int cmdline_parser( int argc, char * const *argv, struct gengetopt_args_info *ar args_info->destport_arg = atoi (optarg); break; + case 'H': /* Extra headers to send to HTTPS proxy. */ + args_info->header_given++; + /* FIXME in case of multiple headers, later... */ + args_info->header_arg = gengetopt_strdup (optarg); + break; + case 'n': /* Turn on resolve to Dotted Quad */ args_info->dottedquad_flag = !(args_info->dottedquad_flag); break; diff --git a/http.c b/http.c index 22997e8..fc09b7e 100644 --- a/http.c +++ b/http.c @@ -96,28 +96,28 @@ void proxy_protocol() } + sprintf( buf, "CONNECT %s:%d HTTP/1.0\r\n", + args_info.desthost_arg, args_info.destport_arg ); + if ( args_info.user_given && args_info.pass_given ) { /* * Create connect string including the authorization part */ - sprintf( buf, - "CONNECT %s:%d HTTP/1.0\r\nProxy-authorization: Basic %s \r\nProxy-Connection: Keep-Alive\r\n\r\n", - args_info.desthost_arg, - args_info.destport_arg,basicauth ); + sprintf( buf, "%sProxy-authorization: Basic %s\r\n", + buf, basicauth ); } - else + + if ( args_info.header_given ) { /* - * Create connect string without authorization part + * Add extra header(s) */ - sprintf( buf, "CONNECT %s:%d HTTP/1.0\r\nProxy-Connection: Keep-Alive\r\n\r\n", - args_info.desthost_arg, - args_info.destport_arg ); + sprintf( buf, "%s%s\r\n\r\n", buf, args_info.header_arg ); } if( args_info.verbose_flag ) - message( "%s", buf); + message( "Connect string sent to Proxy: '%s'\n", buf); /* * Send the CONNECT instruction to the proxy