to show on the console - we use $path most places in the code
# Yes, I know Perl doesn't care, but since this item shows on the console, it confuses some Win32
users
# to see a frontslash in the middle of their path. We don't want confused users do we?
if ($^O eq 'MSWin32') {
$HoTTProxyConfig{'CookieDirectory'} = "$path\\$HoTTProxyConfig{'CookieDirectory'}";
} else {
$HoTTProxyConfig{'CookieDirectory'} = "$path/$HoTTProxyConfig{'CookieDirectory'}";
}
# Find the "public" IP Address of this machine
if ($HoTTProxyConfig{'IPDetectionURL'} and $HoTTProxyConfig{'IPDetectionRegEx'}) {
my $ua = LWP::UserAgent->new(agent=>"HoTTProxy/$HoTTProxyVersion");
my $response = $ua->get($HoTTProxyConfig{'IPDetectionURL'});
my $content = $response->content;
if ($content) {
eval("(\$HoTTProxyConfig{'PublicIPAddr'}) = \$content =~ $HoTTProxyConfig{'IPDetectionRegEx'}");
}
}
# Find the "private" IP Address of this machine
$HoTTProxyConfig{'LocalHostName'} = hostname();
$HoTTProxyConfig{'LocalHostName'} = 'localhost' unless $HoTTProxyConfig{'LocalHostName'};
$HoTTProxyConfig{'PrivateIPAddr'} = inet_ntoa(scalar
gethostbyname($HoTTProxyConfig{'LocalHostName'}));
# Determine whether or not Proxy Cookie Support is (or can be) enabled
if ( (-e "$HoTTProxyConfig{'CookieDirectory'}/") and ( eval("proxyCookieSupport()") ) and (not
$HoTTProxyConfig{'DisableProxyCookieSupport'})) {
$HoTTProxyConfig{'ProxyCookiesEnabled'} = 1;
} else {
$HoTTProxyConfig{'ProxyCookiesEnabled'} = 0;
}
# I want to get rid of this $logDetail variable at some point and just use
$HoTTProxyConfig{'LogDetail'}
my $logDetail = 1 if $HoTTProxyConfig{'LogDetail'};
say ("\nRun this program with the '/license' switch to see the license.\n",0);
say ("\n" . '=' x 79 . "\n\n",0);
foreach my $i (sort(keys(%HoTTProxyConfig))) {
if (not $hiddenConfig{$i}) {
if(ref($HoTTProxyConfig{$i}) eq 'HASH') {
my @configKeys = sort(keys(%{$HoTTProxyConfig{$i}}));
say(sprintf("%27s: %s","+$i",$configKeys[0]) . "\n",1);
my $j;
for ($j=1; $j<=$#configKeys; $j++) {
say(sprintf("%27s %s",'',$configKeys[$j]) . "\n",1);
}
} else {
say(sprintf("%27s: %s",$i,$HoTTProxyConfig{$i}) . "\n",1);
}
}
}
say ("\n" . '=' x 79 . "\n\n",1);
my @userFiles = bsd_glob("$path/*.user"); # We just need a count of files - we don't do anything
else with these two arrays
my @passwordFiles = bsd_glob("$path/*.password");
say("!!!!! Warning !!!!!\n\nNo .user or .password files found. You will be unable to access\nthis
proxy until you create at least one user account.\n\nSee the documentation for details!\n\n")
unless (scalar(@userFiles) or scalar(@passwordFiles));
my %cookieStore; # This hash will hold all of the cookie bags
# I have no idea if this is correct or not, but I wanted to overload the HTTP::Daemon->proxy_tokens
method so the
# "Server" header that is returned is "HoTTProxy/#.#.#.#" instead of the default
"libwww-perl-daemon/#.##"
# This seems to work - hopefully someone will tell me if this is bad practice.
{
package HTTP::Daemon;
sub product_tokens {
return "HoTTProxy/$HoTTProxyVersion";
}
}
my $proxy = HTTP::Proxy->new( port => $HoTTProxyConfig{'ProxyPort'}, host => '', via =>
$HoTTProxyConfig{'ViaString'} ); # Via is what shows up has HTTP_VIA on the web server
# ------------- This block of code is to enable capturing and redirecting of 'proxy:homepage'
homepage requests as seen in Alltel
$proxy->init();
$proxy->agent->protocols_allowed( [ @{ $proxy->agent->protocols_allowed() }, 'proxy' ] ); # Add
bogus protocol 'proxy' to the list of supported protocols
# ------------- End special code for proxy:homepage
if ($HoTTProxyConfig{'HTTP_Proxy_Module_Logmask'} =
uc($HoTTProxyConfig{'HTTP_Proxy_Module_Logmask'})) {
$HoTTProxyConfig{'HTTP_Proxy_Module_Logmask'} =~ s/[^A-Z |\w]//g; # Only allow capital A-Z,
spaces, and |
eval "\$proxy->logmask($HoTTProxyConfig{'HTTP_Proxy_Module_Logmask'})";
}
=2= |