aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-27 12:25:25 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-27 12:25:40 +0000
commitbc08cc1e47b0b4a7cbc83f356861517d125c12a8 (patch)
tree03fb935dd8a64cc7b2cb6900f8e4672489f7011e /utils
parent2452fe09ea8579da8ab5c842ff050a30c4d94062 (diff)
downloadrspamd-bc08cc1e47b0b4a7cbc83f356861517d125c12a8.tar.gz
rspamd-bc08cc1e47b0b4a7cbc83f356861517d125c12a8.zip
[Minor] Improve asn.pl helper script
Diffstat (limited to 'utils')
-rw-r--r--utils/asn.pl26
1 files changed, 20 insertions, 6 deletions
diff --git a/utils/asn.pl b/utils/asn.pl
index 5959b5c93..be56c0962 100644
--- a/utils/asn.pl
+++ b/utils/asn.pl
@@ -32,7 +32,7 @@ my $download_target = "./";
my $help = 0;
my $man = 0;
my $v4 = 1;
-my $v6 = 0;
+my $v6 = 1;
my $parse = 1;
my $v4_zone = "asn.rspamd.com";
my $v6_zone = "asn6.rspamd.com";
@@ -43,7 +43,7 @@ GetOptions(
"download-asn" => \$download_asn,
"download-bgp" => \$download_bgp,
"4!" => \$v4,
- "6" => \$v6,
+ "6!" => \$v6,
"parse!" => \$parse,
"target=s" => \$download_target,
"zone-v4=s" => \$v4_zone,
@@ -116,6 +116,10 @@ foreach my $u ( @{ $config{'bgp_sources'} } ) {
my $net = $dd->{'prefix'} . '/' . $dd->{'bits'};
if ( $entry && $entry->{'AS_PATH'} ) {
my $as = $entry->{'AS_PATH'}->[-1];
+ if (ref($as) eq "ARRAY") {
+ $as = @{$as}[0];
+ }
+
if ( !$networks->{$as} ) {
if ( $dd->{'subtype'} == 2 ) {
$networks->{$as} = { nets_v4 => [$net], nets_v6 => [] };
@@ -153,9 +157,15 @@ foreach my $u ( @{ $config{'asn_sources'} } ) {
my $as_end = $as_start + int( $elts[4] );
for ( my $as = $as_start ; $as < $as_end ; $as++ ) {
- if ( $networks->{"$as"} ) {
- $networks->{"$as"}->{'country'} = $elts[1];
- $networks->{"$as"}->{'rir'} = $elts[0];
+ my $real_as = $as;
+
+ if (ref($as) eq "ARRAY") {
+ $real_as = @{$as}[0];
+ }
+
+ if ( $networks->{"$real_as"} ) {
+ $networks->{"$real_as"}->{'country'} = $elts[1];
+ $networks->{"$real_as"}->{'rir'} = $elts[0];
}
}
}
@@ -201,8 +211,12 @@ asn.pl [options]
Options:
--download-asn Download ASN data from RIR
- --download-bgp Download GeoIP data from Maxmind
+ --download-bgp Download GeoIP data from Maxmind
--target Where to download files (default: current dir)
+ --zone-v4 IPv4 zone (default: asn.rspamd.com)
+ --zone-v6 IPv6 zone (default: asn6.rspamd.com)
+ --file-v4 IPv4 zone file (default: ./asn.zone)
+ --file-v6 IPv6 zone (default: ./asn6.zone)
--help Brief help message
--man Full documentation