X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fshow%2Fbadip.pl;h=475abde165e2856454874dcc5147be223868a916;hb=ceb2daf21a03249decadc86f4b90711fe8a53b0e;hp=73db65da76df80e96329a8b84b21035844f9263a;hpb=400227d4bd709387099bf224b1c00a6f988c8196;p=spider.git diff --git a/cmd/show/badip.pl b/cmd/show/badip.pl index 73db65da..475abde1 100644 --- a/cmd/show/badip.pl +++ b/cmd/show/badip.pl @@ -12,7 +12,18 @@ return (1, $self->msg('e5')) if $self->priv < 6; my @out; my @added; my @in = split /\s+/, $line; -my @list= DXCIDR::list(); +my $maxlth = 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 (80/($maxlth+1)); +my $format = "\%-${maxlth}s " x $n; +chop $format; + foreach my $list (@list) { if (@in) { for (@in) { @@ -22,7 +33,17 @@ foreach my $list (@list) { } } } else { - push @out, $list; - } + if (@l > $n) { + push @out, sprintf $format, @l; + @l = (); + } + push @l, $list; + } +} +unless (@in) { + push @l, "" while @l < $n; + push @out, sprintf $format, @l; } + +push @out, "show/badip: " . scalar @list . " records found"; return (1, @out);