Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Compressing .sigs more

by strredwolf (Chaplain)
on Sep 19, 2001 at 21:25 UTC ( [id://113413]=obfuscated: print w/replies, xml ) Need Help??

My current .sig file. Any word on trying to get the perl parts shrunk down smaller?
eval join"",map{chomp;s/^[^>]+>\s*//;$_}grep{/>/}<DATA>; __DATA__ .' .' Kelly "STrRedWolf" Price WolfSkunk Des +igns xX xX .' http://stalag99.keenspace.com tygris(@)cablespeed(. +)com "X "X X .' NO UNSOLICITED COMMERCIAL E-MAIL ACCEPTED WITHOUT PAY +MENT _____. X" X FREE SPEECH-FREE DIMITRY: http://www.dibona.com/d +mca/ XXXXXXXx. X".' # dnsblcheck "dnsbl" "responce" < mail, ret 1 on fail +ure '"XXXXXX| X > while(<STDIN>){chomp;if(/^Received:[^\[]+\[(\d+)\.( +\d+) "XXX| X" > \.(\d+)\.(\d+)\]/){$n=`host $4.$3.$2.$1.$ARGV[0] 2> +&1`; 'XX' > exit(0) if($n=~/$ARGV[1]/m);}} exit(1);
The code needs to take an IP address out of a Received header (procmail will unmunge it so it's one header/line), reverse the numbers, and look up a host to check if it's on a DNS Blacklist.

One hint: The first line takes care of any bad breaking.

eval join "", map { chomp; s/^[^>]+>\s*//; $_} grep{/>/} <DATA>;
So lets see now... <DATA> sucks in the rest of the .sig. Th' grep filters everything but three lines (which have ">" up front), in which the map will remove any end-of-line characters, strip off everything up to and including "> ", and the join will just merge everything into one line which eval gets to run through.

--
$Stalag99{"URL"}="http://stalag99.keenspace.com";

Replies are listed 'Best First'.
Re: Compressing .sigs more
by jynx (Priest) on Sep 20, 2001 at 01:23 UTC

    AFAICT,

    It looks like the part you want changed is the last three lines of perl, kinda like so:

    while(<STDIN>) { chomp; if (/^Received:[^\[]+\[(\d+)\.(\d+)\.(\d+)\.(\d+)\]/) { $n=`host $4.$3.$2.$1.$ARGV[0] 2>&1`; exit(0) if ($n=~/$ARGV[1]/m); } } exit(1);
    Well, the best i could come up with looks something like this:
    while(<STDIN>){$_="host ".join'.',map{s/(\d+)/$1/}split /./."$ARGV[0] 2>&1";`$_`=~/$ARGV[1]/m&&exit 0}exit 1
    (or if we spread that out for readability):
    while (<STDIN>) { $_= "host " . join '.', map {s/(\d+)/$1/} split /./ . "$ARGV[0] 2>&1"; `$_` =~ /$ARGV[1]/m && exit 0 } exit 1
    Which reduces it one line. It has not been tested well at all (but should have the same functionality), and could probably be reduced more. Does this help at all?

    jynx

      That partly helps, but I do need to do the filtering and lookup on that Received header.

      --
      $Stalag99{"URL"}="http://stalag99.keenspace.com";


        here's my next attempt,

        Actually, this is two attempts. After playing around with my original twist a couple of times, i found that to do what it needs to do it would have to be longer than your original code. So i instead took your original code and chopped off unimportant bits and did some reformatting. Both of the following snippets seem to test out correctly (using warnings and strict):

        /^Received[^\[]+\[(\d+).(\d+).(\d+).(\d+)]/?`host $4.$3. $2.$1.$ARGV[0] 2>&1`=~/$ARGV[1]/m&&exit 0:1while<STDIN>; exit 1 while(<STDIN>){s/^Received[^\[]+//&&s/].*//?($_='host ' .(join'.',(reverse map{s/(\D+)//;$_}split/\./),$ARGV[0] ).' 2>&1',`$_`=~/$ARGV[1]/m&&exit 0):1}exit 1
        The first one is based off of yours, i'm sure there's a way to squeeze it further, but i can't see it from here. The second is a re-working of my previous answer, and is obviously inadequate space-wise.

        Hope This Helps,
        jynx


        PS i'm not sure how space-conscientious you want to be, but you could also shorten the first line to:

        eval join"",map{chop;s/^[^>]+>\s*//&&$_}<DATA>__END__
        if you're really desperate for space. As always, it could probably be shortened more... :)
Typos?
by tommyw (Hermit) on Sep 20, 2001 at 01:45 UTC

    Ok, I'm definately not an obfuscated expert, I may have missed something here. But...
    shouldn't the regexp in the map be s/^[^>]+>\s*//; instead?

    And you've got $n~= in the last line. $n=~ methinks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://113413]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found