- # local processing 1
- my $pcr;
- eval {
- $pcr = Local::pcprot($self, $pcno, @field);
- };
-# dbg("Local::pcprot error $@") if isdbg('local') if $@;
- return if $pcr;
-
- SWITCH: {
- if ($pcno == 10) { # incoming talk
-
- # rsfp check
- return if $rspfcheck and !$self->rspfcheck(0, $field[6], $field[1]);
-
- # will we allow it at all?
- if ($censorpc) {
- my @bad;
- if (@bad = BadWords::check($field[3])) {
- dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
- return;
- }
- }
-
- # is it for me or one of mine?
- my ($from, $to, $via, $call, $dxchan);
- $from = $field[1];
- if ($field[5] gt ' ') {
- $via = $field[2];
- $to = $field[5];
- } else {
- $to = $field[2];
- }
-
- # if this is a 'nodx' node then ignore it
- if ($badnode->in($field[6]) || ($via && $badnode->in($via))) {
- dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr');
- return;
- }
-
- # if this is a 'bad spotter' user then ignore it
- my $nossid = $from;
- $nossid =~ s/-\d+$//;
- if ($badspotter->in($nossid)) {
- dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
- return;
- }
-
- # if we are converting announces to talk is it a dup?
- if ($ann_to_talk) {
- if (AnnTalk::is_talk_candidate($from, $field[3]) && AnnTalk::dup($from, $to, $field[3])) {
- dbg("DXPROT: Dupe talk from announce, dropped") if isdbg('chanerr');
- return;
- }
- }
-
- # it is here and logged on
- $dxchan = DXChannel->get($main::myalias) if $to eq $main::mycall;
- $dxchan = DXChannel->get($to) unless $dxchan;
- if ($dxchan && $dxchan->is_user) {
- $field[3] =~ s/\%5E/^/g;
- $dxchan->talk($from, $to, $via, $field[3]);
- return;
- }
-
- # is it elsewhere, visible on the cluster via the to address?
- # note: this discards the via unless the to address is on
- # the via address
- my ($ref, $vref);
- if ($ref = Route::get($to)) {
- $vref = Route::Node::get($via) if $via;
- $vref = undef unless $vref && grep $to eq $_, $vref->users;
- $ref->dxchan->talk($from, $to, $vref ? $via : undef, $field[3], $field[6]);
- return;
- }
-
- # not visible here, send a message of condolence
- $vref = undef;
- $ref = Route::get($from);
- $vref = $ref = Route::Node::get($field[6]) unless $ref;
- if ($ref) {
- $dxchan = $ref->dxchan;
- $dxchan->talk($main::mycall, $from, $vref ? $vref->call : undef, $dxchan->msg('talknh', $to) );
- }
- return;
- }
-
- if ($pcno == 11 || $pcno == 26) { # dx spot
-
- # route 'foreign' pc26s
- if ($pcno == 26) {
- if ($field[7] ne $main::mycall) {
- $self->route($field[7], $line);
- return;
- }
- }
-
- # rsfp check
-# return if $rspfcheck and !$self->rspfcheck(1, $field[7], $field[6]);
-
- # if this is a 'nodx' node then ignore it
- if ($badnode->in($field[7])) {
- dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr');
- return;
- }
-
- # if this is a 'bad spotter' user then ignore it
- my $nossid = $field[6];
- $nossid =~ s/-\d+$//;
- if ($badspotter->in($nossid)) {
- dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
- return;
- }
-
- # convert the date to a unix date
- my $d = cltounix($field[3], $field[4]);
- # bang out (and don't pass on) if date is invalid or the spot is too old (or too young)
- if (!$d || ($pcno == 11 && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) {
- dbg("PCPROT: Spot ignored, invalid date or out of range ($field[3] $field[4])\n") if isdbg('chanerr');
- return;
- }
-
- # is it 'baddx'
- if ($baddx->in($field[2]) || BadWords::check($field[2]) || $field[2] =~ /COCK/) {
- dbg("PCPROT: Bad DX spot, ignored") if isdbg('chanerr');
- return;
- }
-
- # do some de-duping
- $field[5] =~ s/^\s+//; # take any leading blanks off
- $field[2] = unpad($field[2]); # take off leading and trailing blanks from spotted callsign
- if ($field[2] =~ /BUST\w*$/) {
- dbg("PCPROT: useless 'BUSTED' spot") if isdbg('chanerr');
- return;
- }
- if ($censorpc) {
- my @bad;
- if (@bad = BadWords::check($field[5])) {
- dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
- return;
- }
- }
-
-
- my @spot = Spot::prepare($field[1], $field[2], $d, $field[5], $field[6], $field[7]);
- # global spot filtering on INPUT
- if ($self->{inspotsfilter}) {
- my ($filter, $hops) = $self->{inspotsfilter}->it(@spot);
- unless ($filter) {
- dbg("PCPROT: Rejected by input spot filter") if isdbg('chanerr');
- return;
- }
- }
-
- # this goes after the input filtering, but before the add
- # so that if it is input filtered, it isn't added to the dup
- # list. This allows it to come in from a "legitimate" source
- if (Spot::dup($field[1], $field[2], $d, $field[5])) {
- dbg("PCPROT: Duplicate Spot ignored\n") if isdbg('chanerr');
- return;
- }
-
- # add it
- Spot::add(@spot);
-
- #
- # @spot at this point contains:-
- # freq, spotted call, time, text, spotter, spotted cc, spotters cc, orig node
- # then spotted itu, spotted cq, spotters itu, spotters cq
- # you should be able to route on any of these
- #
-
- # fix up qra locators of known users
- my $user = DXUser->get_current($spot[4]);
- if ($user) {
- my $qra = $user->qra;
- unless ($qra && is_qra($qra)) {
- my $lat = $user->lat;
- my $long = $user->long;
- if (defined $lat && defined $long) {
- $user->qra(DXBearing::lltoqra($lat, $long));
- $user->put;
- }
- }
-
- # send a remote command to a distant cluster if it is visible and there is no
- # qra locator and we havn't done it for a month.
-
- unless ($user->qra) {
- my $node;
- my $to = $user->homenode;
- my $last = $user->lastoper || 0;
- if ($send_opernam && $to && $to ne $main::mycall && $main::systime > $last + $DXUser::lastoperinterval && ($node = Route::Node::get($to)) ) {
- my $cmd = "forward/opernam $spot[4]";
- # send the rcmd but we aren't interested in the replies...
- my $dxchan = $node->dxchan;
- if ($dxchan && $dxchan->is_clx) {
- route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
- } else {
- route(undef, $to, pc34($main::mycall, $to, $cmd));
- }
- if ($to ne $field[7]) {
- $to = $field[7];
- $node = Route::Node::get($to);
- if ($node) {
- $dxchan = $node->dxchan;
- if ($dxchan && $dxchan->is_clx) {
- route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
- } else {
- route(undef, $to, pc34($main::mycall, $to, $cmd));
- }
- }
- }
- $user->lastoper($main::systime);
- $user->put;
- }
- }
- }
-
- # local processing
- my $r;
- eval {
- $r = Local::spot($self, @spot);
- };
-# dbg("Local::spot1 error $@") if isdbg('local') if $@;
- return if $r;
-
- # DON'T be silly and send on PC26s!
- return if $pcno == 26;
-
- # send out the filtered spots
- send_dx_spot($self, $line, @spot) if @spot;
- return;