X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXProt.pm;h=9c7064d21cdfd3a0d943eb970b3a0bdf87423ab0;hb=211b54d504170a8c9dad2bf25b9ed686d5eeac11;hp=e2c1dae4221ebdc9cceca1ce97c14b09d11637f4;hpb=eef5d189206ebcfaf8e83675803829c72671a320;p=spider.git diff --git a/perl/DXProt.pm b/perl/DXProt.pm index e2c1dae4..9c7064d2 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -29,11 +29,12 @@ use AnnTalk; 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 $last_hour %pings %rcmds - %nodehops @baddx $baddxfn + %nodehops @baddx $baddxfn $censorpc $allowzero $decode_dk0wcy $send_opernam @checklist); $me = undef; # the channel id for this cluster @@ -45,7 +46,7 @@ $last_hour = time; # last time I did an hourly periodic update %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"; @@ -69,7 +70,7 @@ $baddxfn = "$main::data/baddx.pl"; [ qw(c c n n) ], # pc25 [ qw(f m d t m c c bc) ], # pc26 [ qw(d n n n n m c c bc) ], # pc27 - [ qw(c c c c d t p m bp n p bp bc) ], # pc28 + [ qw(c c c m d t p m bp n p bp bc) ], # pc28 [ qw(c c n m) ], # pc29 [ qw(c c n) ], # pc30 [ qw(c c n) ], # pc31 @@ -177,15 +178,6 @@ sub init confess $@ if $@; $me->{sort} = 'S'; # S for spider - # now prime the spot and wwv duplicates file with data -# my @today = Julian::unixtoj(time); -# for (Spot::readfile(@today), Spot::readfile(Julian::sub(@today, 1))) { -# Spot::dup(@{$_}[0..3]); -# } -# for (Geomag::readfile(time)) { -# Geomag::dup(@{$_}[1..5]); -# } - # load the baddx file do "$baddxfn" if -e "$baddxfn"; print "$@\n" if $@; @@ -219,11 +211,18 @@ sub start $self->{consort} = $line; # save the connection type $self->{here} = 1; + # get the output filters + $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'node_default', 0); + $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'node_default', 0); + $self->{wcyfilter} = Filter::read_in('wcy', $call, 0) || Filter::read_in('wcy', 'node_default', 0); + $self->{annfilter} = Filter::read_in('ann', $call, 0) || Filter::read_in('ann', 'node_default', 0) ; + + # get the INPUT filters (these only pertain to Clusters) - $self->{inspotfilter} = Filter::read_in('spots', $call, 1); - $self->{inwwvfilter} = Filter::read_in('wwv', $call, 1); - $self->{inwcyfilter} = Filter::read_in('wcy', $call, 1); - $self->{inannfilter} = Filter::read_in('ann', $call, 1); + $self->{inspotsfilter} = Filter::read_in('spots', $call, 1) || Filter::read_in('spots', 'node_default', 1); + $self->{inwwvfilter} = Filter::read_in('wwv', $call, 1) || Filter::read_in('wwv', 'node_default', 1); + $self->{inwcyfilter} = Filter::read_in('wcy', $call, 1) || Filter::read_in('wcy', 'node_default', 1); + $self->{inannfilter} = Filter::read_in('ann', $call, 1) || Filter::read_in('ann', 'node_default', 1); # set unbuffered and no echo $self->send_now('B',"0"); @@ -294,20 +293,27 @@ sub normal SWITCH: { if ($pcno == 10) { # incoming talk - + + # will we allow it at all? + if ($censorpc) { + 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 @@ -351,6 +357,13 @@ sub normal dbg('chan', "Duplicate Spot ignored\n"); return; } + if ($censorpc) { + 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]); @@ -427,12 +440,34 @@ sub normal dbg('chan', "Duplicate Announce ignored"); return; } + + if ($censorpc) { + 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 if ($self->{inannfilter}) { - my ($filter, $hops) = Filter::it($self->{inannfilter}, @field[1..6], $self->{call} ); + my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0); + my @dxcc = Prefix::extract($field[1]); + if (@dxcc > 0) { + $ann_dxcc = $dxcc[1]->dxcc; + $ann_itu = $dxcc[1]->itu; + $ann_cq = $dxcc[1]->cq(); + } + @dxcc = Prefix::extract($field[5]); + if (@dxcc > 0) { + $org_dxcc = $dxcc[1]->dxcc; + $org_itu = $dxcc[1]->itu; + $org_cq = $dxcc[1]->cq(); + } + my ($filter, $hops) = $self->{inannfilter}->it(@field[1..6], $self->{call}, + $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq); unless ($filter) { dbg('chan', "Rejected by filter"); return; @@ -1103,8 +1138,8 @@ sub send_dx_spot my $routeit; my ($filter, $hops); - if ($dxchan->{spotfilter}) { - ($filter, $hops) = Filter::it($dxchan->{spotfilter}, @_, $self->{call} ); + if ($dxchan->{spotsfilter}) { + ($filter, $hops) = $dxchan->{spotsfilter}->it(@_, $self->{call} ); next unless $filter; } @@ -1125,6 +1160,7 @@ sub send_dx_spot } 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 { @@ -1148,7 +1184,7 @@ sub send_wwv_spot my ($filter, $hops); if ($dxchan->{wwvfilter}) { - ($filter, $hops) = Filter::it($dxchan->{wwvfilter}, @_, $self->{call} ); + ($filter, $hops) = $dxchan->{wwvfilter}->it(@_, $self->{call} ); next unless $filter; } if ($dxchan->is_node) { @@ -1192,7 +1228,7 @@ sub send_wcy_spot my ($filter, $hops); if ($dxchan->{wcyfilter}) { - ($filter, $hops) = Filter::it($dxchan->{wcyfilter}, @_, $self->{call} ); + ($filter, $hops) = $dxchan->{wcyfilter}->it(@_, $self->{call} ); next unless $filter; } if ($dxchan->is_clx || $dxchan->is_spider) { @@ -1254,7 +1290,20 @@ sub send_announce my ($filter, $hops); if ($dxchan->{annfilter}) { - ($filter, $hops) = Filter::it($dxchan->{annfilter}, @_, $self->{call} ); + my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0); + my @dxcc = Prefix::extract($_[1]); + if (@dxcc > 0) { + $ann_dxcc = $dxcc[1]->dxcc; + $ann_itu = $dxcc[1]->itu; + $ann_cq = $dxcc[1]->cq; + } + @dxcc = Prefix::extract($_[5]); + if (@dxcc > 0) { + $org_dxcc = $dxcc[1]->dxcc; + $org_itu = $dxcc[1]->itu; + $org_cq = $dxcc[1]->cq; + } + ($filter, $hops) = $dxchan->{annfilter}->it(@_, $self->{call}, $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq); next unless $filter; } if ($dxchan->is_node && $_[1] ne $main::mycall) { # i.e not specifically routed to me @@ -1278,6 +1327,7 @@ sub send_announce } 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); @@ -1337,19 +1387,22 @@ sub send_local_config sub route { my ($self, $call, $line) = @_; - my $cl = DXCluster->get_exact($call); - if ($cl) { # don't route it back down itself - if (ref $self && $call eq $self->{call}) { - dbg('chan', "Trying to route back to source, dropped"); - return; - } - my $hops; - my $dxchan = $cl->{dxchan}; - if ($dxchan) { - my $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name - if ($routeit) { - $dxchan->send($routeit) if $dxchan; - } + + if (ref $self && $call eq $self->{call}) { + dbg('chan', "Trying to route back to source, dropped"); + return; + } + + # always send it down the local interface if available + my $dxchan = DXChannel->get($call); + unless ($dxchan) { + my $cl = DXCluster->get_exact($call); + $dxchan = $cl->dxchan if $cl; + } + if ($dxchan) { + my $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name + if ($routeit) { + $dxchan->send($routeit); } } } @@ -1420,7 +1473,7 @@ sub broadcast_list if ($sort eq 'dx') { next unless $dxchan->{dx}; - ($filter) = Filter::it($dxchan->{spotfilter}, @{$fref}) if ref $fref; + ($filter) = $dxchan->{spotsfilter}->it(@{$fref}) if ref $fref; next unless $filter; } next if $sort eq 'ann' && !$dxchan->{ann};