From 3b87cb901b1aa6604814d3f585561a404603f43f Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Sat, 7 Jan 2023 17:31:02 +0000 Subject: [PATCH] add load/badip.pl --- Changes | 1 + cmd/load/badip.pl | 19 +++++++++++++++++++ perl/DXCIDR.pm | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 cmd/load/badip.pl diff --git a/Changes b/Changes index 374e1321..12216135 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ 1. Fillout DXCIDR, attach checks in PC61 and logins. Login that fail will simply disconnect, like locked out callsigns 2. Fix qrz.com URL in stock Internet.pm. +3. Fix DXHash issues (baddx, badnode, badspotter etc) 30Dec22======================================================================= 1. Add more BadWords (regex) checks. 01Dec22======================================================================= diff --git a/cmd/load/badip.pl b/cmd/load/badip.pl new file mode 100644 index 00000000..22967cd7 --- /dev/null +++ b/cmd/load/badip.pl @@ -0,0 +1,19 @@ +# +# load list of bad dx nodes +# +# Copyright (c) 2023 - Dirk Koopman G1TLH +# +# +my ($self, $line) = @_; +return (1, $self->msg('e5')) if $self->remotecmd; +# are we permitted? +return (1, $self->msg('e5')) if $self->priv < 6; + +my @out; + +my $count = 0; +eval{ $count += DXCIDR::load(); }; +return (1, "load/badip: $_ $@") if $@; + +push @out, "load/badip: added $count entries"; +return (1, @out); diff --git a/perl/DXCIDR.pm b/perl/DXCIDR.pm index 230920f9..2ef0d193 100644 --- a/perl/DXCIDR.pm +++ b/perl/DXCIDR.pm @@ -85,6 +85,8 @@ sub _put sub add { + my $count = 0; + for my $ip (@_) { # protect against stupid or malicious next if /^127\./; @@ -95,6 +97,7 @@ sub add next; } $ipv4->add_any($ip); + ++$count; ++$count4; } elsif (/:/) { if ($ipv6->find($ip)) { @@ -102,6 +105,7 @@ sub add next; } $ipv6->add_any($ip); + ++$count; ++$count6; LogDbg('DXProt', "DXCIDR: Added IPV6 $ip address"); } @@ -114,6 +118,7 @@ sub add $ipv6->prep_find; _put($ipv6, 6); } + return $count; } sub save -- 2.34.1