+02Sep00=======================================================================
+1. fix a long standing talk bug to do with routing to specific nodes (t xxx >
+yyy .....)
+2. Add badwords checking in various places. You put a list of words into
+/spider/data/badwords one or several per line. Lines starting with # are
+ignored. PC10, PC11, PC12 with words contained in this file will not be
+sent on. Also ann, talk and dx commands have badword checking added. Words
+are NOT case sensitive, but you will need to put all the endings in (eg
+...k, ...ker, ...king).
+01Sep00=======================================================================
+1. allow blank on field 4 of PC10 (even though it's "illegal").
28Aug00=======================================================================
1. changes DXChannel::get_all_ak1a to get_all_nodes.
2. ignore PC21s coming in on the interface with that callsign (ie nodes
# change ^ into : for transmission
$line =~ s/\^/:/og;
+my @bad;
+if (@bad = BadWords::check($line)) {
+ return (1, $self->msg('e17', @bad));
+}
+
return (1, $self->msg('dup')) if AnnTalk::dup($from, $to, $line);
Log('ann', $to, $from, $line);
DXProt::broadcast_list("To $to de $from <$t>: $line", 'ann', undef, @locals);
if ($to ne "LOCAL") {
- $line =~ s/\^//og; # remove ^ characters!
my $pc = DXProt::pc12($from, $line, $tonode, $sysopflag, 0);
DXProt::broadcast_ak1a($pc);
}
return (1, @out) unless $valid;
-# change ^ into : for transmission
-$line =~ s/\^/:/og;
+my @bad;
+if (@bad = BadWords::check($line)) {
+ return (1, $self->msg('e17', @bad));
+}
# Store it here (but only if it isn't baddx)
if (grep $_ eq $spotted, @DXProt::baddx) {
--- /dev/null
+# reload the badwords file
+my $self = shift;
+my @out;
+return (1, $self->msg('e5')) if $self->priv < 9;
+push @out, (BadWords::load());
+@out = ($self->msg('ok')) unless @out;
+return (1, @out);
# if there is a line send it, otherwise add this call to the talk list
# and set talk mode for command mode
if ($line) {
+ my @bad;
+ if (@bad = BadWords::check($line)) {
+ return (1, $self->msg('e17', @bad));
+ }
$dxchan->talk($self->call, $to, $via, $line) if $dxchan;
} else {
my $s = $to;
use DXUtil;
use DXDebug;
use DXDupe;
+use DXVars;
use vars qw(%dup $duplth $dupage);
$duplth = 60; # the length of text to use in the deduping
$dupage = 5*24*3600; # the length of time to hold spot dups
+
# enter the spot for dup checking and return true if it is already a dup
sub dup
{
--- /dev/null
+#
+# Search for bad words in strings
+#
+# Copyright (c) 2000 Dirk Koopman
+#
+# $Id$
+#
+
+package BadWords;
+
+use strict;
+
+use DXUtil;
+use DXVars;
+use IO::File;
+
+use vars qw(%badwords $fn);
+
+$fn = "$main::data/badwords";
+%badwords = ();
+
+# load the badwords file
+sub load
+{
+ my @out;
+ return unless -e $fn;
+ my $fh = new IO::File $fn;
+
+ if ($fh) {
+ %badwords = ();
+ while (<$fh>) {
+ chomp;
+ next if /^\s*\#/;
+ my @list = split " ";
+ for (@list) {
+ $badwords{lc $_}++;
+ }
+ }
+ $fh->close;
+ } else {
+ my $l = "can't open $fn $!";
+ dbg('err', $l);
+ push @out, $l;
+ }
+ return @out;
+}
+
+# check the text against the badwords list
+sub check
+{
+ return grep { $badwords{$_} } split(/\b/, lc shift);
+}
+
+1;
use Geomag;
use WCY;
use Time::HiRes qw(gettimeofday tv_interval);
+use BadWords;
use strict;
use vars qw($me $pc11_max_age $pc23_max_age
SWITCH: {
if ($pcno == 10) { # incoming talk
-
+
+ # will we allow it at all?
+ my @bad;
+ if (@bad = BadWords::check($field[3])) {
+ dbg('chan', "Bad words: @bad, dropped" );
+ return;
+ }
+
# is it for me or one of mine?
my ($to, $via, $call, $dxchan);
if ($field[5] gt ' ') {
$call = $via = $field[2];
$to = $field[5];
- unless (is_callsign($to)) {
- dbg('chan', "Corrupt talk, rejected");
- return;
- }
} else {
$call = $to = $field[2];
}
- if ($dxchan = DXChannel->get($call)) {
+ $dxchan = DXChannel->get($call);
+ if ($dxchan && $dxchan->is_user) {
+ $field[3] =~ s/\%5E/^/g;
$dxchan->talk($field[1], $to, $via, $field[3]);
} else {
$self->route($field[2], $line); # relay it on its way
dbg('chan', "Duplicate Spot ignored\n");
return;
}
+ my @bad;
+ if (@bad = BadWords::check($field[5])) {
+ dbg('chan', "Bad words: @bad, dropped" );
+ return;
+ }
my @spot = Spot::add($field[1], $field[2], $d, $field[5], $field[6], $field[7]);
dbg('chan', "Duplicate Announce ignored");
return;
}
-
+
+ my @bad;
+ if (@bad = BadWords::check($field[3])) {
+ dbg('chan', "Bad words: @bad, dropped" );
+ return;
+ }
if ($field[2] eq '*' || $field[2] eq $main::mycall) {
# global ann filtering on INPUT
} elsif ($dxchan->is_user && $dxchan->{dx}) {
my $buf = Spot::formatb($dxchan->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]);
$buf .= "\a\a" if $dxchan->{beep};
+ $buf =~ s/\%5E/^/g;
if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
$dxchan->send($buf);
} else {
}
next if $target eq 'SYSOP' && $dxchan->{priv} < 5;
my $buf = "$to$target de $_[0]: $text";
+ $buf =~ s/\%5E/^/g;
$buf .= "\a\a" if $dxchan->{beep};
if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
$dxchan->send($buf);
}
$text = unpad($text);
$text = ' ' unless $text && length $text > 0;
+ $text =~ s/\^/%5E/g;
return "PC10^$from^$user1^$text^*^$user2^$main::mycall^~";
}
my $hops = get_hops(11);
my $t = time;
$text = ' ' if !$text;
+ $text =~ s/\^/%5E/g;
return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
}
$text = ' ' if !$text;
$wx = '0' if !$wx;
$tonode = '*' if !$tonode;
+ $text =~ s/\^/%5E/g;
return "PC12^$call^$tonode^$text^$sysop^$main::mycall^$wx^$hops^~";
}
e14 => 'First argument must be numeric and > 0',
e15 => 'invalid qualifier \"$_[0]\"',
e16 => 'File \"$_[0]\" exists',
+ e17 => 'Please don\'t use the words: @_ on here',
echoon => 'Echoing enabled',
echooff => 'Echoing disabled',
use AnnTalk;
use WCY;
use DXDupe;
+use BadWords;
use Data::Dumper;
use Fcntl ':flock';
dbg('err', "starting listener ...");
Msg->new_server("$clusteraddr", $clusterport, \&login);
+# load bad words
+dbg('err', "load badwords: " . (BadWords::load or "Ok"));
+
# prime some signals
$SIG{INT} = \&cease;
$SIG{TERM} = \&cease;