PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|Proxy|HoTTProxy|HoTTProxy.pl =

page 1 of 12



#!/usr/bin/perl

# Note that in this program, I invented the term "cookie bag".  I consider the cookie "jar" for a 
# given user to be all of the cookies in all of his .cookies files.  Each different domain 
restriction 
# (e.g. .google.com) has it's own file and I'm calling that file a cookie "bag" since it is a 
smaller 
# collection of cookies than the whole "jar".

# Also note that I have made no attempt to handle cookies in compliance with any RFC as they have 
# all taken a good, simple thing and made way too much of it.  I instead have attempted to comply 
# (as much as is practicable) with the Netscape Cookie Specification found here 
# http://wp.netscape.com/newsref/std/cookie_spec.html.

# Particular thanks to Philippe "BooK" Bruhat for the Perl HTTP::Proxy module which is the core of 
# HoTTProxy.

# To-do List:
# ===========
# Need to finish the web based administrative control panel
# Discard expired cookies (get rid of them in the cookie bags) instead of just not sending them
# Need to do a filefree check before opening cookie bag file for output so as not to step on self
# Need to do something with the logging so that the log file wraps off or something
# Need to make CookiePassthru and SetCookiePassthru do something
# Need to write the manual

# Note: HoTTProxy started out as a quick hack to see if I could make a proxy server. Once it worked 
#       (suprisingly easily mind you), then I set out to add the proxy cookie support, and more and 
#       more features. Since it grew kind of quickly, and without any thought of others seeing the 
#       code, some things in here might still be a bit kludgy. One notable example would be that 
#       there are still a bunch of remarked out "print STDERR something" lines. I use these for 
#       troubleshooting and un-rem them as necessary. Some of these have been turned into "say" 
#       instructions and given a ConsoleVerbosity level, but many have not. The code *is* fairly 
#       well commented, so if you are skilled with Perl you should be able to follow it.

# We need 0.16 or greater because the ability to add protocols to protocols_allowed wasn't added 
until 0.16
use HTTP::Proxy 0.16 qw( :log );

use HTTP::Proxy::HeaderFilter::simple;
use HTTP::Proxy::BodyFilter::simple;
use HTTP::Date; # We use this module when converting epoch time to "cookie" time and vice versa
use MIME::Base64 qw( encode_base64 decode_base64 );
use IO::Handle;
use LWP::UserAgent;
use Digest::MD5 qw / md5_hex /;
use Date::Calc qw / Date_to_Time Decode_Date_US /;
use Socket;  # To figure out the local host name
use Sys::Hostname;  # To figure out the local host name
use File::Glob qw / :glob /;

require 'HoTTProxy_Add-In_Filters.pl';  # Any user-defined filters can be put in here

my $HoTTProxyVersion = '0.24.0.0';

use strict;

$|=1;

# We need the path to the present executable.  Under Win32 this is pretty 
# positive using the Win32::GetFullPathName.  Under Linux and the like, 
# it looks like $ENV{'PWD'} will get us what we want - suggestions?
my $path;
my $slash;
if ($^O eq 'MSWin32') {
 $path = Win32::GetFullPathName( $0 );
 ($path) = $path =~ m/^(.*)\\/; # e.g. C:\data\programming\Perl\HoTTProxy (no trailing slash)
 
} else {
 $path = $ENV{'PWD'};
}

my %HoTTProxyConfig;  # This hash will store the configuration settings for the proxy
my %hiddenConfig;  # Items listed in this hash won't show on the console -
	start the element name with a minus ('-') to hide -
	mostly used for items you just don't care about

say("
HoTTProxy $HoTTProxyVersion - (c) 2005 Brian A. Blakley

This program is free for personal use but must be licensed for commercial use.

License is contained in License.txt. License.txt is only a valid file if it is
signed by PGP Key \"Brian Blakley <bblakley\@mp5.net> (0xE66620C3)\".

",0);

processParameters();  # Handle all the command line parameters

# Set default config file if one not specified on command line
$HoTTProxyConfig{'ConfigFile'} = 'HoTTProxy.conf' unless $HoTTProxyConfig{'ConfigFile'};

loadConfig($HoTTProxyConfig{'ConfigFile'});  # Load up all the customizable settings

# Yes, I know we already did this, but some command line parameters *over-ride* the 
# config file while some need to be handled before we load the config file.  This is a 
# cheap and easy way to make this happen.
processParameters();  

$HoTTProxyConfig{'RunningFrom'} = $path; # This is just to get the path
=1=

= PAGE 1 = NEXT > |2|3|4|5|6|7|8|9|10.12

UP TO ROOT | UP TO DIR

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.0297692 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)