fix badspotters and local ann/full.
authorminima <minima>
Wed, 11 Jan 2006 20:21:50 +0000 (20:21 +0000)
committerminima <minima>
Wed, 11 Jan 2006 20:21:50 +0000 (20:21 +0000)
do more development work on XML Interface, get pings basically working.

14 files changed:
Changes
cmd/announce.pl
cmd/ping.pl
cmd/set/newprotocol.pl [deleted file]
cmd/set/wantpc90.pl [deleted file]
cmd/unset/newprotocol.pl [deleted file]
cmd/unset/wantpc90.pl [deleted file]
perl/DXChannel.pm
perl/DXCommandmode.pm
perl/DXProt.pm
perl/DXXml.pm
perl/DXXml/Ping.pm
perl/Investigate.pm
perl/cluster.pl

diff --git a/Changes b/Changes
index fdc6451020fecdb462964d6a9f010d0560f6b412..b94c786d703be1e13509460d6b7a210d6cdd1df1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+11Jan06=======================================================================
+1. Fixed problem with badspotters doing ann/full as pointed out by Luigi 
+IK5ZUK.
 07Jan06=======================================================================
 1. Fixed problem with the standalone 'showdx' program pointed out by Leo,
 IZ5FSA.
index 9a1cbd376b2dcc13700351e14774867b939878e7..e80562225bfa8ad3cbceecd95de0c4881a4903a4 100644 (file)
@@ -48,10 +48,24 @@ if ($sort eq "FULL") {
 # change ^ into : for transmission
 $line =~ s/\^/:/og;
 
+# if this is a 'bad spotter' user then ignore it
+my $nossid = $from;
+my $drop = 0;
+$nossid =~ s/-\d+$//;
+if ($DXProt::badspotter->in($nossid)) {
+       LogDbg('DXCommand', "bad spotter ($from) announcement: $line");
+       $drop++;
+}
+
+# have they sworn?
 my @bad;
 if (@bad = BadWords::check($line)) {
        $self->badcount(($self->badcount||0) + @bad);
        LogDbg('DXCommand', "$self->{call} swore: $line (with words:" . join(',', @bad) . ")");
+       $drop++;
+}
+
+if ($drop) {
        Log('ann', $to, $from, "[to $from only] $line");
        $self->send("To $to de $from <$t>: $line");
        return (1, ());
index aab2a3e6b2b94076f9b4ff0810465184ea49dd2f..f577bff1a54477a373cf110d944ebf91fa34e07b 100644 (file)
@@ -26,7 +26,7 @@ $noderef = RouteDB::get($call) unless $noderef;
 return (1, $self->msg('e7', $call)) unless $noderef;
 
 # ping it
-DXProt::addping($self->call, $call);
+DXXml::Ping::add($self, $call);
 
 return (1, $self->msg('pingo', $call));
 
diff --git a/cmd/set/newprotocol.pl b/cmd/set/newprotocol.pl
deleted file mode 100644 (file)
index ae2054a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# set the new protocol flag
-#
-# Copyright (c) 1998 - Dirk Koopman
-#
-# $Id$
-#
-
-my ($self, $line) = @_;
-my @args = split /\s+/, $line;
-my $call;
-my @out;
-
-@args = $self->call if (!@args || $self->priv < 9);
-
-foreach $call (@args) {
-       $call = uc $call;
-       my $user = DXUser->get_current($call);
-       if ($user) {
-               $user->wantnp(1);
-               $user->put;
-               push @out, $self->msg('set', 'New Protocol', $call);
-       } else {
-               push @out, $self->msg('e3', "Set New Protocol", $call);
-       }
-}
-return (1, @out);
diff --git a/cmd/set/wantpc90.pl b/cmd/set/wantpc90.pl
deleted file mode 100644 (file)
index 81cd2e1..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# set the want PC90 flag
-#
-# Copyright (c) 2002 - Dirk Koopman
-#
-# $Id$
-#
-
-my ($self, $line) = @_;
-my @args = split /\s+/, uc $line;
-my $call;
-my @out;
-
-return (1, $self->msg('e5')) if $self->priv < 9;
-
-foreach $call (@args) {
-       return (1, $self->msg('e12')) unless is_callsign($call);
-
-       my $user = DXUser->get_current($call);
-       if ($user) {
-               $user->wantpc90(1);
-               $user->put;
-               push @out, $self->msg('wpc90s', $call);
-       } else {
-               push @out, $self->msg('e3', "set/wantpc90", $call);
-       }
-}
-return (1, @out);
diff --git a/cmd/unset/newprotocol.pl b/cmd/unset/newprotocol.pl
deleted file mode 100644 (file)
index e14c2df..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# unset the new protocol flag
-#
-# Copyright (c) 1998 - Dirk Koopman
-#
-# $Id$
-#
-
-my ($self, $line) = @_;
-my @args = split /\s+/, $line;
-my $call;
-my @out;
-
-@args = $self->call if (!@args || $self->priv < 9);
-
-foreach $call (@args) {
-       $call = uc $call;
-       my $user = DXUser->get_current($call);
-       if ($user) {
-               $user->wantnp(0);
-               $user->put;
-               push @out, $self->msg('unset', 'New Protocol', $call);
-       } else {
-               push @out, $self->msg('e3', "Unset New Protocol", $call);
-       }
-}
-return (1, @out);
diff --git a/cmd/unset/wantpc90.pl b/cmd/unset/wantpc90.pl
deleted file mode 100644 (file)
index a4684c1..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# unset the want PC90 flag
-#
-# Copyright (c) 2002 - Dirk Koopman
-#
-# $Id$
-#
-
-my ($self, $line) = @_;
-my @args = split /\s+/, uc $line;
-my $call;
-my @out;
-
-return (1, $self->msg('e5')) if $self->priv < 9;
-
-foreach $call (@args) {
-       return (1, $self->msg('e12')) unless is_callsign($call);
-
-       my $user = DXUser->get_current($call);
-       if ($user) {
-               $user->wantpc90(0);
-               $user->put;
-               push @out, $self->msg('wpc90u', $call);
-       } else {
-               push @out, $self->msg('e3', "unset/wantpc90", $call);
-       }
-}
-return (1, @out);
index 6da3ecbe36d0be30a00ee2a47ce64bdac9f1e411..adf7c358ddfec793cf90cedf136da8e799355e0e 100644 (file)
@@ -178,6 +178,14 @@ sub alloc
        return $channels{$call} = $self;
 }
 
+# rebless this channel as something else
+sub rebless
+{
+       my $self = shift;
+       my $class = shift;
+       return $channels{$self->{call}} = bless $self, $class;
+}
+
 sub rec        
 {
        my ($self, $msg) = @_;
index 404a7391af2c6bc59d76b28936cc0cc0b2d98720..ecd65716f71da86fac4f27df28b7af0d7f3ae5b6 100644 (file)
@@ -35,6 +35,7 @@ use Net::Telnet;
 use QSL;
 use DB_File;
 use VE7CC;
+use DXXml;
 
 use strict;
 use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug
index d51b9f1a7e256193985b0919f4523aec28d50957..4a43ef086d1b381800960dd47158ce3fe5482a98 100644 (file)
@@ -27,7 +27,6 @@ use DXDb;
 use AnnTalk;
 use Geomag;
 use WCY;
-use Time::HiRes qw(gettimeofday tv_interval);
 use BadWords;
 use DXHash;
 use Route;
@@ -57,7 +56,6 @@ $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
 
 $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
 %pc19list = ();                                        # list of outstanding PC19s that haven't had PC16s on them
@@ -1550,7 +1548,7 @@ sub handle_51
                if ($flag == 1) {
                        $self->send(pc51($from, $to, '0'));
                } else {
-                       $self->handle_ping_reply($from);
+                       DXXml::Ping::handle_ping_reply($self, $from);
                }
        } else {
 
@@ -1565,56 +1563,6 @@ sub handle_51
        }
 }
 
