On Fri, 13 Nov 1998, Mark Reynolds wrote:
]Which version of squid will this work for? Version 1 I'd bet.
]I can't seeing this working with version 1.2/2 as the
]swap.state file is no longer a simple text file.
]
]If anyone had a version 1.2/2 method, I think it would be
]interesting and useful for many people.
You'd have to go over all /var/spool/cache/??/??/* files, and extract the
URL from the start. But the URL is contained within a binary struct, thus
perl looks feasible for the task. Unfortunately, the URL recorded there
might be truncated. Nevertheless, try the perl script appended below my
signature (for squid-2). Insert whatever you need in the match()
subroutine at the place marked 'HERE'. Replace $cachedir with the
appropriate location.
This is a quick hack. Use at your own risk. No guarantees, whatsoever!
E.g. will break if you happen to have other non-related material named
'asdf01qwer' or similar underneath your $cachedir. Hopefully, pine's
quoted printable encoding will not garble my script too much.
If I have some time left, I might fiddle with unpack() to obtain the URL
less chancy and possibly faster. And some other possibly interesting info
besides it, too.
Le deagh dhùrachd,
Dipl.-Ing. Jens-S. Vöckler (voeckler@rvs.uni-hannover.de)
Institute for Computer Networks and Distributed Systems
University of Hanover, Germany; +49 511 762 4726
--- &< snip, snip ----
#!/usr/bin/perl
# for use with squid-2
require 5.003;
my $cachedir = '/var/spool/cache';
my ($top,$sub,$file,$line);
# the glob operator fails, thus we have to do it manually...
opendir( TOP, "$cachedir" ) || die "opendir($cachedir): $!\n";
while ( ($top = readdir(TOP)) ) {
next unless $top =~ /[0-9A-F]{2,2}/;
print STDERR "# processing in $cachedir/$top\n";
if ( opendir( SUB, "$cachedir/$top" ) ) {
while ( ($sub = readdir(SUB)) ) {
next unless $sub =~ /[0-9A-F]{2,2}/;
if ( opendir( FILES, "$cachedir/$top/$sub" ) ) {
while ( ($file = readdir(FILES)) ) {
next unless $file =~ /[0-9A-F]{8,8}/;
match("$cachedir/$top/$sub/$file");
}
closedir(FILES);
} else {
warn "opendir($sub): $!\n";
}
}
closedir(SUB);
} else {
warn "opendir($top): $!\n";
}
}
closedir(TOP);
sub match ($) {
my $fn = shift;
if ( open(IN, "<$fn") ) {
if ( sysread( IN, $line, 8192 ) > 60 ) {
# throw away first 60 byte, and everything after LF
$_ = substr($line,60,index($line,"\n",60)-60);
# throw away the HTTP return code
s(HTTP/1\.\d.*)();
#
# HERE!
# Insert whatever necessary here, e.g. call external
# client program with PURGE method.
#
#print "$fn $_\n";
print "$_\n";
#
#
} else {
warn "# $fn is strange...\n";
}
close(IN);
} else {
warn "open($fn): $!\n";
}
}
Received on Fri Nov 13 1998 - 07:38:34 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:43:02 MST