From 61fe8f951eba89d430046d23bca9d65b30561578 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Wed, 4 Jan 2023 23:35:57 +0000 Subject: [PATCH] fix DXCIDR inet_pton calls --- cmd/show/badip.pl | 2 +- perl/DXCIDR.pm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/show/badip.pl b/cmd/show/badip.pl index 475abde1..b378abde 100644 --- a/cmd/show/badip.pl +++ b/cmd/show/badip.pl @@ -14,7 +14,7 @@ my @added; my @in = split /\s+/, $line; my $maxlth = 0; -$DB::single = 1; +#$DB::single = 1; my @list = map {my $s = $_; $s =~ s|/32$||; $maxlth = length $s if length $s > $maxlth; $s =~ /^1$/?undef:$s} DXCIDR::list(); diff --git a/perl/DXCIDR.pm b/perl/DXCIDR.pm index 506b9693..230920f9 100644 --- a/perl/DXCIDR.pm +++ b/perl/DXCIDR.pm @@ -16,7 +16,7 @@ use DXUtil; use DXLog; use IO::File; use File::Copy; -use Socket qw(inet_pton inet_ntop); +use Socket qw(AF_INET AF_INET6 inet_pton inet_ntop); our $active = 0; our $badipfn = "badip"; @@ -128,7 +128,7 @@ sub _sort my @in; my @out; for (@_) { - push @in, [inet_pton($_), split m|/|]; + push @in, [inet_pton(m|:|?AF_INET6:AF_INET, $_), split m|/|]; } @out = sort {$a->[0] <=> $b->[0]} @in; return map { "$_->[1]/$_->[2]"} @out; -- 2.43.0