-sub handle_ping_reply
-{
-       my $self = shift;
-       my $from = shift;
-       my $id = shift;
-       
-       # it's a reply, look in the ping list for this one
-       my $ref = $pings{$from};
-       return unless $ref;
-
-       my $tochan =  DXChannel::get($from);
-       while (@$ref) {
-               my $r = shift @$ref;
-               my $dxchan = DXChannel::get($r->{call});
-               next unless $dxchan;
-               my $t = tv_interval($r->{t}, [ gettimeofday ]);
-               if ($dxchan->is_user) {
-                       my $s = sprintf "%.2f", $t; 
-                       my $ave = sprintf "%.2f", $tochan ? ($tochan->{pingave} || $t) : $t;
-                       $dxchan->send($dxchan->msg('pingi', $from, $s, $ave))
-               } elsif ($dxchan->is_node) {
-                       if ($tochan) {
-                               my $nopings = $tochan->user->nopings || $obscount;
-                               push @{$tochan->{pingtime}}, $t;
-                               shift @{$tochan->{pingtime}} if @{$tochan->{pingtime}} > 6;
-                               
-                               # cope with a missed ping, this means you must set the pingint large enough
-                               if ($t > $tochan->{pingint}  && $t < 2 * $tochan->{pingint} ) {
-                                       $t -= $tochan->{pingint};
-                               }
-                               
-                               # calc smoothed RTT a la TCP
-                               if (@{$tochan->{pingtime}} == 1) {
-                                       $tochan->{pingave} = $t;
-                               } else {
-                                       $tochan->{pingave} = $tochan->{pingave} + (($t - $tochan->{pingave}) / 6);
-                               }
-                               $tochan->{nopings} = $nopings; # pump up the timer
-                               if (my $ivp = Investigate::get($from, $self->{call})) {
-                                       $ivp->handle_ping;
-                               }
-                       } elsif (my $rref = Route::Node::get($r->{call})) {
-                               if (my $ivp = Investigate::get($from, $self->{call})) {
-                                       $ivp->handle_ping;
-                               }
-                       }
-               }
-       }
-}
-
 # dunno but route it
 sub handle_75
 {
@@ -1737,7 +1685,7 @@ sub process
                        if ($dxchan->{nopings} <= 0) {
                                $dxchan->disconnect;
                        } else {
-                               addping($main::mycall, $dxchan->call);
+                               DXXml::Ping::add($main::me, $dxchan->call);
                                $dxchan->{nopings} -= 1;
                                $dxchan->{lastping} = $t;
                                $dxchan->{lastping} += $dxchan->{pingint} / 2 unless @{$dxchan->{pingtime}};
@@ -2195,29 +2143,6 @@ sub load_hops
        return ();
 }
 
-
-# add a ping request to the ping queues
-sub addping
-{
-       my ($from, $to, $via) = @_;
-       my $ref = $pings{$to} || [];
-       my $r = {};
-       $r->{call} = $from;
-       $r->{t} = [ gettimeofday ];
-       if ($via && (my $dxchan = DXChannel::get($via))) {
-               $dxchan->send(pc51($to, $main::mycall, 1));
-       } else {
-               route(undef, $to, pc51($to, $main::mycall, 1));
-       }
-       push @$ref, $r;
-       $pings{$to} = $ref;
-       my $u = DXUser->get_current($to);
-       if ($u) {
-               $u->lastping(($via || $from), $main::systime);
-               $u->put;
-       }
-}
-
 sub process_rcmd
 {
        my ($self, $tonode, $fromnode, $user, $cmd) = @_;
index e3c5f270276db1f041d4164e811009fce0633bbf..1bea12c784d38d9bda02e6cbfe1074aebb1a0312 100644 (file)
@@ -117,13 +117,75 @@ sub toxml
 {
        my $self = shift;
 
-       $self->{o} ||= $main::mycall;
-       $self->{t} ||= IsoTime::dayms();
-       $self->{id} ||= nextid();
+       unless (exists $self->{'-xml'}) {
+               $self->{o} ||= $main::mycall;
+               $self->{t} ||= IsoTime::dayms();
+               $self->{id} ||= nextid();
+               
+               my ($name) = ref $self =~ /::(\w+)$/;
+               $self->{'-xml'} = $xs->XMLout($self, RootName =>lc $name, NumericEscape=>1);
+       }
+       return $self->{'-xml'};
+}
+
+sub route
+{
+       my $self = shift;
+       my $fromdxchan = shift;
+       my $to = shift;
+       my $via = $to || $self->{'-via'} || $self->{to};
+
+       unless ($via) {
+               dbg("XML: no route specified (" . $self->toxml . ")") if isdbg('chanerr');
+               return;
+       }
+       if (ref $fromdxchan && $via && $fromdxchan->call eq $via) {
+               dbg("XML: Trying to route back to source (" . $self->toxml . ")") if isdbg('chanerr');
+               return;
+       }
+
+       # always send it down the local interface if available
+       my $dxchan = DXChannel::get($via);
+       if ($dxchan) {
+               dbg("route: $via -> $dxchan->{call} direct" ) if isdbg('route');
+       } else {
+               my $cl = Route::get($via);
+               $dxchan = $cl->dxchan if $cl;
+               dbg("route: $via -> $dxchan->{call} using normal route" ) if isdbg('route');
+       }
 
-       my ($name) = ref $self =~ /::(\w+)$/;
-       my $s = $xs->XMLout($self, RootName =>lc $name, NumericEscape=>1);
-       return $self->{'-xml'} = $s;
+       # try the backstop method
+       unless ($dxchan) {
+               my $rcall = RouteDB::get($via);
+               if ($rcall) {
+                       $dxchan = DXChannel::get($rcall);
+                       dbg("route: $via -> $rcall using RouteDB" ) if isdbg('route') && $dxchan;
+               }
+       }
+       
+       unless ($dxchan) {
+               dbg("XML: no route available to $via") if isdbg('chanerr');
+               return;
+       }
+
+       if ($fromdxchan->call eq $via) {
+               dbg("XML: Trying to route back to source (" . $self->toxml . ")") if isdbg('chanerr');
+               return;
+       }
+
+       if ($dxchan == $main::me) {
+               dbg("XML: Trying to route to me (" . $self->toxml . ")") if isdbg('chanerr');
+               return;
+       }
+
+       if ($dxchan->handle_xml) {
+               $dxchan->send($self->toxml);
+       } else {
+               $self->{o} ||= $main::mycall;
+               $self->{id} ||= nextid();
+               $self->{'-timet'} ||= $main::systime;
+               $dxchan->send($self->topcxx);
+       }
 }
 
 sub has_xml
index 26dd864e26e3c3429d29ca8241ed42b78021569f..a1b0a6a122ba6e3a8a792ef69d819c4216b9ecb0 100644 (file)
@@ -13,14 +13,17 @@ package DXXml::Ping;
 use DXDebug;
 use DXProt;
 use IsoTime;
+use Investigate;
+use Time::HiRes qw(gettimeofday tv_interval);
 
-use vars qw($VERSION $BRANCH @ISA);
+use vars qw($VERSION $BRANCH @ISA %pings);
 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
 $main::build += $VERSION;
 $main::branch += $BRANCH;
 
 @ISA = qw(DXXml);
+%pings = ();                    # outstanding ping requests outbound
 
 sub handle_input
 {
@@ -29,4 +32,91 @@ sub handle_input
        
 }
 
+sub topcxx
+{
+       my $self = shift;
+       unless (exists $self->{'-pcxx'}) {
+               $self->{'-pcxx'} = DXProt::pc51($self->{to}, $self->{o}, $self->{s});
+       }
+       return $self->{'-pcxx'};
+}
+
+# add a ping request to the ping queues
+sub add
+{
+       my ($dxchan, $to, $via) = @_;
+       my $from = $dxchan->call;
+       my $ref = $pings{$to} || [];
+       my $r = {};
+       my $self = DXXml::Ping->new(to=>$to, '-hirestime'=>[ gettimeofday ], s=>'1');
+       $self->{u} = $from unless $from eq $main::mycall;
+       $self->{'-via'} = $via if $via && DXChannel::get($via);
+       $self->{o} = $main::mycall;
+       $self->{id} = $self->nextid;
+       $self->route($dxchan);
+
+       push @$ref, $self;
+       $pings{$to} = $ref;
+       my $u = DXUser->get_current($to);
+       if ($u) {
+               $u->lastping(($via || $from), $main::systime);
+               $u->put;
+       }
+}
+
+sub handle_ping_reply
+{
+       my $fromdxchan = shift;
+       my $from = shift;
+       my $fromxml;
+       
+       if (ref $from) {
+               $fromxml = $from;
+               $from = $from->{o};
+       }
+
+       # it's a reply, look in the ping list for this one
+       my $ref = $pings{$from};
+       return unless $ref;
+
+       my $tochan = DXChannel::get($from);
+       while (@$ref) {
+               my $r = shift @$ref;
+               my $dxchan = DXChannel::get($r->{to});
+               next unless $dxchan;
+               my $t = tv_interval($r->{'-hirestime'}, [ gettimeofday ]);
+               if ($dxchan->is_user) {
+                       my $s = sprintf "%.2f", $t; 
+                       my $ave = sprintf "%.2f", $tochan ? ($tochan->{pingave} || $t) : $t;
+                       $dxchan->send($dxchan->msg('pingi', $from, $s, $ave))
+               } elsif ($dxchan->is_node) {
+                       if ($tochan) {
+                               my $nopings = $tochan->user->nopings || $DXProt::obscount;
+                               push @{$tochan->{pingtime}}, $t;
+                               shift @{$tochan->{pingtime}} if @{$tochan->{pingtime}} > 6;
+                               
+                               # cope with a missed ping, this means you must set the pingint large enough
+                               if ($t > $tochan->{pingint}  && $t < 2 * $tochan->{pingint} ) {
+                                       $t -= $tochan->{pingint};
+                               }
+                               
+                               # calc smoothed RTT a la TCP
+                               if (@{$tochan->{pingtime}} == 1) {
+                                       $tochan->{pingave} = $t;
+                               } else {
+                                       $tochan->{pingave} = $tochan->{pingave} + (($t - $tochan->{pingave}) / 6);
+                               }
+                               $tochan->{nopings} = $nopings; # pump up the timer
+                               if (my $ivp = Investigate::get($from, $fromdxchan->{call})) {
+                                       $ivp->handle_ping;
+                               }
+                       } elsif (my $rref = Route::Node::get($r->{to})) {
+                               if (my $ivp = Investigate::get($from, $fromdxchan->{to})) {
+                                       $ivp->handle_ping;
+                               }
+                       }
+               }
+       }
+}
+
 1;
index 426e23ebfe11ab5650be7ecd79320da6662161f0..811d6380386f5ede159e0aac4b7c4b3ba0f54f09 100644 (file)
@@ -124,7 +124,7 @@ sub process
                if ($v->{state} eq 'start') {
                        my $via = $via{$v->{via}} || 0;
                        if ($main::systime > $via+$pingint) {
-                               DXProt::addping($main::mycall, $v->{call}, $v->{via});
+                               DXXml::Ping::add($main::me, $v->{call}, $v->{via});
                                $v->{start} = $lastping = $main::systime;
                                dbg("Investigate: ping sent to $v->{call} via $v->{via}") if isdbg('investigate');
                                $v->chgstate('waitping');
index 0ad54f310b4bb7346e22e7194d920947c272fbd0..6ed4c556c3a0588176238b7cf80dea6726c7fde7 100755 (executable)
@@ -510,9 +510,8 @@ for (;;) {
        
        # do timed stuff, ongoing processing happens one a second
        if ($timenow != $systime) {
-               reap if $zombies;
-               $systime = $timenow;
-               IsoTime::update($systime);
+               reap() if $zombies;
+               IsoTime::update($systime = $timenow);
                DXCron::process();      # do cron jobs
                DXCommandmode::process(); # process ongoing command mode stuff
                DXXml::process();