diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-16 11:17:00 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-16 11:17:00 +0100 |
commit | 217b238dfe2f74a8fa7ea7b5674cd68a585c9212 (patch) | |
tree | 89fe955c7449a790be7f26e263e3f0674240354a /utils/asn.pl | |
parent | 8f367144e8772a209a5f0b6133c601d5db69ce6c (diff) | |
download | rspamd-217b238dfe2f74a8fa7ea7b5674cd68a585c9212.tar.gz rspamd-217b238dfe2f74a8fa7ea7b5674cd68a585c9212.zip |
[Minor] Asn: Use bgpdump if it is available
Diffstat (limited to 'utils/asn.pl')
-rw-r--r-- | utils/asn.pl | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/utils/asn.pl b/utils/asn.pl index 42554cf5a..f283d0a08 100644 --- a/utils/asn.pl +++ b/utils/asn.pl @@ -8,12 +8,10 @@ use File::Fetch; use LWP::Simple; use PerlIO::gzip; use File::Basename; -use Net::MRT; use URI; use Data::Dumper; $LWP::Simple::ua->show_progress(1); -$Net::MRT::USE_RFC4760 = -1; my %config = ( asn_sources => [ @@ -55,12 +53,18 @@ GetOptions( "ns-server=s@" => \$ns_servers, "help|?" => \$help, "man" => \$man, - "bgpdump" => \$use_bgpdump ) or pod2usage(2); pod2usage(1) if $help; pod2usage( -exitval => 0, -verbose => 2 ) if $man; +if ( -x bgpdump ) { + use_bgpdump = $1; +} else { + warn "bgpdump is not found will try to use Net::MRT instead, results can be incomplete"; +} + + sub download_file { my ($u) = @_; @@ -202,6 +206,9 @@ foreach my $u ( @{ $config{'bgp_sources'} } ) { } } else { + require Net::MRT; + $Net::MRT::USE_RFC4760 = -1; + open( my $fh, "<:gzip", $fname ) or die "Cannot open $fname: $!"; while (my $dd = eval {Net::MRT::mrt_read_next($fh)}) { @@ -317,7 +324,6 @@ asn.pl [options] --zone-v6 IPv6 zone (default: asn6.rspamd.com) --file-v4 IPv4 zone file (default: ./asn.zone) --file-v6 IPv6 zone (default: ./asn6.zone) - --bgpdump Use bgpdump utility instead of NET::MRT --help Brief help message --man Full documentation |