3 # This module impliments the protocal mode for a dx cluster
5 # Copyright (c) 1998 Dirk Koopman G1TLH
38 use Time::HiRes qw(gettimeofday tv_interval);
43 use vars qw($pc11_max_age $pc23_max_age $last_pc50 $eph_restime $eph_info_restime $eph_pc34_restime
44 $last_hour $last10 %eph %pings %rcmds $ann_to_talk
45 $pingint $obscount %pc19list $chatdupeage $chatimportfn
46 $pc19_version $myprot_version
47 %nodehops $baddx $badspotter $badnode $censorpc
48 $allowzero $decode_dk0wcy $send_opernam @checklist
49 $eph_pc15_restime $pc92_update_period $pc92_obs_timeout
50 %pc92_find $pc92_find_timeout $pc92_short_update_period
51 $next_pc92_obs_timeout $pc92_slug_changes $last_pc92_slug
52 $pc92_extnode_update_period $pc50_interval
53 $pc92_keepalive_period $senderverify $pc92_ad_enabled
57 $pc11_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc11
58 $pc23_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc23
60 $last_hour = time; # last time I did an hourly periodic update
61 %rcmds = (); # outstanding rcmd requests outbound
62 %nodehops = (); # node specific hop control
63 %pc19list = (); # list of outstanding PC19s that haven't had PC16s on them
65 $censorpc = 1; # Do a BadWords::check on text fields and reject things
66 # loads of 'bad things'
67 $baddx = new DXHash "baddx";
68 $badspotter = new DXHash "badspotter";
69 $badnode = new DXHash "badnode";
70 $last10 = $last_pc50 = time;
73 $eph_info_restime = 18*60*60;
74 $eph_pc15_restime = 6*60;
75 $eph_pc34_restime = 30;
78 $chatdupeage = 20 * 60;
79 $chatimportfn = "$main::root/chat_import";
80 $pc19_version = 5455; # the visible version no for outgoing PC19s generated from pc59
81 $pc92_update_period = 4*60*60; # the period between outgoing PC92 C updates
82 $pc92_short_update_period = 15*60; # shorten the update period after a connection or start up
83 $pc92_extnode_update_period = 1*60*60; # the update period for external nodes
84 $pc92_keepalive_period = 1*60*60; # frequency of PC92 K (keepalive) records
85 %pc92_find = (); # outstanding pc92 find operations
86 $pc92_find_timeout = 30; # maximum time to wait for a reply
87 $senderverify = 0; # 1 = check spotter is on node it says it is and check ip address if available
88 ; # 2 = do 1 and dump if check
89 $pc92_ad_enabled = 1; # send pc92 A & D records.
90 $pc92c_ipaddr_enable = 0; # add the local ip address info to each callsign in a PC92 C
94 [ qw(i c c m bp bc c) ], # pc10
95 [ qw(i f m d t m c c h) ], # pc11
96 [ qw(i c bm m bm bm p h) ], # pc12
100 undef , # pc16 has to be validated manually
101 [ qw(i c c h) ], # pc17
102 [ qw(i m n) ], # pc18
103 undef , # pc19 has to be validated manually
104 undef , # pc20 no validation
105 [ qw(i c m h) ], # pc21
106 undef , # pc22 no validation
107 [ qw(i d n n n n m c c h) ], # pc23
108 [ qw(i c p h) ], # pc24
109 [ qw(i c c n n) ], # pc25
110 [ qw(i f m d t m c c bc) ], # pc26
111 [ qw(i d n n n n m c c bc) ], # pc27
112 [ qw(i c c m c d t p m bp n p bp bc) ], # pc28
113 [ qw(i c c n m) ], # pc29
114 [ qw(i c c n) ], # pc30
115 [ qw(i c c n) ], # pc31
116 [ qw(i c c n) ], # pc32
117 [ qw(i c c n) ], # pc33
118 [ qw(i c c m) ], # pc34
119 [ qw(i c c m) ], # pc35
120 [ qw(i c c m) ], # pc36
121 [ qw(i c c n m) ], # pc37
122 undef, # pc38 not interested
123 [ qw(i c m) ], # pc39
124 [ qw(i c c m p n) ], # pc40
125 [ qw(i c n m h) ], # pc41
126 [ qw(i c c n) ], # pc42
127 undef, # pc43 don't handle it
128 [ qw(i c c n m m c) ], # pc44
129 [ qw(i c c n m) ], # pc45
130 [ qw(i c c n) ], # pc46
133 [ qw(i c m h) ], # pc49
134 [ qw(i c n h) ], # pc50
135 [ qw(i c c n) ], # pc51
145 [ qw(i f m d t m c c a h) ], # pc61
157 [ qw(i d n n n n n n m m m c c h) ], # pc73
168 [ qw(i c c c m) ], # pc84
169 [ qw(i c c c m) ], # pc85
176 [ qw(i c f l)], # pc92
177 [ qw(i c f *m c *c m)], # pc93
180 # use the entry in the check list to check the field list presented
181 # return OK if line NOT in check list (for now)
188 return 0 if $n < 0 || $n > @checklist;
189 my $ref = $checklist[$n];
190 return 0 unless ref $ref;
193 for ($i = 1; $i < @$ref; $i++) {
194 my ($blank, $act) = $$ref[$i] =~ /^(b?)(\w)$/;
195 return 0 unless $act;
196 next if $blank eq 'b' && $pc->[$i] =~ /^[ \*]$/;
197 next if $blank eq '*' && $pc->[$i] =~ /^\*$/;
199 return $i unless is_callsign($pc->[$i]);
200 } elsif ($act eq 'i') {
202 } elsif ($act eq 'm') {
203 return $i unless is_pctext($pc->[$i]);
204 } elsif ($act eq 'p') {
205 return $i unless is_pcflag($pc->[$i]);
206 } elsif ($act eq 'f') {
207 return $i unless is_freq($pc->[$i]);
208 } elsif ($act eq 'n') {
209 return $i unless $pc->[$i] =~ /^[\d ]+$/;
210 } elsif ($act eq 'h') {
211 return $i unless $pc->[$i] =~ /^H\d\d?$/;
212 } elsif ($act eq 'd') {
213 return $i unless $pc->[$i] =~ /^\s*\d+-\w\w\w-[12][90]\d\d$/;
214 } elsif ($act eq 't') {
215 return $i unless $pc->[$i] =~ /^[012]\d[012345]\dZ$/;
216 } elsif ($act eq 'l') {
217 return $i unless $pc->[$i] =~ /^[A-Z]$/;
218 } elsif ($act eq 'a') {
219 return $i unless is_ipaddr($pc->[$i]);
228 my $period = shift || ($self->{do_pc9x} ? $pc92_update_period : $pc92_extnode_update_period);
229 $self->{next_pc92_update} = $main::systime + $period - int rand($period / 4);
230 dbg("ROUTE: update_pc92_next: $self->{call} " . atime($self->{next_pc92_update})) if isdbg('obscount');
233 sub update_pc92_keepalive
236 my $period = shift || $pc92_keepalive_period;
237 $self->{next_pc92_keepalive} = $main::systime + $period - int rand($period / 4);
238 dbg("ROUTE: update_pc92_keepalive: $self->{call} " . atime($self->{next_pc92_keepalive})) if isdbg('obscount');
243 my $fn = localdata("hop_table.pl");
247 my $user = DXUser::get($main::mycall);
248 die "User $main::mycall not setup or disappeared RTFM" unless $user;
250 $myprot_version += $main::version*100;
251 $main::me = DXProt->new($main::mycall, 0, $user);
252 $main::me->{here} = 1;
253 $main::me->{state} = "indifferent";
254 $main::me->{sort} = 'S'; # S for spider
255 $main::me->{priv} = 9;
256 $main::me->{metric} = 0;
257 $main::me->{pingave} = 0;
258 $main::me->{registered} = 1;
259 $main::me->{version} = $main::version;
260 $main::me->{build} = $main::build;
261 $main::me->{do_pc9x} = 1;
262 $main::me->{hostname} = $main::clusteraddr;
263 $main::me->update_pc92_next($pc92_short_update_period);
264 $main::me->update_pc92_keepalive;
268 # obtain a new connection this is derived from dxchannel
273 my $self = DXChannel::alloc(@_);
275 # add this node to the table, the values get filled in later
279 # if we have an entry already, then send a PC21 to all connect
280 # old style connections, because we are about to get the real deal
281 if (my $ref = Route::Node::get($call)) {
282 dbg("ROUTE: $call is already in the routing table, deleting") if isdbg('route');
283 my @rout = $ref->delete;
284 $self->route_pc21($main::mycall, undef, @rout) if @rout;
286 $main::routeroot->add($call, '5000', Route::here(1), $self->{conn}->peerhost) if $call ne $main::mycall;
291 # this is how a pc connection starts (for an incoming connection)
292 # issue a PC38 followed by a PC18, then wait for a PC20 (remembering
293 # all the crap that comes between).
296 my ($self, $line, $sort) = @_;
297 my $call = $self->{call};
298 my $user = $self->{user};
301 my $host = $self->{conn}->peerhost;
302 $host ||= "AGW Port #$self->{conn}->{agwport}" if exists $self->{conn}->{agwport};
303 $host ||= $host if is_ipaddr($host);
305 $self->{hostname} = $host if is_ipaddr($host);
306 Log('DXProt', "$call connected from $host");
308 # remember type of connection
309 $self->{consort} = $line;
310 $self->{outbound} = $sort eq 'O';
311 my $priv = $user->priv;
312 $priv = $user->priv(1) unless defined $priv;
313 $self->{priv} = $priv; # other clusters can always be 'normal' users
314 $self->{lang} = $user->lang || 'en';
315 $self->{isolate} = $user->{isolate};
316 $self->{consort} = $line; # save the connection type
320 # sort out registration
321 $self->{registered} = 1;
323 # get the output filters
324 # $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'node_default', 0);
325 # $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'node_default', 0);
326 # $self->{wcyfilter} = Filter::read_in('wcy', $call, 0) || Filter::read_in('wcy', 'node_default', 0);
327 # $self->{annfilter} = Filter::read_in('ann', $call, 0) || Filter::read_in('ann', 'node_default', 0) ;
328 # $self->{routefilter} = Filter::read_in('route', $call, 0) || Filter::read_in('route', 'node_default', 0) unless $self->{isolate};
329 # $self->{pc92filter} = Filter::read_in('pc92', $call, 0) || Filter::read_in('pc92', 'node_default', 0) unless $self->{isolate} ;
331 Filter::load_dxchan($self, 'spots', 0);
332 Filter::load_dxchan($self, 'wwv', 0);
333 Filter::load_dxchan($self, 'wcy', 0);
334 Filter::load_dxchan($self, 'ann', 0);
335 Filter::load_dxchan($self, 'route', 0) unless $self->{isolate};
336 Filter::load_dxchan($self, 'pc92', 0) unless $self->{isolate};
339 # get the INPUT filters (these only pertain to Clusters)
340 # $self->{inspotsfilter} = Filter::read_in('spots', $call, 1) || Filter::read_in('spots', 'node_default', 1);
341 # $self->{inwwvfilter} = Filter::read_in('wwv', $call, 1) || Filter::read_in('wwv', 'node_default', 1);
342 # $self->{inwcyfilter} = Filter::read_in('wcy', $call, 1) || Filter::read_in('wcy', 'node_default', 1);
343 # $self->{inannfilter} = Filter::read_in('ann', $call, 1) || Filter::read_in('ann', 'node_default', 1);
344 # $self->{inroutefilter} = Filter::read_in('route', $call, 1) || Filter::read_in('route', 'node_default', 1) unless $self->{isolate};
345 # $self->{inpc92filter} = Filter::read_in('pc92', $call, 0) || Filter::read_in('pc92', 'node_default', 0) unless $self->{isolate} ;
347 Filter::load_dxchan($self, 'spots', 1);
348 Filter::load_dxchan($self, 'wwv', 1);
349 Filter::load_dxchan($self, 'wcy', 1);
350 Filter::load_dxchan($self, 'ann', 1);
351 Filter::load_dxchan($self, 'route', 1) unless $self->{isolate};
352 Filter::load_dxchan($self, 'pc92', 1) unless $self->{isolate};
355 # set unbuffered and no echo
356 $self->send_now('B',"0");
357 $self->send_now('E',"0");
358 $self->conn->echo(0) if $self->conn->can('echo');
360 # ping neighbour node stuff
361 my $ping = $user->pingint;
362 $ping = $pingint unless defined $ping;
363 $self->{pingint} = $ping;
364 $self->{nopings} = $user->nopings || $obscount;
365 $self->{pingtime} = [ ];
366 $self->{pingave} = 999;
367 $self->{metric} ||= 100;
368 $self->{lastping} = $main::systime;
370 # send initialisation string
371 unless ($self->{outbound}) {
375 $self->state('init');
376 $self->{pc50_t} = $main::systime;
378 # send info to all logged in thingies
379 $self->tell_login('loginn');
381 # run a script send the output to the debug file
382 my $script = new Script(lc $call) || new Script('node_default');
383 $script->run($self) if $script;
385 # set up a config broadcast "quite soon" to converge tables quicker
386 $main::me->update_pc92_next($pc92_short_update_period);
387 $self->update_pc92_next($pc92_short_update_period);
389 # set next keepalive time
390 $self->update_pc92_keepalive;
394 # send outgoing 'challenge'
400 $self->send(pc18(($self->{isolate} || !$self->user->wantpc9x) ? "" : " pc9x"));
404 # This is the normal pcxx despatcher
408 my ($self, $line) = @_;
410 if ($line =~ '^<\w+\s' && $main::do_xml) {
411 DXXml::normal($self, $line);
415 my @field = split /\^/, $line;
416 return unless @field;
418 pop @field if $field[-1] eq '~';
420 # print join(',', @field), "\n";
423 # process PC frames, this will fail unless the frame starts PCnn
424 my ($pcno) = $field[0] =~ /^PC(\d\d)/; # just get the number
425 unless (defined $pcno && $pcno >= 10 && $pcno <= 99) {
426 dbg("PCPROT: unknown protocol") if isdbg('chanerr');
430 # check for and dump bad protocol messages
431 my $n = check($pcno, \@field);
433 dbg("PCPROT: bad field $n, dumped (" . parray($checklist[$pcno-10]) . ")") if isdbg('chanerr');
437 # modify the hop count here
438 if ($self != $main::me) {
439 if (my ($hops, $trail) = $line =~ /\^H(\d+)(\^?\~?)?$/) {
443 $line =~ s/\^H(\d+)(\^?\~?)?$/sprintf('^H%d%s', $hops, $trail)/e;
444 $field[-1] = "H$hops";
448 my $origin = $self->{call};
450 if (defined &Local::pcprot) {
452 eval { $r = Local::pcprot($self, $pcno, $line, $origin, \@field); };
453 return if $r; # i.e don't process it
456 # send it out for processing
458 my $sub = "handle_$pcno";
460 if ($self->can($sub)) {
461 $self->$sub($pcno, $line, $origin, \@field);
463 $self->handle_default($pcno, $line, $origin, \@field);
468 # This is called from inside the main cluster processing loop and is used
469 # for despatching commands that are doing some long processing job
474 my @dxchan = DXChannel::get_all();
479 if ($t - $last10 >= 10) {
487 # send out a pc50 on EVERY channel all at once
488 if ($t >= $last_pc50 + $pc50_interval) {
489 $pc50s = pc50($main::me, scalar DXChannel::get_all_users);
494 foreach $dxchan (@dxchan) {
495 next unless $dxchan->is_node;
496 next if $dxchan == $main::me;
499 $dxchan->send($pc50s) if !$dxchan->{do_pc9x} && $pc50s;
501 # send a ping out on this channel
502 if ($dxchan->{pingint} && $t >= $dxchan->{pingint} + $dxchan->{lastping}) {
503 if ($dxchan->{nopings} <= 0) {
504 dbg("ROUTE: $dxchan->{call} disconnected on ping obscount") if isdbg('obscount');
507 DXXml::Ping::add($main::me, $dxchan->call);
508 $dxchan->{nopings} -= 1;
509 $dxchan->{lastping} = $t;
510 $dxchan->{lastping} += $dxchan->{pingint} / 2 unless @{$dxchan->{pingtime}};
511 dbg("ROUTE: $dxchan->{call} ping obscount = $dxchan->{nopings}") if isdbg('obscount');
518 # send out config broadcasts
519 foreach $dxchan (@dxchan) {
520 next unless $dxchan->is_node;
522 # send out a PC92 config record if required for me and
523 # all my non pc9x dependent nodes. But for dependent nodes we only do
524 # this if we have not seen any from anyone else for at least half
525 # of one update period. This should stop quite a bit of excess C
526 # records. Someone will win, it does not really matter who, because
527 # we always believe "us".
528 if ($main::systime >= $dxchan->{next_pc92_update}) {
529 if ($dxchan == $main::me || !$dxchan->{do_pc9x}) {
530 dbg("ROUTE: pc92 broadcast candidate: $dxchan->{call}") if isdbg('obscount');
531 my $ref = Route::Node::get($dxchan->{call});
532 if ($dxchan == $main::me || ($ref && ($ref->measure_pc9x_t($main::systime-$main::systime_daystart)) >= $pc92_extnode_update_period/2)) {
533 $dxchan->broadcast_pc92_update($dxchan->{call});
535 $dxchan->update_pc92_next;
538 $dxchan->update_pc92_next; # this won't actually do anything, it's just to be tidy
543 # do the keepalive for me, if required
544 if ($main::systime >= $main::me->{next_pc92_keepalive}) {
545 time_out_pc92_routes();
546 $main::me->broadcast_pc92_keepalive($main::mycall);
549 if ($pc92_slug_changes && $main::systime >= $last_pc92_slug + $pc92_slug_changes) {
550 my ($add, $del) = gen_pc92_changes();
551 $main::me->route_pc92d($main::mycall, undef, $main::routeroot, @$del) if @$del;
552 $main::me->route_pc92a($main::mycall, undef, $main::routeroot, @$add) if @$add;
553 clear_pc92_changes();
557 if ($main::systime - 3600 > $last_hour) {
558 $last_hour = $main::systime;
565 # finish up a pc context
569 # some active measures
577 my @dxchan = DXChannel::get_all();
581 # send it if it isn't the except list and isn't isolated and still has a hop count
582 # taking into account filtering and so on
583 foreach $dxchan (@dxchan) {
584 next if $dxchan == $main::me;
585 next if $dxchan == $self && $self->is_node;
586 next if $dxchan == $self;
587 next if $dxchan->is_rbn;
588 if ($line =~ /PC61/ && !($dxchan->is_spider || $dxchan->is_user)) {
590 my @f = split /\^/, $line;
591 $pc11 = join '^', 'PC11', @f[1..7,9];
593 $dxchan->dx_spot($pc11, $self->{isolate}, @_, $self->{call});
595 $dxchan->dx_spot($line, $self->{isolate}, @_, $self->{call});
607 if ($self->{spotsfilter}) {
608 ($filter, $hops) = $self->{spotsfilter}->it(@_);
609 return unless $filter;
611 send_prot_line($self, $filter, $hops, $isolate, $line);
616 my ($self, $filter, $hops, $isolate, $line) = @_;
622 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
624 $routeit = adjust_hops($self, $line); # adjust its hop count by node name
625 return unless $routeit;
628 $self->send($routeit);
630 $self->send($routeit) unless $self->{isolate} || $isolate;
639 my @dxchan = DXChannel::get_all();
641 my @dxcc = ((Prefix::cty_data($_[6]))[0..2], (Prefix::cty_data($_[7]))[0..2]);
643 # send it if it isn't the except list and isn't isolated and still has a hop count
644 # taking into account filtering and so on
645 foreach $dxchan (@dxchan) {
646 next if $dxchan == $main::me;
647 next if $dxchan == $self && $self->is_node;
648 next if $dxchan->is_rbn;
652 $dxchan->wwv($line, $self->{isolate}, @_, $self->{call}, @dxcc);
663 if ($self->{wwvfilter}) {
664 ($filter, $hops) = $self->{wwvfilter}->it(@_[7..$#_]);
665 return unless $filter;
667 send_prot_line($self, $filter, $hops, $isolate, $line)
674 my @dxchan = DXChannel::get_all();
676 my @dxcc = ((Prefix::cty_data($_[10]))[0..2], (Prefix::cty_data($_[11]))[0..2]);
678 # send it if it isn't the except list and isn't isolated and still has a hop count
679 # taking into account filtering and so on
680 foreach $dxchan (@dxchan) {
681 next if $dxchan == $main::me;
682 next if $dxchan == $self;
683 next if $dxchan->is_rbn;
685 $dxchan->wcy($line, $self->{isolate}, @_, $self->{call}, @dxcc);
696 if ($self->{wcyfilter}) {
697 ($filter, $hops) = $self->{wcyfilter}->it(@_);
698 return unless $filter;
700 send_prot_line($self, $filter, $hops, $isolate, $line) if $self->is_clx || $self->is_spider || $self->is_dxnet;
707 my $from_pc9x = shift;
709 my @dxchan = DXChannel::get_all();
713 my $text = unpad($_[2]);
716 if ($_[3] eq '*') { # sysops
718 } elsif ($_[3] gt ' ') { # speciality list handling
719 my ($name) = split /\./, $_[3];
720 $target = "$name"; # put the rest in later (if bothered)
727 $target = "ALL" if !$target;
730 # obtain country codes etc
731 my @a = Prefix::cty_data($from);
732 my @b = Prefix::cty_data($_[4]);
733 if ($self->{inannfilter}) {
734 my ($filter, $hops) =
735 $self->{inannfilter}->it(@_, $self->{call},
737 @b[0..2], $a[3], $b[3]);
739 dbg("PCPROT: Rejected by input announce filter") if isdbg('chanerr');
744 # the sysop ('*') thing is an attempt to minimise the damage caused by non-updated PC93 generators
745 if (AnnTalk::dup($from, $target, $_[2]) || ($_[3] eq '*' && AnnTalk::dup($from, 'ALL', $_[2]))) {
746 my $dxchan = DXChannel::get($from);
747 if ($self == $main::me && $dxchan && $dxchan->is_user) {
748 if ($dxchan->priv < 5) {
749 $dxchan->send($dxchan->msg('dup'));
753 dbg("PCPROT: Duplicate Announce ignored") if isdbg('chanerr');
758 Log('ann', $target, $from, $text);
759 AnnTalk::add_anncache('ann', $target, $from, $text);
761 # send it if it isn't the except list and isn't isolated and still has a hop count
762 # taking into account filtering and so on
763 foreach $dxchan (@dxchan) {
764 next if $dxchan == $main::me;
765 next if $dxchan == $self && $self->is_node;
766 next if $from_pc9x && $dxchan->{do_pc9x};
767 next if $target eq 'LOCAL' && $dxchan->is_node;
768 next if $dxchan->is_rbn;
769 $dxchan->announce($line, $self->{isolate}, $to, $target, $text, @_, $self->{call},
774 my $msgid = int rand(1000);
779 $msgid = 1 if $msgid > 999;
787 my $from_pc9x = shift;
789 my @dxchan = DXChannel::get_all();
792 my $text = unpad($_[2]);
796 # munge the group and recast the line if required
797 if ($target =~ s/\.LST$//) {
801 # obtain country codes etc
802 my @a = Prefix::cty_data($from);
803 my @b = Prefix::cty_data($_[4]);
804 if ($self->{inannfilter}) {
805 my ($filter, $hops) =
806 $self->{inannfilter}->it(@_, $self->{call},
808 @b[0..2], $a[3], $b[3]);
810 dbg("PCPROT: Rejected by input announce filter") if isdbg('chanerr');
815 if (AnnTalk::dup($from, $target, $_[2], $main::systime + $chatdupeage)) {
816 my $dxchan = DXChannel::get($from);
817 if ($self == $main::me && $dxchan && $dxchan->is_user) {
818 if ($dxchan->priv < 5) {
819 $dxchan->send($dxchan->msg('dup'));
823 dbg("PCPROT: Duplicate Announce ignored") if isdbg('chanerr');
829 Log('chat', $target, $from, $text);
831 # send it if it isn't the except list and isn't isolated and still has a hop count
832 # taking into account filtering and so on
833 foreach $dxchan (@dxchan) {
834 if ($dxchan->is_node) {
835 next if $dxchan == $main::me;
836 next if $dxchan == $self;
837 next if $from_pc9x && $dxchan->do_pc9x;
838 next unless $dxchan->is_spider && $dxchan->do_pc9x;
839 next if $target eq 'LOCAL';
841 next if $dxchan->is_rbn;
843 $dxchan->chat($line, $self->{isolate}, $target, $_[1],
844 $text, @_, $self->{call}, @a[0..2], @b[0..2]);
858 if ($self->{annfilter}) {
859 ($filter, $hops) = $self->{annfilter}->it(@_);
860 return unless $filter;
862 send_prot_line($self, $filter, $hops, $isolate, $line) unless $_[1] eq $main::mycall;
875 if ($self->{annfilter}) {
876 ($filter, $hops) = $self->{annfilter}->it(@_);
877 return unless $filter;
879 if (($self->is_spider || $self->is_ak1a) && $_[1] ne $main::mycall) {
880 send_prot_line($self, $filter, $hops, $isolate, $line);
885 sub send_local_config
889 dbg('DXProt::send_local_config') if isdbg('trace');
897 if ($self->{isolate}) {
898 dbg("$self->{call} send_local_config: isolated");
899 @localnodes = ( $main::routeroot );
900 $self->send_route($main::mycall, \&pc19, 1, $main::routeroot);
901 } elsif ($self->{do_pc9x}) {
902 dbg("$self->{call} send_local_config: doing pc9x");
903 my $node = Route::Node::get($self->{call});
904 # $self->send_last_pc92_config($main::routeroot);
905 # $self->send(pc92a($main::routeroot, $node)) unless $main::routeroot->last_PC92C =~ /$self->{call}/;
906 $self->send(pc92a($main::routeroot, $node));
907 $self->send(pc92k($main::routeroot));
909 # create a list of all the nodes that are not connected to this connection
910 # and are not themselves isolated, this to make sure that isolated nodes
911 # don't appear outside of this node
913 dbg("$self->{call} send_local_config: traditional");
915 # send locally connected nodes
916 my @dxchan = grep { $_->call ne $main::mycall && $_ != $self && !$_->{isolate} } DXChannel::get_all_nodes();
917 @localnodes = map { my $r = Route::Node::get($_->{call}); $r ? $r : () } @dxchan if @dxchan;
918 $self->send_route($main::mycall, \&pc19, scalar(@localnodes)+1, $main::routeroot, @localnodes);
921 my @rawintcalls = map { $_->nodes } @localnodes if @localnodes;
923 foreach $node (@rawintcalls) {
924 push @intcalls, $node if grep $_ && $node != $_, @intcalls;
926 my $ref = Route::Node::get($self->{call});
927 my @rnodes = $ref->nodes;
928 foreach $node (@intcalls) {
929 push @remotenodes, Route::Node::get($node) if grep $_ && $node != $_, @rnodes, @remotenodes;
931 $self->send_route($main::mycall, \&pc19, scalar(@remotenodes), @remotenodes);
934 # get all the users connected on the above nodes and send them out
935 unless ($self->{do_pc9x}) {
936 foreach $node ($main::routeroot, @localnodes, @remotenodes) {
938 my @rout = map {my $r = Route::User::get($_); $r ? ($r) : ()} $node->users;
939 $self->send_route($main::mycall, \&pc16, 1, $node, @rout) if @rout && $self->user->wantsendpc16;
941 dbg("sent a null value") if isdbg('chanerr');
947 sub gen_my_pc92_config
951 if ($node->{call} eq $main::mycall) {
952 clear_pc92_changes(); # remove any slugged data, we are generating it as now
953 my @dxchan = grep { $_->call ne $main::mycall && !$_->{isolate} } DXChannel::get_all();
954 dbg("ROUTE: all dxchan: " . join(',', map{$_->{call}} @dxchan)) if isdbg('routelow');
955 my @localnodes = map { my $r = Route::get($_->{call}); ($_->is_node || $_->is_user) && $r ? $r : () } @dxchan;
956 dbg("ROUTE: localnodes: " . join(',', map{$_->{call}} @localnodes)) if isdbg('routelow');
957 return pc92c($node, @localnodes);
959 my @rout = map {my $r = Route::User::get($_); $r ? ($r) : ()} $node->users;
960 return pc92c($node, @rout);
964 sub send_last_pc92_config
968 if (my $l = $node->last_PC92C) {
971 $self->send_pc92_config($node);
980 dbg('DXProt::send_pc92_config') if isdbg('trace');
982 $node->last_PC92C(gen_my_pc92_config($node));
983 $self->send($node->last_PC92C);
986 sub broadcast_pc92_update
991 dbg("ROUTE: broadcast_pc92_update $call") if isdbg('obscount');
993 my $nref = Route::Node::get($call);
995 cluck("ERROR: broadcast_pc92_update - Route::Node $call disappeared");
996 $self->update_pc92_next;
999 my $l = $nref->last_PC92C(gen_my_pc92_config($nref));
1000 $nref->lastid(last_pc9x_id());
1001 $main::me->broadcast_route_pc9x($main::mycall, undef, $l, 0);
1002 $self->update_pc92_next;
1005 sub broadcast_pc92_keepalive
1010 dbg("ROUTE: broadcast_pc92_keepalive $call") if isdbg('obscount');
1012 my $nref = Route::Node::get($call);
1014 cluck("ERROR: broadcast_pc92_keepalive - Route::Node $call disappeared");
1015 $self->update_pc92_keepalive;
1018 my $l = pc92k($nref);
1019 $nref->lastid(last_pc9x_id());
1020 $main::me->broadcast_route_pc9x($main::mycall, undef, $l, 0);
1021 $self->update_pc92_keepalive;
1024 sub time_out_pc92_routes
1026 my @nodes = grep {$_->call ne $main::mycall && ($_->do_pc9x || $_->via_pc92)} Route::Node::get_all();
1028 foreach my $n (@nodes) {
1029 my $o = $n->dec_obs;
1031 if (my $dxchan = DXChannel::get($n->call)) {
1032 dbg("ROUTE: disconnecting local pc92 $dxchan->{call} on obscount") if isdbg('obscount');
1033 $dxchan->disconnect;
1036 my @parents = map {Route::Node::get($_)} $n->parents;
1039 dbg("ROUTE: deleting pc92 $_->{call} from $n->{call} on obscount") if isdbg('obscount');
1040 push @rdel, $n->del($_);
1044 dbg("ROUTE: obscount on $n->{call} now $o") if isdbg('obscount');
1048 $main::me->route_pc21($main::mycall, undef, $_) if $_;
1053 # route a message down an appropriate interface for a callsign
1055 # is called route(to, pcline);
1060 my ($self, $call, $line) = @_;
1062 if (ref $self && $call eq $self->{call}) {
1063 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
1067 # always send it down the local interface if available
1068 my $dxchan = DXChannel::get($call);
1070 dbg("route: $call -> $dxchan->{call} direct" ) if isdbg('route');
1072 my $cl = Route::get($call);
1073 $dxchan = $cl->dxchan if $cl;
1075 if (ref $self && $dxchan eq $self) {
1076 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
1079 dbg("route: $call -> $dxchan->{call} using normal route" ) if isdbg('route');
1084 my $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1086 $dxchan->send($routeit) unless $dxchan == $main::me;
1089 dbg("PCPROT: No route available, dropped") if isdbg('chanerr');
1094 # obtain the hops from the list for this callsign and pc no
1100 my $hops = $DXProt::hopcount{$pcno};
1101 $hops = $DXProt::def_hopcount unless $hops;
1106 # adjust the hop count on a per node basis using the user loadable
1107 # hop table if available or else decrement an existing one
1114 my $call = $self->{call};
1117 if (($hops) = $s =~ /\^H([-\d]+)\^?~?$/o) {
1118 my ($pcno) = $s =~ /^PC(\d\d)/o;
1119 confess "$call called adjust_hops with '$s'" unless $pcno;
1120 my $ref = $nodehops{$call} if %nodehops;
1122 my $newhops = $ref->{$pcno};
1123 return "" if defined $newhops && $newhops == 0;
1124 $newhops = $ref->{default} unless $newhops;
1125 return "" if defined $newhops && $newhops == 0;
1126 $newhops = $hops unless $newhops;
1127 return "" unless $newhops > 0;
1128 $s =~ s/\^H(\d+)(\^~?)$/\^H$newhops$2/ if $newhops != $hops;
1130 return "" unless $hops > 0;
1142 return $self->msg('lh1') unless -e "$main::data/hop_table.pl";
1143 do "$main::data/hop_table.pl";
1150 my ($self, $tonode, $fromnode, $user, $cmd) = @_;
1152 if ($tonode eq $main::mycall) {
1153 my $ref = DXUser::get_current($fromnode);
1154 unless ($ref && UNIVERSAL::isa($ref, 'DXUser')) {
1155 dbg("DXProt process_rcmd: user $fromnode isn't a reference (check user_asc and tell G1TLH)");
1156 $self->send_rcmd_reply($main::mycall, $fromnode, $user, "sorry...!");
1159 Log('rcmd', 'in', ($ref->{priv}||0), $fromnode, $cmd, $user);
1160 my $cref = Route::Node::get($fromnode);
1161 unless ($cref && UNIVERSAL::isa($cref, 'Route')) {
1162 dbg("DXProt process_rcmd: Route $fromnode isn't a reference (tell G1TLH)");
1163 $self->send_rcmd_reply($main::mycall, $fromnode, $user, "sorry...!");
1166 if ($cmd !~ /^\s*rcmd/i && $ref->homenode && $cref->call eq $ref->homenode) { # not allowed to relay RCMDS!
1167 if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
1168 $self->{remotecmd} = 1; # for the benefit of any command that needs to know
1169 my $oldpriv = $self->{priv};
1170 $self->{priv} = 1; # set a maximum privilege
1172 # park homenode and user for any spawned command that run_cmd may do.
1173 $self->{_rcmd_user} = $user;
1174 $self->{_rcmd_fromnode} = $fromnode;
1175 my @in = (DXCommandmode::run_cmd($self, $cmd));
1176 delete $self->{_rcmd_fromnode};
1177 delete $self->{_rcmd_user};
1178 $self->{priv} = $oldpriv;
1179 $self->send_rcmd_reply($main::mycall, $fromnode, $user, @in);
1180 delete $self->{remotecmd};
1182 $self->send_rcmd_reply($main::mycall, $fromnode, $user, "sorry...!");
1185 $self->send_rcmd_reply($main::mycall, $fromnode, $user, "your attempt is logged, Tut tut tut...!");
1188 my $ref = DXUser::get_current($tonode);
1189 if ($ref && $ref->is_clx) {
1190 $self->route($tonode, pc84($fromnode, $tonode, $user, $cmd));
1192 $self->route($tonode, pc34($fromnode, $tonode, $cmd));
1202 my $fromnode = shift;
1207 Log('rcmd', 'out', $fromnode, $line, $user);
1208 if ($self->is_clx) {
1209 $self->send(pc85($main::mycall, $fromnode, $user, "$main::mycall:$line"));
1211 $self->send(pc35($main::mycall, $fromnode, "$main::mycall:$line"));
1216 # Punt off a long running command into a separate process - this will be caused by an rcmd from outside
1218 # This is called from commands to run some potentially long running
1219 # function. The process forks and then runs the function and returns
1220 # the result back to the cmd.
1222 # NOTE: this merely forks the current process and then runs the cmd in that (current) context.
1223 # IT DOES NOT START UP SOME NEW PROGRAM AND RELIES ON THE FACT THAT IT IS RUNNING DXSPIDER
1224 # THE CURRENT CONTEXT!!
1226 # call: $self->spawn_cmd($original_cmd_line, \<function>, [cb => sub{...}], [prefix => "cmd> "], [progress => 0|1], [args => [...]]);
1232 my $call = $self->{call};
1236 my $cb = delete $args{cb};
1237 my $prefix = delete $args{prefix};
1238 my $progress = delete $args{progress};
1239 my $args = delete $args{args} || [];
1240 my $t0 = [gettimeofday];
1242 # remembered from process_cmd when spawn_cmd was called thru DXCommandmode::run_cmd which was called by process_rcmd
1243 my $fromnode = $self->{_rcmd_fromnode};
1244 my $user = $self->{_rcmd_user};
1248 my $fc = DXSubprocess->new;
1250 # just behave normally if something has set the "one-shot" _nospawn in the channel
1251 if ($self->{_nospawn} || $main::is_win == 1) {
1252 eval { @out = $cmdref->(@$args); };
1254 DXDebug::dbgprintring(25);
1255 push @out, DXDebug::shortmess($@);
1260 # $fc->serializer(\&encode_json);
1261 # $fc->deserializer(\&decode_json);
1265 if (isdbg('progress')) {
1266 my $s = qq{line: "$line"};
1267 $s .= ", args: " . join(', ', map { defined $_ ? qq{'$_'} : q{'undef'} } @$args) if $args && @$args;
1270 eval { @out = $cmdref->(@$args); };
1272 DXDebug::dbgprintring(25);
1273 push @out, DXDebug::shortmess($@);
1279 my ($fc, $err, @res) = @_;
1280 my $self = DXChannel::get($call);
1281 return unless $self;
1284 my $s = "DXCommand::spawn_cmd: call $call error $err";
1285 dbg($s) if isdbg('chan');
1286 if ($fromnode && $user) {
1287 $self->send_rcmd_reply($main::mycall, $fromnode, $user, $s);
1294 # transform output if required
1295 @res = $cb->($self, @res);
1298 if ($fromnode && $user) {
1299 $self->send_rcmd_reply($main::mycall, $fromnode, $user, @res);
1304 diffms("rcmd from $user on $call", $line, $t0, scalar @res) if isdbg('progress');
1310 sub process_rcmd_reply
1312 my ($self, $tonode, $fromnode, $user, $line) = @_;
1313 if ($tonode eq $main::mycall) {
1314 my $s = $rcmds{$fromnode};
1316 my $dxchan = DXChannel::get($s->{call});
1317 my $ref = $user eq $tonode ? $dxchan : (DXChannel::get($user) || $dxchan);
1318 $ref->send($line) if $ref;
1319 delete $rcmds{$fromnode} if !$dxchan;
1321 # send unsolicited ones to the sysop
1322 my $dxchan = DXChannel::get($main::myalias);
1323 $dxchan->send($line) if $dxchan;
1326 my $ref = DXUser::get_current($tonode);
1327 if ($ref && $ref->is_clx) {
1328 $self->route($tonode, pc85($fromnode, $tonode, $user, $line));
1330 $self->route($tonode, pc35($fromnode, $tonode, $line));
1337 # add a rcmd request to the rcmd queues
1340 my ($self, $to, $cmd) = @_;
1343 $r->{call} = $self->{call};
1344 $r->{t} = $main::systime;
1348 my $ref = Route::Node::get($to);
1349 my $dxchan = $ref->dxchan;
1350 if ($dxchan && $dxchan->is_clx) {
1351 route(undef, $to, pc84($main::mycall, $to, $self->{call}, $cmd));
1353 route(undef, $to, pc34($main::mycall, $to, $cmd));
1360 my $pc39flag = shift || 0;
1361 my $call = $self->call;
1363 return if $self->{disconnecting}++;
1365 unless ($pc39flag == 1) {
1366 $self->send_now("D", DXProt::pc39($main::mycall, $self->msg('disc1', "System Op")));
1369 # get rid of any PC16/17/19
1370 eph_del_regex("^PC1[679]*$call");
1372 # do routing stuff, remove me from routing table
1373 my $node = Route::Node::get($call);
1375 Route::delete_interface($call);
1377 # unbusy and stop and outgoing mail
1378 my $mref = DXMsg::get_busy($call);
1379 $mref->stop_msg($call) if $mref;
1381 # remove outstanding pings
1382 delete $pings{$call};
1384 # I was the last node visited
1385 $self->user->node($main::mycall);
1387 # send info to all logged in thingies
1388 $self->tell_login('logoutn');
1390 Log('DXProt', $call . " Disconnected");
1392 $self->SUPER::disconnect;
1394 # here we determine what needs to go out of the routing table
1396 if ($node && $pc39flag != 2) {
1397 dbg('%Route::Node::List = ' . join(',', sort keys %Route::Node::list)) if isdbg('routedisc');
1399 @rout = $node->del($main::routeroot);
1401 dbg('@rout = ' . join(',', sort map {$_->call} @rout)) if isdbg('routedisc');
1403 # now we need to see what can't be routed anymore and came
1404 # in via this node (probably).
1406 while ($n != @rout) {
1408 for (Route::Node::get_all()) {
1409 unless ($_->dxchan) {
1410 push @rout, $_->delete;
1413 dbg('@rout = ' . join(',', sort map {$_->call} @rout)) if isdbg('routedisc');
1416 dbg('%Route::Node::List = ' . join(',', sort keys %Route::Node::list)) if isdbg('routedisc');
1418 # and all my ephemera as well
1421 eph_del_regex("^PC1[679].*$c");
1425 # broadcast to all other nodes that all the nodes connected to via me are gone
1426 unless ($pc39flag == 2) {
1427 $self->route_pc21($main::mycall, undef, @rout) if @rout;
1428 $self->route_pc92d($main::mycall, undef, $main::routeroot, $node) if $node;
1434 # send a talk message to this thingy
1438 my ($self, $from, $to, $via, $line, $origin) = @_;
1440 my $ipaddr = DXCommandmode::alias_localhost($self->hostname || '127.0.0.1');
1441 if ($self->{do_pc9x}) {
1442 $self->send(pc93($to, $from, $via, $line, undef, $ipaddr));
1444 $self->send(pc10($from, $to, $via, $line, $origin));
1446 Log('talk', $to, $from, '>' . ($via || $origin || $self->call), $line, $ipaddr) unless $origin && $origin ne $main::mycall;
1449 # send it if it isn't the except list and isn't isolated and still has a hop count
1450 # taking into account filtering and so on
1456 my $generate = shift;
1457 my $no = shift; # the no of things to filter on
1459 my ($filter, $hops);
1462 for (; @_ && $no; $no--) {
1465 # don't send messages with $self's call in back to them
1466 if ($r->call eq $self->{call}) {
1467 dbg("PCPROT: trying to send $self->{call} back itself") if isdbg('chanerr');
1471 if (!$self->{isolate} && $self->{routefilter}) {
1474 ($filter, $hops) = $self->{routefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq, $self->{state}, $r->{state});
1478 dbg("PCPROT: $self->{call}/" . $r->call . " rejected by output filter") if isdbg('filter');
1481 dbg("was sent a null value") if isdbg('chanerr');
1484 push @rin, $r unless $self->{isolate} && $r->call ne $main::mycall;
1488 foreach my $line (&$generate(@rin, @_)) {
1491 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1493 $routeit = adjust_hops($self, $line); # adjust its hop count by node name
1494 next unless $routeit;
1497 $self->send($routeit);
1502 # broadcast everywhere
1507 my $generate = shift;
1509 my @dxchan = DXChannel::get_all_nodes();
1513 $line =~ /\^H(\d+)\^?\~?$/;
1514 return unless $1 > 0;
1516 unless ($self->{isolate}) {
1517 foreach $dxchan (@dxchan) {
1518 next if $dxchan == $self || $dxchan == $main::me;
1519 next if $origin eq $dxchan->{call}; # don't route some from this call back again.
1520 next unless $dxchan->isa('DXProt');
1522 $dxchan->send_route($origin, $generate, @_);
1527 # broadcast to non-pc9x nodes
1528 sub broadcast_route_nopc9x
1532 my $generate = shift;
1534 my @dxchan = DXChannel::get_all_nodes();
1538 $line =~ /\^H(\d+)\^?\~?$/;
1539 return unless $1 > 0;
1541 unless ($self->{isolate}) {
1542 foreach $dxchan (@dxchan) {
1543 next if $dxchan == $self || $dxchan == $main::me;
1544 next if $origin eq $dxchan->{call}; # don't route some from this call back again.
1545 next unless $dxchan->isa('DXProt');
1546 next if $dxchan->{do_pc9x};
1547 if ($generate == \&pc16 || $generate==\&pc17) {
1548 next unless $dxchan->user->wantsendpc16;
1550 $dxchan->send_route($origin, $generate, @_);
1555 # this is only used for next door nodes on init
1560 return unless $self->{do_pc9x};
1563 my $generate = shift;
1564 my $no = shift; # the no of things to filter on
1567 $line = &$generate(@_);
1571 # broadcast only to pc9x nodes
1572 sub broadcast_route_pc9x
1576 my $generate = shift;
1579 my @dxchan = DXChannel::get_all_nodes();
1582 if ($origin eq $main::mycall && $generate && !$line) {
1583 $line = &$generate(@_);
1586 $line =~ /\^H(\d+)\^\~?$/;
1587 unless ($1 > 0 && $self->{isolate}) {
1588 foreach $dxchan (@dxchan) {
1589 next if $dxchan == $self || $dxchan == $main::me;
1590 next if $origin eq $dxchan->{call}; # don't route some from this call back again.
1591 next unless $dxchan->isa('DXProt');
1592 next unless $dxchan->{do_pc9x};
1594 $dxchan->send($line);
1602 return unless $self->user->wantpc16;
1605 broadcast_route_nopc9x($self, $origin, \&pc16, $line, 1, @_);
1611 return unless $self->user->wantpc16;
1614 broadcast_route_nopc9x($self, $origin, \&pc17, $line, 1, @_);
1622 broadcast_route_nopc9x($self, $origin, \&pc19, $line, scalar @_, @_);
1630 broadcast_route_nopc9x($self, $origin, \&pc21, $line, scalar @_, @_);
1638 broadcast_route($self, $origin, \&pc24, $line, 1, @_);
1646 broadcast_route($self, $origin, \&pc41, $line, 1, @_);
1649 # this is probably obsolete now
1656 broadcast_route($self, $origin, \&pc50, $line, 1, @_);
1665 broadcast_route_pc9x($self, $origin, \&pc92c, $line, 1, @_);
1673 return unless $pc92_ad_enabled;
1674 broadcast_route_pc9x($self, $origin, \&pc92a, $line, 1, @_);
1682 return unless $pc92_ad_enabled;
1683 broadcast_route_pc9x($self, $origin, \&pc92d, $line, 1, @_);
1690 my ($filter, $hops) = (1, 1);
1692 if ($self->{inroutefilter}) {
1693 ($filter, $hops) = $self->{inroutefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq, $self->state, $r->state);
1694 dbg("PCPROT: $self->{call}/" . $r->call . ' rejected by in_filter_route') if !$filter && isdbg('chanerr');
1702 my $t = shift || $eph_restime;
1706 $s =~ s/\^H\d\d?\^?\~?$//;
1707 $r = 1 if exists $eph{$s}; # pump up the dup if it keeps circulating
1708 $eph{$s} = $main::systime + $t;
1709 dbg("PCPROT: emphemeral duplicate") if $r && isdbg('chanerr');
1717 while (($key, $val) = each %eph) {
1718 if ($key =~ m{$regex}) {
1728 while (($key, $val) = each %eph) {
1729 if ($main::systime >= $val) {
1740 while (($key, $val) = each %eph) {
1741 push @out, $key, $val;
1748 goto &DXCommandmode::run_cmd;
1752 # import any msgs in the chat directory
1753 # the messages are sent to the chat group which forms the
1754 # the first part of the name (eg: solar.1243.txt would be
1755 # sent to chat group SOLAR)
1757 # Each message found is sent: one non-blank line to one chat
1758 # message. So 4 lines = 4 chat messages.
1760 # The special name LOCAL is for local users ANN
1761 # The special name ALL is for ANN/FULL
1762 # The special name SYSOP is for ANN/SYSOP
1766 # are there any to do in this directory?
1767 return unless -d $chatimportfn;
1768 unless (opendir(DIR, $chatimportfn)) {
1769 dbg("can\'t open $chatimportfn $!") if isdbg('msg');
1770 Log('msg', "can\'t open $chatimportfn $!");
1774 my @names = readdir(DIR);
1777 foreach $name (@names) {
1778 next if $name =~ /^\./;
1779 my $splitit = $name =~ /^split/;
1780 my $fn = "$chatimportfn/$name";
1782 unless (open(MSG, $fn)) {
1783 dbg("can\'t open import file $fn $!") if isdbg('msg');
1784 Log('msg', "can\'t open import file $fn $!");
1788 my @msg = map { s/\r?\n$//; $_ } <MSG>;
1792 my @cat = split /\./, $name;
1793 my $target = uc $cat[0];
1795 foreach my $text (@msg) {
1796 next unless $text && $text !~ /^\s*#/;
1797 if ($target eq 'ALL' || $target eq 'LOCAL' || $target eq 'SYSOP' || $target eq 'WX') {
1798 my $sysop = uc $target eq 'SYSOP' ? '*' : ' ';
1799 my $wx = uc $target eq 'WX' ? '1' : '0';
1801 $via = '*' if $target eq 'ALL' || $target eq 'SYSOP';
1802 Log('ann', $target, $main::mycall, $text);
1803 AnnTalk::add_anncache('ann', $target, $main::mycall, $text);
1804 my $ipaddr = DXCommandmode::alias_localhost($main::me->hostname || '127.0.0.1');
1805 $main::me->normal(DXProt::pc93($target, $main::mycall, $via, $text, undef, $ipaddr));
1807 DXCommandmode::send_chats($main::me, $target, $text);
1813 # start a pc92 find operation
1818 my $key = "$dxchan->{call}|$target";
1819 if ($pc92_find{$key}) {
1824 # function (not method) to handle pc92 find returns
1825 sub handle_pc92_find_reply
1827 my ($dxchan, $node, $from, $target, $flag, $ms) = @_;
1829 $dxchan->print_pc92_find_reply($node, $target, $flag, $ms) if $dxchan->can('print_pc92_find_return');