#!/usr/bin/perl -w # (c) 2003 # Julien Tayon LDCOM # julien@tayon.net julien.tayon@ldcom.fr # use strict; use LWP::UserAgent; use LWP::RobotUA; use LWP::Authen::Basic; use Data::Dumper; use Net::IP; use Math::BigInt; my $ua = LWP::UserAgent->new; $ua->agent("whois wanderer 1.0"); my $req = HTTP::Request->new(GET => 'http://ripe.net/perl/whois?form_type=advanced&full_query_string=&searchtext=LDCOM-mnt&do_search=Search&reverse_delegation_domains=ON&inverse_attributes=mnt-by&ip_search_lvl=Default&alt_database=RIPE&object_type=inetnum'); my $res = $ua->request($req); if ($res->is_success) { # noting here } else { # print STDERR Dumper ($res->headers); die "impossible to get URL \n"; } my @ips; my $val; my $pflag=0; foreach my $line ( split ("\n", $res->content) ) { chomp ($line); if( $line =~ m!inetnum[^\d]+([0-9][\d\.\-\s]{10,})! ) { $pflag=1; push @ips, new Net::IP($1) or die (Net::IP::Error()); } $pflag = ($line =~ /^source:/) ? 0 : $pflag; # print $line . "\n" if ($pflag); } #print Dumper @ips; sub is_included { my $res = $a->overlaps($b) eq $IP_A_IN_B_OVERLAP; if ( $res != 0 ) { return $res; } else { return $a->intip() <=> $b->intip() ; } } my $last; my $decalage=0; my $firsttime=0; my ($a,$b); my $big=0; format this = debut : @<<<<<<<<<<<<<<<<<< fin : @<<<<<<<<<<<<<<<<<< $a, $b . $~ = 'this'; foreach my $ip (sort is_included @ips) { if ( $firsttime eq 0) { $last=$ip; $firsttime=1; } my $inc; if ( $big ) { $last = $big }; $~ = ''; $inc = $ip->overlaps($last) eq $IP_A_IN_B_OVERLAP; if ($inc) { $decalage++; $big=$last; } else {$decalage=0; $big=0; } print " " x $decalage . ":" x ( 8 - $decalage ) ; $~ = 'this'; # foreach my $ip2 (sort { $a <=> $b } @ips) { # if ( $a=$ip->ip(); $b=$ip->last_ip(); write; $last=$ip; }