X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRoute%2FNode.pm;h=f3072db121cb747b440c838244cc51025606cf3c;hb=8c23f70c2487e906a80ef323763cb7cb123baf28;hp=83f5768c0e6fe8fa5df2fae2eab16cdeffc61f84;hpb=ebbf88f53284e6b7e77c3319047607b1c5cd2518;p=spider.git diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index 83f5768c..f3072db1 100644 --- a/perl/Route/Node.pm +++ b/perl/Route/Node.pm @@ -15,8 +15,8 @@ use Route::User; use strict; 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)); +$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /:\s+(\d+)\.(\d+)/ ); +$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /:\s+\d+\.\d+\.(\d+)\.(\d+)/ || (0,0)); $main::build += $VERSION; $main::branch += $BRANCH; @@ -30,6 +30,7 @@ use vars qw(%list %valid @ISA $max $filterdef); usercount => '0,User Count', version => '0,Version', newroute => '0,New Routing?,yesno', + pingtime => '0,Ping Time', ); $filterdef = $Route::filterdef; @@ -80,6 +81,39 @@ sub unlink_node return $neighbour->is_empty('dxchan') ? ($neighbour) : (); } +sub add_route +{ + my ($self, $neighbour, $dxchan) = @_; + + # add the dxchan link + # add the node link + my @rout; + push @rout, $self->link_node($neighbour, $dxchan); + dbg("Adding $neighbour->{call}") if isdbg('routelow'); + + # then run down the tree removing this dxchan link from + # all the referenced nodes that use this interface + my %visited; + my @in = map { Route::Node::get($_) } $neighbour->nodes; + foreach my $r (@in) { + next unless $r; + next if $visited{$r->call}; + next if $r->{call} eq $main::mycall; + next if $r->{call} eq $self->{call}; + my ($o) = $r->add_dxchan($dxchan); + if ($o) { + dbg("Connecting new node $o->{call}") if isdbg('routelow'); + push @rout, $o; + } + push @in, map{ Route::Node::get($_) } $r->nodes; + $visited{$r->call} = $r; + } + + # @rout should contain any nodes that have now been de-orphaned + # ie have had their first dxchan added. + return @rout; +} + sub remove_route { my ($self, $neighbour, $dxchan) = @_; @@ -97,6 +131,8 @@ sub remove_route foreach my $r (@in) { next unless $r; next if $visited{$r->call}; + next if $r->{call} eq $main::mycall; + next if $r->{call} eq $self->{call}; my ($o) = $r->del_dxchan($dxchan); if ($o) { dbg("Orphanning $o->{call}") if isdbg('routelow'); @@ -206,7 +242,6 @@ sub new $self->{nodes} = []; $list{$call} = $self; - dbg("creating Route::Node $self->{call}") if isdbg('routelow'); return $self; }