Hello, I've made myself a small Perl program to trace which proxies are
being used to service various HTTP requests, and would like to know what
HTTP headers, other than x-cache and x-cache-lookup are inserted by
proxies (so far, I have only encountered Squid).
I'd post it on my website, but it currently won't let me in, so I've
stuck it below. It's still in its early stages, in that it's output
needs to be tidied up a bit.
$ pxytrace
Proxy detected
x-cache: MISS from proxy2.akl1.maxnet.net.nz
x-cache: MISS from belgarath.localdomain
$ pxytrace -a -u http://slashdot.org/
link = ARRAY(0x82f5790)
slash-log-data = shtml
connection = close
x-powered-by = Slash 2.003000
client-response-num = 1
cache-control = private
date = Tue, 15 Jun 2004 22:16:37 GMT
client-peer = 66.35.250.150:80
client-date = Tue, 15 Jun 2004 22:16:47 GMT
pragma = private
content-type = text/html; charset=iso-8859-1
title = Slashdot: News for nerds, stuff that matters
x-cache-lookup = MISS from belgarath.localdomain:3128
Proxy detected
x-cache: MISS from proxy1.akl1.maxnet.net.nz
x-cache: MISS from belgarath.localdomain
x-cache = ARRAY(0x81d3eec)
server = Apache/1.3.29 (Unix) mod_gzip/1.3.26.1a mod_perl/1.29
x-fry = Hey look, it's that guy you are!
Any help would be appreciated.
---- pxytrace ----
#!/usr/bin/perl -w
#
# Are we subject to a transparent proxy? If so, where is it?
# This is done by looking using the online proxy-detection service.
#
# Cameron Kerr
# 12 June 2004
use strict;
use Getopt::Std;
use LWP::UserAgent;
use Data::Dumper;
my $deturl = 'http://www.google.com/';
my $usage = "Usage: pxydetect-trans [-q] [-a] [-u URL]\n" .
" -q (Quiet), -a (Print all headers), -u (URL to request)\n";
my %opts;
getopts "qu:a", \%opts or die $usage;
$deturl = $opts{'u'} if defined $opts{'u'};
my $ua = LWP::UserAgent->new;
$ua->agent("Proxy Detector");
$ua->env_proxy;
my $req = HTTP::Request->new( GET => $deturl );
my $res = $ua->request($req);
my $foundproxy = 0;
if( $res->is_success ) {
foreach my $header (keys %{$res->headers}) {
my $value = $res->headers->{$header};
$foundproxy++;
print "Proxy detected\n" unless $opts{'q'};
if( ref($value) eq "ARRAY" ) {
print $header, ": ", $i, "\n";
}
} else {
print $header, ": ", $value, "\n";
}
}
print $header, " = ", $value, "\n" if $opts{'a'};
}
exit 0 if $foundproxy;
print "No proxy detected\n";
exit 1
die $res->status_line . "\n";Quote:} else {
die "Should not have gotten here\n";Quote:}
------------------
--
Cameron Kerr
Empowered by Perl!