X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fset%2Fbadip.pl;h=1ed8225adb050de98ac87e7d388860c8785125e6;hb=b13a483683bc4e449a18743eae324fcdf4aea385;hp=b53763569127f2505be6d73f3afcb3ac27ca8a13;hpb=3f1464a293cbdbe1ee1f6a41fabaec1e6a6a7119;p=spider.git diff --git a/cmd/set/badip.pl b/cmd/set/badip.pl index b5376356..1ed8225a 100644 --- a/cmd/set/badip.pl +++ b/cmd/set/badip.pl @@ -9,10 +9,16 @@ 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, 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; -return (1, "set/badip: need IP, IP-IP or IP/24") unless @in; +my $suffix = 'local'; +if ($in[0] =~ /^[_\d\w]+$/) { + $suffix = shift @in; +} +return (1, "set/badip: need [suffix (def: local])] IP, IP-IP or IP/24") unless @in; for my $ip (@in) { my $r; eval{ $r = DXCIDR::find($ip); }; @@ -21,12 +27,13 @@ for my $ip (@in) { push @out, "set/badip: $ip exists, not added"; next; } - DXCIDR::add($ip); + DXCIDR::add($suffix, $ip); push @added, $ip; } my $count = @added; my $list = join ' ', @in; DXCIDR::clean_prep(); -DXCIDR::save(); -push @out, "set/badip: added $count entries: $list" if $count; +#$DB::single = 1; +DXCIDR::append($suffix, @added); +push @out, "set/badip: added $count entries to badip.$suffix : $list" if $count; return (1, @out);