clean up various things and add the DXXml.pm module
[spider.git] / perl / DXProt.pm
index 46fda5706fe5bdbadfa8c73058ed8d0c56c1f369..39b023c482705163e1be93f84e256766cbffcfa9 100644 (file)
@@ -50,7 +50,8 @@ use vars qw($pc11_max_age $pc23_max_age $last_pc50 $eph_restime $eph_info_restim
                        $pingint $obscount %pc19list $chatdupeage $chatimportfn
                        $investigation_int $pc19_version $myprot_version
                        %nodehops $baddx $badspotter $badnode $censorpc $rspfcheck
-                       $allowzero $decode_dk0wcy $send_opernam @checklist);
+                       $allowzero $decode_dk0wcy $send_opernam @checklist
+                       $handle_xml);
 
 $pc11_max_age = 1*3600;                        # the maximum age for an incoming 'real-time' pc11
 $pc23_max_age = 1*3600;                        # the maximum age for an incoming 'real-time' pc23
@@ -78,11 +79,12 @@ $chatdupeage = 20 * 60 * 60;
 $chatimportfn = "$main::root/chat_import";
 $investigation_int = 12*60*60; # time between checks to see if we can see this node
 $pc19_version = 5466;                  # the visible version no for outgoing PC19s generated from pc59
+$handle_xml = 0;                               # handle XML sentences
 
 @checklist = 
 (
  [ qw(i c c m bp bc c) ],                      # pc10
- [ qw(i f m d t m c c h) ],            # pc11
+ [ qw(i f bm d t m c c h) ],           # pc11
  [ qw(i c bm m bm bm p h) ],           # pc12
  [ qw(i c h) ],                                        # 
  [ qw(i c h) ],                                        # 
@@ -249,7 +251,10 @@ sub start
        my $user = $self->{user};
 
        # log it
-       my $host = $self->{conn}->{peerhost} || "unknown";
+       my $host = $self->{conn}->{peerhost};
+       $host ||= "AGW Port #$self->{conn}->{agwport}" if exists $self->{conn}->{agwport};
+       $host ||= "unknown";
+
        Log('DXProt', "$call connected from $host");
        
        # remember type of connection
@@ -323,21 +328,6 @@ sub sendinit
        $self->send(pc18());
 }
 
-sub removepc90
-{
-       $_[0] =~ s/^PC90\^[-A-Z0-9]+\^\d+\^//;
-       $_[0] =~ s/^PC91\^[-A-Z0-9]+\^\d+\^[-A-Z0-9]+\^//;
-}
-
-#sub send
-#{
-#      my $self = shift;
-#      while (@_) {
-#              my $line = shift;
-#              $self->SUPER::send($line);
-#      }
-#}
-
 #
 # This is the normal pcxx despatcher
 #
@@ -345,9 +335,6 @@ sub normal
 {
        my ($self, $line) = @_;
 
-       # remove any incoming PC90 frames
-       removepc90($line);
-
        my @field = split /\^/, $line;
        return unless @field;
        
@@ -548,7 +535,7 @@ sub handle_11
        # 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(@spot[0..4])) {
+       if (Spot::dup(@spot[0..4,5])) {
                dbg("PCPROT: Duplicate Spot ignored\n") if isdbg('chanerr');
                return;
        }
@@ -943,6 +930,7 @@ sub handle_18
                        $self->user->put;
                        $self->sort('S');
                }
+               $self->handle_xml++ if $_[1] =~ /\bxml\b/;
        } else {
                $self->version(50.0);
                $self->version($_[2] / 100) if $_[2] && $_[2] =~ /^\d+$/;
@@ -1231,13 +1219,24 @@ sub handle_23
                dbg("PCPROT: WWV Date ($_[1] $_[2]) out of range") if isdbg('chanerr');
                return;
        }
-       if (Geomag::dup($d,$sfi,$k,$i,$_[6])) {
+
+       # global wwv filtering on INPUT
+       my @dxcc = ((Prefix::cty_data($_[7]))[0..2], (Prefix::cty_data($_[8]))[0..2]);
+       if ($self->{inwwvfilter}) {
+               my ($filter, $hops) = $self->{inwwvfilter}->it(@_[7,8], $origin, @dxcc);
+               unless ($filter) {
+                       dbg("PCPROT: Rejected by input wwv filter") if isdbg('chanerr');
+                       return;
+               }
+       }
+       $_[7] =~ s/-\d+$//o;            # remove spotter's ssid
+       if (Geomag::dup($d,$sfi,$k,$i,$_[6],$_[7])) {
                dbg("PCPROT: Dup WWV Spot ignored\n") if isdbg('chanerr');
                return;
        }
-       $_[7] =~ s/-\d+$//o;            # remove spotter's ssid
                
-       my $wwv = Geomag::update($d, $_[2], $sfi, $k, $i, @_[6..8], $r);
+       # note this only takes the first one it gets
+       Geomag::update($d, $_[2], $sfi, $k, $i, @_[6..8], $r);
 
        my $rep;
        eval {
@@ -1836,7 +1835,7 @@ sub wwv
        my ($filter, $hops);
        
        if ($self->{wwvfilter}) {
-               ($filter, $hops) = $self->{wwvfilter}->it(@_);
+               ($filter, $hops) = $self->{wwvfilter}->it(@_[7..$#_]);
                return unless $filter;
        }
        send_prot_line($self, $filter, $hops, $isolate, $line)