diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-03 14:40:05 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-03 14:40:05 +0100 |
commit | 32a4e9d75500bd0300534fce653198b6098e8b9b (patch) | |
tree | bfe5030ad64df37bb111a082fb4d5e2873148f72 /utils | |
parent | 09b039623c6a5b3a6436156b93c6c77df40c60fe (diff) | |
download | rspamd-32a4e9d75500bd0300534fce653198b6098e8b9b.tar.gz rspamd-32a4e9d75500bd0300534fce653198b6098e8b9b.zip |
[Minor] Fix download
Diffstat (limited to 'utils')
-rw-r--r-- | utils/asn.pl | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/utils/asn.pl b/utils/asn.pl index 23ad544f3..c4fca4a22 100644 --- a/utils/asn.pl +++ b/utils/asn.pl @@ -47,7 +47,7 @@ sub download_file { print "Fetching $u\n"; my $ff = File::Fetch->new( uri => $u ); - my $where = $ff->fetch($download_target) or die $ff->error; + my $where = $ff->fetch( to => $download_target ) or die $ff->error; return $where; } @@ -64,12 +64,16 @@ if ($download_bgp) { } } +if ( $download_asn || $download_bgp ) { + exit 0; +} + # Now load BGP data my $networks = {}; foreach my $u ( @{ $config{'bgp_sources'} } ) { my $parsed = URI->new($u); - my $fname = $download_target . basename( $parsed->path ); + my $fname = $download_target . '/' . basename( $parsed->path ); open( my $fh, "<:gzip", $fname ) or die "Cannot open $fname: $!"; @@ -93,7 +97,7 @@ foreach my $u ( @{ $config{'bgp_sources'} } ) { # Now roughly detect countries foreach my $u ( @{ $config{'asn_sources'} } ) { my $parsed = URI->new($u); - my $fname = $download_target . basename( $parsed->path ); + my $fname = $download_target . '/' . basename( $parsed->path ); open( my $fh, "<", $fname ) or die "Cannot open $fname: $!"; while (<$fh>) { @@ -108,17 +112,18 @@ foreach my $u ( @{ $config{'asn_sources'} } ) { for ( my $as = $as_start ; $as < $as_end ; $as++ ) { if ( $networks->{"$as"} ) { $networks->{"$as"}->{'country'} = $elts[1]; - $networks->{"$as"}->{'rir'} = $elts[0]; + $networks->{"$as"}->{'rir'} = $elts[0]; } } } } } -while ( my ( $k, $v ) = each(%{$networks}) ) { - foreach my $n (@{$v->{'nets'}}) { +while ( my ( $k, $v ) = each( %{$networks} ) ) { + foreach my $n ( @{ $v->{'nets'} } ) { + # "15169 | 8.8.8.0/24 | US | arin |" for 8.8.8.8 - if ($v->{'country'}) { + if ( $v->{'country'} ) { printf "%s %s|%s|%s|%s|\n", $n, $k, $n, $v->{'country'}, $v->{'rir'}; } else { |