projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix showdx, is_ipaddr, create_master_badip_files.pl
[spider.git]
/
cmd
/
show
/
badip.pl
diff --git
a/cmd/show/badip.pl
b/cmd/show/badip.pl
index 73db65da76df80e96329a8b84b21035844f9263a..c7b2122d472a92927d30f8aa0a10e337d7fd77b9 100644
(file)
--- a/
cmd/show/badip.pl
+++ b/
cmd/show/badip.pl
@@
-9,10
+9,24
@@
my ($self, $line) = @_;
return (1, $self->msg('e5')) if $self->remotecmd;
# are we permitted?
return (1, $self->msg('e5')) if $self->priv < 6;
return (1, $self->msg('e5')) if $self->remotecmd;
# are we permitted?
return (1, $self->msg('e5')) if $self->priv < 6;
+return (1, q{Please install Net::CIDR::Lite or libnet-cidr-lite-perl to use this command}) unless $DXCIDR::active;
+
my @out;
my @added;
my @in = split /\s+/, $line;
my @out;
my @added;
my @in = split /\s+/, $line;
-my @list= DXCIDR::list();
+my $maxlth = 0;
+my $width = $self->width // 80;
+
+#$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;
+
foreach my $list (@list) {
if (@in) {
for (@in) {
foreach my $list (@list) {
if (@in) {
for (@in) {
@@
-22,7
+36,17
@@
foreach my $list (@list) {
}
}
} else {
}
}
} 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 @out . " records found";
return (1, @out);
return (1, @out);