do more development work on XML Interface, get pings basically working.
+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.
# 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, ());
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));
+++ /dev/null
-#
-# 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);
+++ /dev/null
-#
-# 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);
+++ /dev/null
-#
-# 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);
+++ /dev/null
-#
-# 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);
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) = @_;
use QSL;
use DB_File;
use VE7CC;
+use DXXml;
use strict;
use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug
use AnnTalk;
use Geomag;
use WCY;
-use Time::HiRes qw(gettimeofday tv_interval);
use BadWords;
use DXHash;
use Route;
$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
if ($flag == 1) {
$self->send(pc51($from, $to, '0'));
} else {
- $self->handle_ping_reply($from);
+ DXXml::Ping::handle_ping_reply($self, $from);
}
} else {
}
}
-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
{
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}};
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) = @_;
{
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
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
{
}
+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;
use DXDebug;
use DXUtil;
-use vars qw($VERSION $BRANCH);
-main::mkver($VERSION = q$Revision$);
+use vars qw($VERSION $BRANCH);
+$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;
use vars qw (%list %valid $pingint $maxpingwait);
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');
# 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();