Networking Forums

Networking Forums > Computer Networking > Linux Networking > Proxy trace headers

Reply
Thread Tools Display Modes

Proxy trace headers

 
 
Cameron Kerr
Guest
Posts: n/a

 
      06-15-2004, 06:28 PM
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:umper;

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 @pxyhdrs = qw/x-cache/;

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};
if( scalar grep {$_ eq $header} @pxyhdrs ) {
$foundproxy++;
print "Proxy detected\n" unless $opts{'q'};
if( ref($value) eq "ARRAY" ) {
foreach my $i (@$value) {
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
} else {
die $res->status_line . "\n";
}

die "Should not have gotten here\n";
------------------

--
Cameron Kerr
(E-Mail Removed) : http://nzgeeks.org/cameron/
Empowered by Perl!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
802.11 b headers Adrian Wireless Internet 2 11-21-2005 09:56 AM
client-proxy request headers noc-ops Linux Networking 0 05-14-2005 04:47 AM
Proxy configuration - tool for identifying what proxy is being use =?Utf-8?B?Q2hyaXMgQg==?= Windows Networking 0 03-21-2005 08:31 PM
Spamassassin headers. What you can do with Spamassassin headers and how. dsaklad@zurich.csail.mit.edu Linux Networking 1 03-06-2005 06:35 PM
Slow retrieving headers Terry Pinnell Broadband 6 09-26-2004 04:17 PM



1 2 3 4 5 6 7 8 9 10 11