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, $_[3], $_[6]);
+ $ref->bestdxchan->talk($from, $to, $vref ? $via : undef, $_[3], $_[6]);
return;
}
$ref = Route::get($from);
$vref = $ref = Route::Node::get($_[6]) unless $ref;
if ($ref) {
- $dxchan = $ref->dxchan;
+ $dxchan = $ref->bestdxchan;
$dxchan->talk($main::mycall, $from, $vref ? $vref->call : undef, $dxchan->msg('talknh', $to) );
}
}
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;
+ my $dxchan = $node->bestdxchan;
if ($dxchan && $dxchan->is_clx) {
route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
} else {
$to = $_[7];
$node = Route::Node::get($to);
if ($node) {
- $dxchan = $node->dxchan;
+ $dxchan = $node->bestdxchan;
if ($dxchan && $dxchan->is_clx) {
route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
} else {
if ($call) {
my $ref = Route::get($call);
if ($ref) {
- $dxchan = $ref->dxchan;
+ $dxchan = $ref->bestdxchan;
$dxchan->talk($_[1], $call, undef, $_[3], $_[5]) if $dxchan != $self;
return;
}
}
# do we believe this call?
- next unless $ncall eq $self->{call} || $self->is_believed($ncall);
+ unless ($ncall eq $self->{call} || $self->is_believed($ncall)) {
+ dbg("PCPROT: We don't believe $ncall on $self->{call}");
+ return;
+ }
my $node = Route::Node::get($ncall);
unless ($node) {
dbg("PCPROT: $call is a node") if isdbg('chanerr');
next;
}
-
- $r = Route::User::get($call) || Route::User::get($call);
+
+ $r = Route::User::get($call) || Route::User->new($call);
$r->here($here);
$r->conf($conf);
$node->lastseen($main::systime);
}
# do we believe this call?
- next unless $ncall eq $self->{call} || $self->is_believed($ncall);
+ unless ($ncall eq $self->{call} || $self->is_believed($ncall)) {
+ dbg("PCPROT: We don't believe $ncall on $self->{call}");
+ return;
+ }
my $uref = Route::User::get($ucall);
unless ($uref) {
# first clear out any nodes on this dxchannel
my $node = Route::Node::get($self->{call}) ;
- my @rout = grep {$_ != $node } $main::routeroot->remove_route($node, $self) if $node;
- my @rusers;
- push @rusers, $_->unlink_all_users for @rout;
+ my @rout;
+ foreach my $n ($node->nodes) {
+ next if $n eq $main::mycall;
+ next if $n eq $self->{call};
+ my $nref = Route::Node::get($n);
+ push @rout, $node->remove_route($nref, $self) if $nref;
+ }
$self->route_pc21($origin, $line, @rout) if @rout;
- for (@rout, @rusers) {
+ for (@rout) {
$_->delete;
};
next if $call eq $main::mycall;
# do we believe this call?
- next unless $call eq $self->{call} || $self->is_believed($call);
+ unless ($call eq $self->{call} || $self->is_believed($call)) {
+ dbg("PCPROT: We don't believe $call on $self->{call}");
+ next;
+ }
eph_del_regex("^PC(?:21\\^$call|17\\^[^\\^]+\\^$call)");
return if $call eq $main::mycall; # don't allow malicious buggers to disconnect me (or ignore loops)!
+ unless ($call eq $self->{call} || $self->is_believed($call)) {
+ dbg("PCPROT: We don't believe $call on $self->{call}");
+ return;
+ }
+
eph_del_regex("^PC1[679].*$call");
# if I get a PC21 from the same callsign as self then treat it
return unless $self->in_filter_route($fnode);
# now do it properly for actions
- my $node = Route::Node::get($ncall) || Route::Node::new($ncall);
+ my $node = Route::Node::get($ncall) || Route::Node->new($ncall);
$node->newroute(1);
# find each of the entries (or create new ones)
$user->node($ncall);
$user->put;
}
- $ref = Route::User::new($ecall, 0);
+ $ref = Route::User->new($ecall, 0);
}
} elsif ($esort eq 'N') {
$ref = Route::Node::get($ecall);
$user->node($ncall);
$user->put;
}
- $ref = Route::Node::new($ecall, 0);
+ $ref = Route::Node->new($ecall, 0);
}
} else {
dbg("DXPROT: unknown entity type '$esort' on $ecall for node $ncall") if isdbg('chan');
my $dxchan = DXChannel->get($call);
unless ($dxchan) {
my $cl = Route::get($call);
- $dxchan = $cl->dxchan if $cl;
+ $dxchan = $cl->bestdxchan if $cl;
if (ref $dxchan) {
if (ref $self && $dxchan eq $self) {
dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
$rcmds{$to} = $r;
my $ref = Route::Node::get($to);
- my $dxchan = $ref->dxchan;
+ my $dxchan = $ref->bestdxchan;
if ($dxchan && $dxchan->is_clx) {
route(undef, $to, pc84($main::mycall, $to, $self->{call}, $cmd));
} else {
# do routing stuff, remove me from routing table
my $node = Route::Node::get($call);
my @rout;
- my @rusers;
if ($node) {
# remove the route from this node and return a list
# of nodes that have become orphanned as a result.
push @rout, $main::routeroot->remove_route($node, $self);
- # remove all consequently orphanned users from these nodes
- push @rusers, $_->unlink_all_users for @rout;
-
# remove all my ephemera as well
for (@rout) {
my $c = $_->call;
}
# delete all the unwanted nodes
- $_->delete for @rout, @rusers;
+ $_->delete for @rout;
# remove outstanding pings
delete $pings{$call};
cq => '0,CQ Zone',
state => '0,State',
city => '0,City',
- lastseen => 'Last Seen,atime',
+ lastseen => '0,Last Seen,atime',
);
$filterdef = bless ([
# recursion detector
if ((DXChannel->get($self->{call}) && $level > 1) || grep $self->{call} eq $_, @$seen) {
- $line .= ' ...';
- push @out, $line;
+# $line .= ' ...';
+# push @out, $line;
return @out;
}
push @$seen, $self->{call};
return Route::Node::get($call) || Route::User::get($call);
}
+sub get_all
+{
+ return (Route::Node::get_all(), Route::User::get_all());
+}
+
# find all the possible dxchannels which this object might be on
sub alldxchan
{
my $self = shift;
- my @dxchan;
-# dbg("Trying node $self->{call}") if isdbg('routech');
my $dxchan = DXChannel->get($self->{call});
- push @dxchan, $dxchan if $dxchan;
+ if ($dxchan) {
+ dbg("alldxchan for $self->{call} = $dxchan->{call}") if isdbg('routelow');
+ return $dxchan if $dxchan;
+ }
+
+ my @nodes;
+ if ($self->isa('Route::User')) {
+ push @nodes, map{Route::Node::get($_)} @{$self->{nodes}};
+ } elsif ($self->isa('Route::Node')) {
+ push @nodes, $self;
+ }
# it isn't, build up a list of dxchannels and possible ping times
# for all the candidates.
- unless (@dxchan) {
- foreach my $p (@{$self->{dxchan}}) {
+ my @dxchan;
+ foreach my $nref (@nodes) {
+ next unless $nref;
+ foreach my $p (@{$nref->{dxchan}}) {
# dbg("Trying dxchan $p") if isdbg('routech');
next if $p eq $main::mycall; # the root
my $dxchan = DXChannel->get($p);
}
}
}
-# dbg('routech', "Got dxchan: " . join(',', (map{ $_->call } @dxchan)) );
+ dbg("alldxchan for $self->{call} = (" . join(',', @dxchan) . ")") if isdbg('routelow');
return @dxchan;
}
%valid = (
dxchan => '0,DXChannel List,parray',
- nodes => '0,Nodes,parray',
- users => '0,Users,parray',
+ nodes => '0,Node List,parray',
+ users => '0,User List,parray',
usercount => '0,User Count',
version => '0,Version',
newroute => '0,New Routing?,yesno',
foreach my $r (@in) {
next unless $r;
next if $visited{$r->call};
- my ($o) = $r->del_dxchan($self);
+ my ($o) = $r->del_dxchan($dxchan);
if ($o) {
- dbg("Orphanning $_->{call}") if isdbg('routelow');
+ dbg("Orphanning $o->{call}") if isdbg('routelow');
push @rout, $o;
}
push @in, map{ Route::Node::get($_) } $r->nodes;
sub del_dxchan
{
my ($self, $dxchan) = @_;
- return $self->_dellist('dxchan', $dxchan);
+ $self->_dellist('dxchan', $dxchan);
+ return $self->is_empty('dxchan') ? ($self) : ();
}
sub usercount
sub delete
{
my $self = shift;
- dbg("deleting Route::Node $self->{call}") if isdbg('routelow');
+ dbg("Deleting Route::Node $self->{call}") if isdbg('routelow');
+ for ($self->unlink_all_users) {
+ $_->delete;
+ }
delete $list{$self->{call}};
}