nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] Stanford disliking my emails -- update + question


From: Paul Fox
Subject: Re: [Nmh-workers] Stanford disliking my emails -- update + question
Date: Fri, 24 Apr 2015 08:16:34 -0400

bob wrote:
 > I'm not actually replying directly to Robert's message.  Rather,
 > I'm noting that I never received the copy from the mailing list;
 > only the one sent directly to me, and after a 33-hour delay
 > between Oz and GMail:
 > 
 >      [...]
 >      Received: from munnari.OZ.AU (munnari.OZ.AU. [202.29.151.3])
 >              by mx.google.com with ESMTPS id 
 > m6si7752252obh.91.2015.04.24.01.39.10
 >              for <address@hidden>
 >              (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 
 > bits=128/128);
 >              Fri, 24 Apr 2015 01:39:24 -0700 (PDT)
 >      [...]
 >      Received: from perseus.noi.kre.to (localhost [IPv6:::1]) by 
 > munnari.OZ.AU with ESMTP
 >              id t3MNZIX5024587; Thu, 23 Apr 2015 06:35:43 +0700 (ICT)
 >      Received: from perseus.noi.kre.to (localhost [127.0.0.1])
 >              by perseus.noi.kre.to (8.14.7/8.14.2) with ESMTP id 
 > t3MNYADA005974;
 >              Thu, 23 Apr 2015 06:34:10 +0700 (ICT)
 > 
 > (I did see others' replies to it, that were sent to the mailing
 > list, and was waiting to see if I'd ever get a copy.)

you've just reminded me of one of my favorite special-purpose scripts,
posted long ago (perhaps to the qmail list) by its author.  it parses
Received headers, converts them all to local time, and prints them in
"reverse" (i.e., timeline) order, in a uniform format.  makes it much
easier to figure out who held up delivery.  your message to me took 11
seconds to traverse 6 hops.

paul

#!/usr/bin/perl -w
#!/usr/local/bin/perl -w
#
# mailroute by Chris Garrigues <address@hidden>
#
# Reads an email message on stdin and pretty prints the contents of the
# recieved headers.
#
# When given an email message as it's argument will parse out the received
# headers and display the route it took to get to you and the times it
# arrived at each of the locations in your local timezone.
#
# It also tries to be clever in how it displays things:  (1) It only shows
# what changed in the date/time rather than the entire date/time each time. 
# (2) It breaks the line before the keywords "from", "by", and "with"
# unless they appear in comments.

use Time::Local;

# Global variable for date parsing
%mon = ('jan' => 0,
        'feb' => 1,
        'mar' => 2,
        'apr' => 3,
        'may' => 4,
        'jun' => 5,
        'jul' => 6,
        'aug' => 7,
        'sep' => 8,
        'oct' => 9,
        'nov' => 10,
        'dec' => 11);

# Initialize some variables to keep -w quiet
($owd, $om, $od, $ot, $oy) = ("", "", "", "", "");

# Read the headers into $_
($_ = "\n" . join("", <>)) =~ s/\n\n.*$//sg;

# Parse the contents of the received headers into an array
@rec = ();
while (/\nreceived:(.*?)(\n\S)/gis) {
    unshift(@rec, $1);
    $_ = "$2$'";
}

for (@rec) {
    s/\s+/ /gs;
    # Format is "information; date"
    ($line, $date) = /^\s*(.*?)\s*;\s*(.*?)$/;
    $date =~ s/\(.*\)//g;
    $date =~ s/\s+/ /gs;
    # Parse the sucker
    if ($date =~ /(\d+) (jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) 
(\d\d\d\d) (\d+):(\d\d):(\d\d) ([+-]?\d+)/i) {
        # Coerce the date into something we can give to timegm
        $d = $1;
        ($m = $2) =~ tr/A-Z/a-z/;
        $m = $mon{$m};
        $y = $3 - 1900;
        $h = $4;
        $mi = $5;
        $s = $6;
        ($zh, $zm) = $7 =~ /^([-+]\d\d)(\d\d)$/;
        # hmm, a timezone like -0830 will break this...damn.
        ($wd, $m, $d, $t, $y) =
            split(' ',
                  localtime(timegm($s, $mi, $h, $d, $m, $y) -
                            ($zh*60*60 + $zm*60)));
        $d = " $d" if ($d < 10);
        # Insert line breaks
        $line =~ s/(by|with|from)/\n                         $1/g;
        # But take them back out if they're in a comment
        while ($line =~ s/\(([^()]*?)\s\s+?(.*?)\)/\($1 $2\)/gs) {};
        $line =~ s/\( /\(/g;
        $line =~ s/^\s*//s;
        # Figure out what parts of the date we want to display
        ($pwd, $pm, $pd, $pt, $py) = ($wd, $m, $d, $t, $y);
        $pwd = "   " if ($wd eq $owd);
        $pm = "   " if ($m eq $om);
        $pd = "  " if ($d eq $od);
        $pt = "        " if ($t eq $ot);
        $py = "    " if ($y eq $oy);
        print "$pwd $pm $pd $py $pt $line\n";
        ($owd, $om, $od, $ot, $oy) = ($wd, $m, $d, $t, $y);

    } else {
        # bail...
        print "$date $line\n";
    }
}

=----------------------
 paul fox, address@hidden (arlington, ma, where it's 40.8 degrees)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]