add load/badip.pl
authorDirk Koopman <djk@tobit.co.uk>
Sat, 7 Jan 2023 17:31:02 +0000 (17:31 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Sat, 7 Jan 2023 17:31:02 +0000 (17:31 +0000)
Changes
cmd/load/badip.pl [new file with mode: 0644]
perl/DXCIDR.pm

diff --git a/Changes b/Changes
index 374e1321167b0c7dfe66e54b2a2785bd36d4b53c..12216135525d40b7d8dd8dd5044d5b5d7b039944 100644 (file)
--- 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 (file)
index 0000000..22967cd
--- /dev/null
@@ -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);
index 230920f97be01ebd77a8db69b052a9d01770e4d6..2ef0d1937954dccd2f004bd5777e72a9da773e92 100644 (file)
@@ -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