From 0a92a4608d715cd9cd7eec3c120da651fbb4da5b Mon Sep 17 00:00:00 2001 From: minima Date: Tue, 9 Jan 2001 00:59:39 +0000 Subject: [PATCH] added DXHash.pm added/changed set/unset/show baddx badspotter badnode --- Changes | 6 ++ cmd/Commands_en.hlp | 57 ++++++++++++++---- cmd/set/baddx.pl | 10 ++++ cmd/set/badnode.pl | 14 +---- cmd/set/badspotter.pl | 10 ++++ cmd/show/baddx.pl | 10 ++++ cmd/show/badnode.pl | 10 +--- cmd/show/badspotter.pl | 10 ++++ cmd/unset/baddx.pl | 10 ++++ cmd/unset/badnode.pl | 14 +---- cmd/unset/badspotter.pl | 10 ++++ data/baddx.pl.issue | 19 ------ perl/DXHash.pm | 127 ++++++++++++++++++++++++++++++++++++++++ perl/DXMsg.pm | 6 +- perl/DXProt.pm | 26 ++++---- perl/Messages | 5 ++ 16 files changed, 271 insertions(+), 73 deletions(-) create mode 100644 cmd/set/baddx.pl create mode 100644 cmd/set/badspotter.pl create mode 100644 cmd/show/baddx.pl create mode 100644 cmd/show/badspotter.pl create mode 100644 cmd/unset/baddx.pl create mode 100644 cmd/unset/badspotter.pl delete mode 100644 data/baddx.pl.issue create mode 100644 perl/DXHash.pm diff --git a/Changes b/Changes index c2039fb6..a0b271e7 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +08Jan01======================================================================= +1. Changed the way that badnodes, badmsg etc work. There is a new general way +implemented (dunno why I didn't do this before - hey ho...) as a consequence +there are set/unset/show baddx (for bad dx callsigns) badnode (for dx from +bad nodes) badspotter (for bad spotters of dx eg VE2STN). Expect more of +this sort of thing... 06Jan01======================================================================= 1. Fix set/obscount so it actually works. 2. Allow different number formats for set/pingint eg: 5m for 5 minutes and diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 1cd2b30f..dbfa1770 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -607,11 +607,6 @@ running in order for the changes to take effect. Reload the /spider/data/bands.pl file if you have changed it manually whilst the cluster is running. -=== 9^LOAD/BADDX^Reload the bad DX table -Reload the /spider/data/baddx.pl file if you have changed it manually whilst -the cluster is running. This table contains the DX Calls that, if spotted, -will not be passed on. FR0G and TEST are classic examples. - === 9^LOAD/BADMSG^Reload the bad msg table Reload the /spider/msg/badmsg.pl file if you have changed it manually whilst the cluster is running. This table contains a number of perl regular @@ -931,17 +926,32 @@ SP is an alias for SEND PRIVATE === 5^SET/ARCLUSTER [..]^Make the callsign an AR-Cluster node -=== 6^SET/BADNODE ^Stop spots from this callsign being propagated -=== 6^UNSET/BADNODE ^Allow spots from this callsign again +=== 8^SET/BADDX ..^Stop spots for this callsign being propagated +=== 8^UNSET/BADDX ..^Allow spots for this callsign again +Setting a callsign as a 'baddx' will prevent spots of this callsign +going any further. They will not be displayed and they will not be +sent onto other nodes. + +The call must be a full eg:- + + set/baddx FORSALE VIDEO FR0G + + unset/badnode VIDEO + +will allow spots to that callsign again. + +=== 8^SET/BADNODE ..^Stop spots from this node being propagated +=== 8^UNSET/BADNODE ..^Allow spots from this node again Setting a callsign as a 'badnode' will prevent spots from that node going any further. They will not be displayed and they will not be sent onto other nodes. -The call can be a full or partial call (or a prefix), eg:- +The call must be a full eg:- set/badnode K1TTT -will stop anything from K1TTT (including any SSID's) +will stop anything from K1TTT. If you want SSIDs as well then you must +enter them specifically. unset/badnode K1TTT @@ -949,6 +959,25 @@ will allow spots from him again. Use with extreme care. This command may well be superceeded by FILTERing. +=== 8^SET/BADSPOTTER ..^Stop spots from this callsign being propagated +=== 8^UNSET/BADSPOTTER ..^Allow spots from this callsign again +Setting a callsign as a 'badspotter' will prevent spots from this callsign +going any further. They will not be displayed and they will not be +sent onto other nodes. + +The call must be a full eg:- + + set/badspotter VE2STN + +will stop anything from VE2STN. If you want SSIDs as well then you must +enter them specifically. + + unset/badnode VE2STN + +will allow spots from him again. + +Use with extreme care. This command may well be superceeded by FILTERing. + === 0^SET/BEEP^Add a beep to DX and other messages on your terminal === 0^UNSET/BEEP^Stop beeps for DX and other messages on your terminal @@ -1142,10 +1171,18 @@ Tell the system where you are. For example:- === 0^SET/WX^Allow WX messages to come out on your terminal === 0^UNSET/WX^Stop WX messages coming out on your terminal -=== 6^SHOW/BADNODE^Show all the bad nodes in the system +=== 1^SHOW/BADDX^Show all the bad dx calls in the system +Display all the bad dx callsigns in the system, see SET/BADDX +for more information. + +=== 1^SHOW/BADNODE^Show all the bad nodes in the system Display all the bad node callsigns in the system, see SET/BADNODE for more information. +=== 1^SHOW/BADSPOTTER^Show all the bad spotters in the system +Display all the bad spotter's callsigns in the system, see SET/BADSPOTTER +for more information. + === 0^SHOW/DATE [|]^Show the local time This is very nearly the same as SHOW/TIME, the only difference the format of the date string if no arguments are given. diff --git a/cmd/set/baddx.pl b/cmd/set/baddx.pl new file mode 100644 index 00000000..748640e1 --- /dev/null +++ b/cmd/set/baddx.pl @@ -0,0 +1,10 @@ +# +# set list of bad dx callsigns +# +# Copyright (c) 1998 - Dirk Koopman G1TLH +# +# $Id$ +# +my ($self, $line) = @_; +return $DXProt::baddx->set(8, $self->msg('e6'), $self, $line); + diff --git a/cmd/set/badnode.pl b/cmd/set/badnode.pl index 8af48111..bcd4679c 100644 --- a/cmd/set/badnode.pl +++ b/cmd/set/badnode.pl @@ -1,18 +1,10 @@ # -# set list of bad nodes +# set list of bad dx nodes # # Copyright (c) 1998 - Dirk Koopman G1TLH # # $Id$ # my ($self, $line) = @_; -return (1, $self->msg('e5')) if $self->priv < 6; -my @f = split /\s+/, $line; -my @out; -for (@f) { - return (1, $self->msg('e19')) if /[^\s\w_\-\/]/; - my $call = uc $_; - push @DXProt::nodx_node, $call; - push @out, $self->msg('badnode1', $call); -} -return (1, @out); +return $DXProt::badnode->set(8, $self->msg('e12'), $self, $line); + diff --git a/cmd/set/badspotter.pl b/cmd/set/badspotter.pl new file mode 100644 index 00000000..6478c6f1 --- /dev/null +++ b/cmd/set/badspotter.pl @@ -0,0 +1,10 @@ +# +# set list of bad dx spotters +# +# Copyright (c) 1998 - Dirk Koopman G1TLH +# +# $Id$ +# +my ($self, $line) = @_; +return $DXProt::badspotter->set(8, $self->msg('e6'), $self, $line); + diff --git a/cmd/show/baddx.pl b/cmd/show/baddx.pl new file mode 100644 index 00000000..6e8718c0 --- /dev/null +++ b/cmd/show/baddx.pl @@ -0,0 +1,10 @@ +# +# show list of bad dx callsigns +# +# Copyright (c) 1998 - Dirk Koopman G1TLH +# +# $Id$ +# +my ($self, $line) = @_; +return $DXProt::baddx->show(1, $self); + diff --git a/cmd/show/badnode.pl b/cmd/show/badnode.pl index ff59c68d..cbfa5047 100644 --- a/cmd/show/badnode.pl +++ b/cmd/show/badnode.pl @@ -1,14 +1,10 @@ # -# show list of bad nodes +# show list of bad dx nodes # # Copyright (c) 1998 - Dirk Koopman G1TLH # # $Id$ # my ($self, $line) = @_; -return (1, $self->msg('e5')) if $self->priv < 6; -my @out = ($self->msg('badnode3')); -for (@DXProt::nodx_node) { - push @out, $_; -} -return (1, @out); +return $DXProt::badnode->show(1, $self); + diff --git a/cmd/show/badspotter.pl b/cmd/show/badspotter.pl new file mode 100644 index 00000000..1110a0b8 --- /dev/null +++ b/cmd/show/badspotter.pl @@ -0,0 +1,10 @@ +# +# show list of bad spotter callsigns +# +# Copyright (c) 1998 - Dirk Koopman G1TLH +# +# $Id$ +# +my ($self, $line) = @_; +return $DXProt::badspotter->show(1, $self); + diff --git a/cmd/unset/baddx.pl b/cmd/unset/baddx.pl new file mode 100644 index 00000000..e9798728 --- /dev/null +++ b/cmd/unset/baddx.pl @@ -0,0 +1,10 @@ +# +# unset list of bad dx callsigns +# +# Copyright (c) 1998 - Dirk Koopman G1TLH +# +# $Id$ +# +my ($self, $line) = @_; +return $DXProt::baddx->unset(8, $self->msg('e6'), $self, $line); + diff --git a/cmd/unset/badnode.pl b/cmd/unset/badnode.pl index 4e42e28d..65d10527 100644 --- a/cmd/unset/badnode.pl +++ b/cmd/unset/badnode.pl @@ -1,18 +1,10 @@ # -# unset list of bad nodes +# set list of bad dx nodes # # Copyright (c) 1998 - Dirk Koopman G1TLH # # $Id$ # my ($self, $line) = @_; -return (1, $self->msg('e5')) if $self->priv < 6; -my @f = split /\s+/, $line; -my @out; -for (@f) { - return (1, $self->msg('e19')) if /[^\s\w_\-\/]/; - my $call = uc $_; - @DXProt::nodx_node = grep { !$call =~ /^$_/ } @DXProt::nodx_node; - push @out, $self->msg('badnode2', $call); -} -return (1, @out); +return $DXProt::badnode->unset(8, $self->msg('e12'), $self, $line); + diff --git a/cmd/unset/badspotter.pl b/cmd/unset/badspotter.pl new file mode 100644 index 00000000..5664f1cb --- /dev/null +++ b/cmd/unset/badspotter.pl @@ -0,0 +1,10 @@ +# +# set list of bad dx spotters +# +# Copyright (c) 1998 - Dirk Koopman G1TLH +# +# $Id$ +# +my ($self, $line) = @_; +return $DXProt::badspotter->unset(8, $self->msg('e6'), $self, $line); + diff --git a/data/baddx.pl.issue b/data/baddx.pl.issue deleted file mode 100644 index 55dfe0c5..00000000 --- a/data/baddx.pl.issue +++ /dev/null @@ -1,19 +0,0 @@ -# -# the list of dx spot addresses that we don't store and don't pass on -# - -package DXProt; - -@baddx = qw -( - FROG - SALE - FORSALE - WANTED - P1RATE - PIRATE - TEST - DXTEST - NIL - NOCALL -); diff --git a/perl/DXHash.pm b/perl/DXHash.pm new file mode 100644 index 00000000..b97d54c7 --- /dev/null +++ b/perl/DXHash.pm @@ -0,0 +1,127 @@ +# +# a class for setting 'bad' (or good) things +# +# This is really a general purpose list handling +# thingy for determining good or bad objects like +# callsigns. It is for storing things "For Ever". +# +# Things entered into the list are always upper +# cased. +# +# The files that are created live in /spider/data +# +# Dunno why I didn't do this earlier but heyho.. +# +# Copyright (c) 2001 Dirk Koopman G1TLH +# +# $Id$ +# + +package DXHash; + +use DXVars; +use DXUtil; +use DXDebug; + +use strict; + +sub new +{ + my ($pkg, $name) = @_; + my $s = readfilestr($main::data, $name); + my $self = eval $s; + dbg('err', "error in reading $name in DXHash $@") if $@; + $self = bless {name => $name}, $pkg unless $self; + return $self; +} + +sub put +{ + my $self = shift; + writefilestr($main::data, $self->{name}, undef, $self); +} + +sub add +{ + my $self = shift; + my $n = uc shift; + my $t = shift || time; + $self->{$n} = $t; +} + +sub del +{ + my $self = shift; + my $n = uc shift; + delete $self->{$n}; +} + +sub in +{ + my $self = shift; + my $n = uc shift; + return exists $self->{$n}; +} + +# this is really just a general shortcut for all commands to +# set and unset values +sub set +{ + my ($self, $priv, $noline, $dxchan, $line) = @_; + return (1, $dxchan->msg('e5')) unless $dxchan->priv >= $priv; + my @f = split /\s+/, $line; + return (1, $noline) unless @f; + my $f; + my @out; + + foreach $f (@f) { + + if ($self->in($f)) { + push @out, $dxchan->msg('hasha',uc $f, $self->{name}); + next; + } + $self->add($f); + push @out, $dxchan->msg('hashb', uc $f, $self->{name}); + } + $self->put; + return (1, @out); +} + +# this is really just a general shortcut for all commands to +# set and unset values +sub unset +{ + my ($self, $priv, $noline, $dxchan, $line) = @_; + return (1, $dxchan->msg('e5')) unless $dxchan->priv >= $priv; + my @f = split /\s+/, $line; + return (1, $noline) unless @f; + my $f; + my @out; + + foreach $f (@f) { + + unless ($self->in($f)) { + push @out, $dxchan->msg('hashd', uc $f, $self->{name}); + next; + } + $self->del($f); + push @out, $dxchan->msg('hashc', uc $f, $self->{name}); + } + $self->put; + return (1, @out); +} + +sub show +{ + my ($self, $priv, $dxchan) = @_; + return (1, $dxchan->msg('e5')) unless $dxchan->priv >= $priv; + + my @out; + for (sort keys %{$self}) { + next if $_ eq 'name'; + push @out, $dxchan->msg('hashe', $_, cldatetime($self->{$_})); + } + return (1, @out); +} + +1; diff --git a/perl/DXMsg.pm b/perl/DXMsg.pm index 501d137d..c91049ab 100644 --- a/perl/DXMsg.pm +++ b/perl/DXMsg.pm @@ -287,8 +287,7 @@ sub process $ref->swop_it($self->call); # look for 'bad' to addresses -# if (grep $ref->{to} eq $_, @badmsg) { - if ($ref->dump_it($self->call)) { + if ($ref->dump_it) { $ref->stop_msg($self->call); dbg('msg', "'Bad' message $ref->{to}"); Log('msg', "'Bad' message $ref->{to}"); @@ -761,7 +760,7 @@ sub init } # delete any messages to 'badmsg.pl' places - if (grep $ref->{to} eq $_, @badmsg) { + if ($ref->dump_it) { dbg('msg', "'Bad' TO address $ref->{to}"); Log('msg', "'Bad' TO address $ref->{to}"); $ref->del_msg; @@ -976,7 +975,6 @@ sub forward_it sub dump_it { my $ref = shift; - my $call = shift; my $i; for ($i = 0; $i < @badmsg; $i += 3) { diff --git a/perl/DXProt.pm b/perl/DXProt.pm index af94ecac..f03a6103 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -30,11 +30,12 @@ use Geomag; use WCY; use Time::HiRes qw(gettimeofday tv_interval); use BadWords; +use DXHash; use strict; use vars qw($me $pc11_max_age $pc23_max_age $last_hour %pings %rcmds - %nodehops @baddx $baddxfn $censorpc + %nodehops $baddx $badspotter $badnode $censorpc $allowzero $decode_dk0wcy $send_opernam @checklist); $me = undef; # the channel id for this cluster @@ -45,10 +46,11 @@ $last_hour = time; # last time I did an hourly periodic update %pings = (); # outstanding ping requests outbound %rcmds = (); # outstanding rcmd requests outbound %nodehops = (); # node specific hop control -@baddx = (); # list of illegal spotted callsigns $censorpc = 0; # Do a BadWords::check on text fields and reject things - -$baddxfn = "$main::data/baddx.pl"; + # loads of 'bad things' +$baddx = new DXHash "baddx"; +$badspotter = new DXHash "badspotter"; +$badnode = new DXHash "badnode"; @checklist = ( @@ -177,10 +179,6 @@ sub init do "$main::data/hop_table.pl" if -e "$main::data/hop_table.pl"; confess $@ if $@; $me->{sort} = 'S'; # S for spider - - # load the baddx file - do "$baddxfn" if -e "$baddxfn"; - print "$@\n" if $@; } # @@ -332,8 +330,14 @@ sub normal } # if this is a 'nodx' node then ignore it - if (grep $field[7] =~ /^$_/, @DXProt::nodx_node) { - dbg('chan', "PCPROT: Bad DXNode, dropped"); + if ($badnode->in($field[7])) { + dbg('chan', "PCPROT: Bad Node, dropped"); + return; + } + + # if this is a 'bad spotter' user then ignore it + if ($badspotter->in($field[7])) { + dbg('chan', "PCPROT: Bad Spotter, dropped"); return; } @@ -346,7 +350,7 @@ sub normal } # is it 'baddx' - if (grep $field[2] eq $_, @baddx) { + if ($baddx->in($field[2])) { dbg('chan', "PCPROT: Bad DX spot, ignored"); return; } diff --git a/perl/Messages b/perl/Messages index 59f96279..2a42e71e 100644 --- a/perl/Messages +++ b/perl/Messages @@ -89,6 +89,11 @@ package DXM; filter6 => '$_[0]$_[1] Filter for $[2] not found', grids => 'DX Grid flag set on $_[0]', gridu => 'DX Grid flag unset on $_[0]', + hasha => '$_[0] already exists in $_[1]', + hashb => '$_[0] added to $_[1]', + hashc => '$_[0] removed from $_[1]', + hashd => '$_[0] not in $_[1]', + hashe => '$_[0] set on $_[1]', helpe1 => 'Help system unavailable, tell sysop', helpe2 => 'No help available on $_[0]', heres => 'Here set on $_[0]', -- 2.43.0