Re: Bug log ordering
I wrote:
> The cgi script wouldn't have to run on the same system. It's
> a pretty simple script (see below), just change input mechanism
> from <> to something based on use CGI;
I took a look at CGI.pm and decided it didn't really do the right
stuff for running the script on a different system. Here's a
version which deals with this issue.
Note: you may prefer to s-http:$www/-/-g in place of the current
s-"http:$www/-"/-g
--
Raul
#!/usr/bin/perl -w
=head1 NAME
getbug - quick hack to reverse displayed order of bug reports from default.
=head1 SYNOPSIS
tcpserver -R -c0 0.77.155.243 80 debianproxy /usr/local/bin/getbug &
or, in /etc/inetd.conf:
www stream tcp nowait nobody /usr/local/bin/getbug getbug
=head1 DESCRIPTION
Implements a proxy web server, aimed at transforming auto-generated
text -- such as is currently generated by Debian's bug report system --
from reverse chrono order to regular chrono order. Is not likely to do
anything to other text.
=cut
##################################################################
# configurable parameters
@www = (206,246,79,86);
$www = "www.debian.org";
##################################################################
$|=1;
$pat = 'S n C4 x8';
$inet = 2;
$http = 80;
$server = pack($pat,$inet,$http,@www);
socket(S,2,1,6) or die $!;
connect(S,$server) or die $!;
# aquire complete http request in case it needs to be re-issued
# [I ran across this need some time ago, but haven't been able
# to reproduce the problem...]
$requ= <STDIN>;
$httpversion= ($requ =~/\S+\s+\S+\s+\S+/)
? 1.0 # treat higher versions as 1.0...
: 0.9;
if ($httpversion == 1.0) {
while (<STDIN>) {
$requ.= $_;
last if $_ eq "\r\n";
last if $_ eq "\n";
}
}
select S;
$|=1;
print $requ;
# untested mechanism that might be needed for more complicated
# http transactions
#if (0==fork) {
# print $req;
# print while <STDIN>;
# exit;
#}
select STDOUT;
if ($httpversion == 1.0) {
# HTTP/1.0 -- examine http header for html..
$head="";
while (<S>) {
print $_;
$head.= $_;
last if $_ eq "\r\n";
}
unless ($head =~ m(\nContent-Type:\s*text/html)i) {
print while <S>;
exit;
}
} else {
# HTTP/0.9 -- sample first "line" from real web server
$line=<S>;
unless ($line =~ m(^<)) {
print $line;
print while <S>;
exit;
}
s-"http://$www/-"/-g;
print $line;
}
# html document -- process it..
$num=0;
while (<S>) {
s-"http://$www/-"/-go;
if (m-<h2>Message received at \S+\@bugs.debian.org:</h2><br>-
or m-<address>-) {
$part[++$num]= $_;
} else {
if ($num){
$part[$num].= $_;
} else {
print;
}
}
}
for ($i=$num-1; $i>0; $i--) {
print $part[$i];
}
print $part[$num] if $num;
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: