X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fshow%2Fbadip.pl;fp=cmd%2Fshow%2Fbadip.pl;h=a92329c9fde1d1c4ed350ef23fe9619b01493e2b;hb=19241b6f37923a92a56bf7890a5126f30f9b9d05;hp=55fa556b8e675384e9ccd75d24439721d0ddfd16;hpb=d0b21f21559a63d84086b549bb7570e2e16b75cd;p=spider.git diff --git a/cmd/show/badip.pl b/cmd/show/badip.pl index 55fa556b..a92329c9 100644 --- a/cmd/show/badip.pl +++ b/cmd/show/badip.pl @@ -16,36 +16,38 @@ my @added; my @in = split /\s+/, $line; my $maxlth = 0; my $width = $self->width // 80; +my $count = 0; #$DB::single = 1; -my @list = map {my $s = $_; $s =~ s|/32$||; $maxlth = length $s if length $s > $maxlth; $s =~ /^1$/?undef:$s} DXCIDR::list(); -my @l; -$maxlth //= 20; -my $n = int ($width/($maxlth+1)); -my $format = "\%-${maxlth}s " x $n; -chop $format; - -my $count = 0; - -foreach my $list (@list) { - if (@in) { - for my $in (@in) { - if ($list =~ /$in/i) { - push @out, $list; - ++$count; - } +# query +if (@in) { + foreach my $ip (@in) { + if (DXCIDR::find($ip)) { + push @out, "$ip FOUND"; + ++$count; + } else { + push @out, "$ip CLEAN"; } - } else { + } + return (1, @out); +} else { +# list + my @list = map {my $s = $_; $s =~ s!/(?:32|128)$!!; $maxlth = length $s if length $s > $maxlth; $s =~ /^1$/?undef:$s} DXCIDR::list(); + my @l; + $maxlth //= 20; + my $n = int ($width/($maxlth+1)); + my $format = "\%-${maxlth}s " x $n; + chop $format; + + foreach my $list (@list) { ++$count; if (@l > $n) { push @out, sprintf $format, @l; @l = (); } push @l, $list; - } -} -unless (@in) { + } push @l, "" while @l < $n; push @out, sprintf $format, @l; }