added registration
[spider.git] / perl / DXChannel.pm
index 15bd6d2bffccbbcc994a22825d3545771831a0e0..584015518e6ea2b93478b10660d80d7e60ac4da3 100644 (file)
@@ -32,6 +32,7 @@ use DXVars;
 use DXDebug;
 use Filter;
 use Prefix;
+use Route;
 
 use strict;
 use vars qw(%channels %valid @ISA $count);
@@ -74,17 +75,17 @@ $count = 0;
                  group => '0,Access Group,parray',     # used to create a group of users/nodes for some purpose or other
                  isolate => '5,Isolate network,yesno',
                  delayed => '5,Delayed messages,parray',
-                 annfilter => '5,Announce Filter',
-                 wwvfilter => '5,WWV Filter',
-                 wcyfilter => '5,WCY Filter',
-                 spotsfilter => '5,Spot Filter',
-                 routefilter => '5,route Filter',
-                 inannfilter => '5,Input Ann Filter',
-                 inwwvfilter => '5,Input WWV Filter',
-                 inwcyfilter => '5,Input WCY Filter',
-                 inspotsfilter => '5,Input Spot Filter',
-                 inroutefilter => '5,Input Route Filter',
-                 passwd => '9,Passwd List,parray',
+                 annfilter => '5,Ann Filt-out',
+                 wwvfilter => '5,WWV Filt-out',
+                 wcyfilter => '5,WCY Filt-out',
+                 spotsfilter => '5,Spot Filt-out',
+                 routefilter => '5,Route Filt-out',
+                 inannfilter => '5,Ann Filt-inp',
+                 inwwvfilter => '5,WWV Filt-inp',
+                 inwcyfilter => '5,WCY Filt-inp',
+                 inspotsfilter => '5,Spot Filt-inp',
+                 inroutefilter => '5,Route Filt-inp',
+                 passwd => '9,Passwd List,yesno',
                  pingint => '5,Ping Interval ',
                  nopings => '5,Ping Obs Count',
                  lastping => '5,Ping last sent,atime',
@@ -101,6 +102,13 @@ $count = 0;
                  cq => '0,CQ Zone',
                  enhanced => '5,Enhanced Client,yesno',
                  senddbg => '8,Sending Debug,yesno',
+                 width => '0,Column Width',
+                 disconnecting => '9,Disconnecting,yesno',
+                 ann_talk => '0,Suppress Talk Anns,yesno',
+                 metric => '1,Route metric',
+                 badcount => '1,Bad Word Count',
+                 edit => '7,Edit Function',
+                 registered => '9,Registered?,yesno',
                 );
 
 use vars qw($VERSION $BRANCH);
@@ -497,6 +505,119 @@ sub decode_input
        return ($sort, $call, $line);
 }
 
+sub rspfcheck
+{
+       my ($self, $flag, $node, $user) = @_;
+       my $nref = Route::Node::get($node);
+       my $dxchan = $nref->dxchan if $nref;
+       if ($nref && $dxchan) {
+           if ($dxchan == $self) {
+                       return 1 unless $user;
+                       my @users = $nref->users;
+                       return 1 if @users == 0 || grep $user eq $_, @users;
+                       dbg("RSPF: $user not on $node") if isdbg('rspf');
+               } else {
+                       dbg("RSPF: Shortest path for $node is " . $nref->dxchan->{call}) if isdbg('rspf');
+               }
+       } else {
+               return 1 if $flag;
+               dbg("RSPF: required $node not found" ) if isdbg('rspf');
+       }
+       return 0;
+}
+
+# broadcast a message to all clusters taking into account isolation
+# [except those mentioned after buffer]
+sub broadcast_nodes
+{
+       my $s = shift;                          # the line to be rebroadcast
+       my @except = @_;                        # to all channels EXCEPT these (dxchannel refs)
+       my @dxchan = DXChannel::get_all_nodes();
+       my $dxchan;
+       
+       # send it if it isn't the except list and isn't isolated and still has a hop count
+       foreach $dxchan (@dxchan) {
+               next if grep $dxchan == $_, @except;
+               next if $dxchan == $main::me;
+               
+               my $routeit = $dxchan->can('adjust_hops') ? $dxchan->adjust_hops($s) : $s;      # adjust its hop count by node name
+
+               $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit;
+       }
+}
+
+# broadcast a message to all clusters ignoring isolation
+# [except those mentioned after buffer]
+sub broadcast_all_nodes
+{
+       my $s = shift;                          # the line to be rebroadcast
+       my @except = @_;                        # to all channels EXCEPT these (dxchannel refs)
+       my @dxchan = DXChannel::get_all_nodes();
+       my $dxchan;
+       
+       # send it if it isn't the except list and isn't isolated and still has a hop count
+       foreach $dxchan (@dxchan) {
+               next if grep $dxchan == $_, @except;
+               next if $dxchan == $main::me;
+
+               my $routeit = $dxchan->can('adjust_hops') ? $dxchan->adjust_hops($s) : $s;      # adjust its hop count by node name
+               $dxchan->send($routeit);
+       }
+}
+
+# broadcast to all users
+# storing the spot or whatever until it is in a state to receive it
+sub broadcast_users
+{
+       my $s = shift;                          # the line to be rebroadcast
+       my $sort = shift;           # the type of transmission
+       my $fref = shift;           # a reference to an object to filter on
+       my @except = @_;                        # to all channels EXCEPT these (dxchannel refs)
+       my @dxchan = DXChannel::get_all_users();
+       my $dxchan;
+       my @out;
+       
+       foreach $dxchan (@dxchan) {
+               next if grep $dxchan == $_, @except;
+               push @out, $dxchan;
+       }
+       broadcast_list($s, $sort, $fref, @out);
+}
+
+
+# broadcast to a list of users
+sub broadcast_list
+{
+       my $s = shift;
+       my $sort = shift;
+       my $fref = shift;
+       my $dxchan;
+       
+       foreach $dxchan (@_) {
+               my $filter = 1;
+               next if $dxchan == $main::me;
+               
+               if ($sort eq 'dx') {
+                   next unless $dxchan->{dx};
+                       ($filter) = $dxchan->{spotsfilter}->it(@{$fref}) if ref $fref;
+                       next unless $filter;
+               }
+               next if $sort eq 'ann' && !$dxchan->{ann} && $s !~ /^To\s+LOCAL\s+de\s+(?:$main::myalias|$main::mycall)/i;
+               next if $sort eq 'wwv' && !$dxchan->{wwv};
+               next if $sort eq 'wcy' && !$dxchan->{wcy};
+               next if $sort eq 'wx' && !$dxchan->{wx};
+
+               $s =~ s/\a//og unless $dxchan->{beep};
+
+               if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
+                       $dxchan->send($s);      
+               } else {
+                       $dxchan->delay($s);
+               }
+       }
+}
+
+
 no strict;
 sub AUTOLOAD
 {