3 # This module impliments the protocal mode for a dx cluster
5 # Copyright (c) 1998 Dirk Koopman G1TLH
30 use Time::HiRes qw(gettimeofday tv_interval);
37 use vars qw($me $pc11_max_age $pc23_max_age
38 $last_hour $last10 %eph %pings %rcmds
39 %nodehops $baddx $badspotter $badnode $censorpc
40 $allowzero $decode_dk0wcy $send_opernam @checklist);
42 $me = undef; # the channel id for this cluster
43 $pc11_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc11
44 $pc23_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc23
46 $last_hour = time; # last time I did an hourly periodic update
47 %pings = (); # outstanding ping requests outbound
48 %rcmds = (); # outstanding rcmd requests outbound
49 %nodehops = (); # node specific hop control
50 $censorpc = 1; # Do a BadWords::check on text fields and reject things
51 # loads of 'bad things'
52 $baddx = new DXHash "baddx";
53 $badspotter = new DXHash "badspotter";
54 $badnode = new DXHash "badnode";
59 [ qw(c c m bp bc c) ], # pc10
60 [ qw(f m d t m c c h) ], # pc11
61 [ qw(c bc m bp bm p h) ], # pc12
65 undef , # pc16 has to be validated manually
68 undef , # pc19 has to be validated manually
69 undef , # pc20 no validation
71 undef , # pc22 no validation
72 [ qw(d n n n n m c c h) ], # pc23
74 [ qw(c c n n) ], # pc25
75 [ qw(f m d t m c c bc) ], # pc26
76 [ qw(d n n n n m c c bc) ], # pc27
77 [ qw(c c m c d t p m bp n p bp bc) ], # pc28
78 [ qw(c c n m) ], # pc29
86 [ qw(c c n m) ], # pc37
87 undef, # pc38 not interested
89 [ qw(c c m p n) ], # pc40
90 [ qw(c n m h) ], # pc41
92 undef, # pc43 don't handle it
93 [ qw(c c n m m c) ], # pc44
94 [ qw(c c n m) ], # pc45
100 [ qw(c c n) ], # pc51
122 [ qw(d n n n n n n m m m c c h) ], # pc73
133 [ qw(c c c m) ], # pc84
134 [ qw(c c c m) ], # pc85
137 # use the entry in the check list to check the field list presented
138 # return OK if line NOT in check list (for now)
143 return 0 if $n < 0 || $n > @checklist;
144 my $ref = $checklist[$n];
145 return 0 unless ref $ref;
148 shift; # not interested in the first field
149 for ($i = 0; $i < @$ref; $i++) {
150 my ($blank, $act) = $$ref[$i] =~ /^(b?)(\w)$/;
151 return 0 unless $act;
152 next if $blank && $_[$i] =~ /^[ \*]$/;
154 return $i+1 unless is_callsign($_[$i]);
155 } elsif ($act eq 'm') {
156 return $i+1 unless is_pctext($_[$i]);
157 } elsif ($act eq 'p') {
158 return $i+1 unless is_pcflag($_[$i]);
159 } elsif ($act eq 'f') {
160 return $i+1 unless is_freq($_[$i]);
161 } elsif ($act eq 'n') {
162 return $i+1 unless $_[$i] =~ /^[\d ]+$/;
163 } elsif ($act eq 'h') {
164 return $i+1 unless $_[$i] =~ /^H\d\d?$/;
165 } elsif ($act eq 'd') {
166 return $i+1 unless $_[$i] =~ /^\s*\d+-\w\w\w-[12][90]\d\d$/;
167 } elsif ($act eq 't') {
168 return $i+1 unless $_[$i] =~ /^[012]\d[012345]\dZ$/;
176 my $user = DXUser->get($main::mycall);
177 $DXProt::myprot_version += $main::version*100;
178 $me = DXProt->new($main::mycall, 0, $user);
180 $me->{state} = "indifferent";
181 do "$main::data/hop_table.pl" if -e "$main::data/hop_table.pl";
183 $me->{sort} = 'S'; # S for spider
185 # $Route::Node::me->adddxchan($me);
189 # obtain a new connection this is derived from dxchannel
194 my $self = DXChannel::alloc(@_);
196 # add this node to the table, the values get filled in later
199 $main::routeroot->add($call, '0000', Route::here(1)) if $call ne $main::mycall;
204 # this is how a pc connection starts (for an incoming connection)
205 # issue a PC38 followed by a PC18, then wait for a PC20 (remembering
206 # all the crap that comes between).
209 my ($self, $line, $sort) = @_;
210 my $call = $self->{call};
211 my $user = $self->{user};
213 # remember type of connection
214 $self->{consort} = $line;
215 $self->{outbound} = $sort eq 'O';
216 $self->{priv} = $user->priv || 1; # other clusters can always be 'normal' users
217 $self->{lang} = $user->lang || 'en';
218 $self->{isolate} = $user->{isolate};
219 $self->{consort} = $line; # save the connection type
222 # get the output filters
223 $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'node_default', 0);
224 $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'node_default', 0);
225 $self->{wcyfilter} = Filter::read_in('wcy', $call, 0) || Filter::read_in('wcy', 'node_default', 0);
226 $self->{annfilter} = Filter::read_in('ann', $call, 0) || Filter::read_in('ann', 'node_default', 0) ;
227 $self->{routefilter} = Filter::read_in('route', $call, 0) || Filter::read_in('route', 'node_default', 0) ;
230 # get the INPUT filters (these only pertain to Clusters)
231 $self->{inspotsfilter} = Filter::read_in('spots', $call, 1) || Filter::read_in('spots', 'node_default', 1);
232 $self->{inwwvfilter} = Filter::read_in('wwv', $call, 1) || Filter::read_in('wwv', 'node_default', 1);
233 $self->{inwcyfilter} = Filter::read_in('wcy', $call, 1) || Filter::read_in('wcy', 'node_default', 1);
234 $self->{inannfilter} = Filter::read_in('ann', $call, 1) || Filter::read_in('ann', 'node_default', 1);
235 $self->{inroutefilter} = Filter::read_in('route', $call, 1) || Filter::read_in('route', 'node_default', 1);
237 # set unbuffered and no echo
238 $self->send_now('B',"0");
239 $self->send_now('E',"0");
241 # ping neighbour node stuff
242 my $ping = $user->pingint;
243 $ping = 5*60 unless defined $ping;
244 $self->{pingint} = $ping;
245 $self->{nopings} = $user->nopings || 2;
246 $self->{pingtime} = [ ];
247 $self->{pingave} = 0;
249 # send initialisation string
250 unless ($self->{outbound}) {
252 $self->{lastping} = $main::systime;
254 $self->{lastping} = $main::systime + ($self->pingint / 2);
256 $self->state('init');
257 $self->{pc50_t} = $main::systime;
259 # send info to all logged in thingies
260 $self->tell_login('loginn');
262 Log('DXProt', "$call connected");
266 # This is the normal pcxx despatcher
270 my ($self, $line) = @_;
271 my @field = split /\^/, $line;
272 return unless @field;
274 pop @field if $field[-1] eq '~';
276 # print join(',', @field), "\n";
279 # process PC frames, this will fail unless the frame starts PCnn
280 my ($pcno) = $field[0] =~ /^PC(\d\d)/; # just get the number
282 return if $pcno < 10 || $pcno > 99;
284 # check for and dump bad protocol messages
285 my $n = check($pcno, @field);
287 dbg("PCPROT: bad field $n, dumped (" . parray($checklist[$pcno-10]) . ")") if isdbg('chanerr');
294 $pcr = Local::pcprot($self, $pcno, @field);
296 # dbg("Local::pcprot error $@") if isdbg('local') if $@;
300 if ($pcno == 10) { # incoming talk
302 # will we allow it at all?
305 if (@bad = BadWords::check($field[3])) {
306 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
311 # is it for me or one of mine?
312 my ($to, $via, $call, $dxchan);
313 if ($field[5] gt ' ') {
314 $call = $via = $field[2];
317 $call = $to = $field[2];
319 $dxchan = DXChannel->get($main::myalias) if $call eq $main::mycall;
320 $dxchan = DXChannel->get($call) unless $dxchan;
321 if ($dxchan && $dxchan->is_user) {
322 $field[3] =~ s/\%5E/^/g;
323 $dxchan->talk($field[1], $to, $via, $field[3]);
325 $self->route($field[2], $line); # relay it on its way
330 if ($pcno == 11 || $pcno == 26) { # dx spot
332 # route 'foreign' pc26s
334 if ($field[7] ne $main::mycall) {
335 $self->route($field[7], $line);
340 # if this is a 'nodx' node then ignore it
341 if ($badnode->in($field[7])) {
342 dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr');
346 # if this is a 'bad spotter' user then ignore it
347 if ($badspotter->in($field[6])) {
348 dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
352 # convert the date to a unix date
353 my $d = cltounix($field[3], $field[4]);
354 # bang out (and don't pass on) if date is invalid or the spot is too old (or too young)
355 if (!$d || ($pcno == 11 && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) {
356 dbg("PCPROT: Spot ignored, invalid date or out of range ($field[3] $field[4])\n") if isdbg('chanerr');
361 if ($baddx->in($field[2])) {
362 dbg("PCPROT: Bad DX spot, ignored") if isdbg('chanerr');
367 $field[5] =~ s/^\s+//; # take any leading blanks off
368 $field[2] = unpad($field[2]); # take off leading and trailing blanks from spotted callsign
369 if ($field[2] =~ /BUST\w*$/) {
370 dbg("PCPROT: useless 'BUSTED' spot") if isdbg('chanerr');
373 if (Spot::dup($field[1], $field[2], $d, $field[5])) {
374 dbg("PCPROT: Duplicate Spot ignored\n") if isdbg('chanerr');
379 if (@bad = BadWords::check($field[5])) {
380 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
385 my @spot = Spot::prepare($field[1], $field[2], $d, $field[5], $field[6], $field[7]);
386 # global spot filtering on INPUT
387 if ($self->{inspotsfilter}) {
388 my ($filter, $hops) = $self->{inspotsfilter}->it(@spot);
390 dbg("PCPROT: Rejected by input spot filter") if isdbg('chanerr');
399 # @spot at this point contains:-
400 # freq, spotted call, time, text, spotter, spotted cc, spotters cc, orig node
401 # then spotted itu, spotted cq, spotters itu, spotters cq
402 # you should be able to route on any of these
405 # fix up qra locators of known users
406 my $user = DXUser->get_current($spot[4]);
408 my $qra = $user->qra;
409 unless ($qra && is_qra($qra)) {
410 my $lat = $user->lat;
411 my $long = $user->long;
412 if (defined $lat && defined $long) {
413 $user->qra(DXBearing::lltoqra($lat, $long));
418 # send a remote command to a distant cluster if it is visible and there is no
419 # qra locator and we havn't done it for a month.
421 unless ($user->qra) {
423 my $to = $user->homenode;
424 my $last = $user->lastoper || 0;
425 if ($to ne $main::mycall && $send_opernam && $main::systime > $last + $DXUser::lastoperinterval && $to && ($node = Route::Node::get($to)) ) {
426 my $cmd = "forward/opernam $spot[4]";
427 # send the rcmd but we aren't interested in the replies...
428 my $dxchan = $node->dxchan;
429 if ($dxchan && $dxchan->is_clx) {
430 route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
432 route(undef, $to, pc34($main::mycall, $to, $cmd));
434 if ($to ne $field[7]) {
436 $node = Route::Node::get($to);
438 $dxchan = $node->dxchan;
439 if ($dxchan && $dxchan->is_clx) {
440 route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
442 route(undef, $to, pc34($main::mycall, $to, $cmd));
446 $user->lastoper($main::systime);
455 $r = Local::spot($self, @spot);
457 # dbg("Local::spot1 error $@") if isdbg('local') if $@;
460 # DON'T be silly and send on PC26s!
461 return if $pcno == 26;
463 # send out the filtered spots
464 send_dx_spot($self, $line, @spot) if @spot;
468 if ($pcno == 12) { # announces
469 # announce duplicate checking
470 $field[3] =~ s/^\s+//; # remove leading blanks
471 if (AnnTalk::dup($field[1], $field[2], $field[3])) {
472 dbg("PCPROT: Duplicate Announce ignored") if isdbg('chanerr');
478 if (@bad = BadWords::check($field[3])) {
479 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
484 if ($field[2] eq '*' || $field[2] eq $main::mycall) {
486 # global ann filtering on INPUT
487 if ($self->{inannfilter}) {
488 my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
489 my @dxcc = Prefix::extract($field[1]);
491 $ann_dxcc = $dxcc[1]->dxcc;
492 $ann_itu = $dxcc[1]->itu;
493 $ann_cq = $dxcc[1]->cq();
495 @dxcc = Prefix::extract($field[5]);
497 $org_dxcc = $dxcc[1]->dxcc;
498 $org_itu = $dxcc[1]->itu;
499 $org_cq = $dxcc[1]->cq();
501 my ($filter, $hops) = $self->{inannfilter}->it(@field[1..6], $self->{call},
502 $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
504 dbg("PCPROT: Rejected by input announce filter") if isdbg('chanerr');
510 $self->send_announce($line, @field[1..6]);
512 $self->route($field[2], $line);
528 if ($pcno == 16) { # add a user
530 if (eph_dup($line)) {
531 dbg("PCPROT: dup PC16 detected") if isdbg('chanerr');
537 my $ncall = $field[1];
538 my $newline = "PC16^";
540 if ($ncall eq $main::mycall) {
541 dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
544 $dxchan = DXChannel->get($ncall);
545 if ($dxchan && $dxchan ne $self) {
546 dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
549 my $parent = Route::Node::get($ncall);
551 dbg("PCPROT: Node $ncall not in config") if isdbg('chanerr');
555 # input filter if required
556 return unless $self->in_filter_route($parent);
560 for ($i = 2; $i < $#field; $i++) {
561 my ($call, $conf, $here) = $field[$i] =~ /^(\S+) (\S) (\d)/o;
562 next unless $call && $conf && defined $here && is_callsign($call);
563 next if $call eq $main::mycall;
565 eph_del_regex("^PC17\^$call\^$ncall");
567 $conf = $conf eq '*';
569 my $r = Route::User::get($call);
570 my $flags = Route::here($here)|Route::conf($conf);
573 if ($r->flags != $flags) {
577 $r->addparent($ncall);
579 push @rout, $parent->add_user($call, $flags);
582 # add this station to the user database, if required
583 $call =~ s/-\d+$//o; # remove ssid for users
584 my $user = DXUser->get_current($call);
585 $user = DXUser->new($call) if !$user;
586 $user->homenode($parent->call) if !$user->homenode;
587 $user->node($parent->call);
588 $user->lastin($main::systime) unless DXChannel->get($call);
593 # queue up any messages (look for privates only)
594 DXMsg::queue_msg(1) if $self->state eq 'normal';
596 $self->route_pc16($parent, @rout) if @rout;
600 if ($pcno == 17) { # remove a user
602 my $ncall = $field[2];
603 my $ucall = $field[1];
604 if (eph_dup($line)) {
605 dbg("PCPROT: dup PC17 detected") if isdbg('chanerr');
609 eph_del_regex("^PC16.*$ncall.*$ucall");
611 if ($ncall eq $main::mycall) {
612 dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
615 $dxchan = DXChannel->get($ncall);
616 if ($dxchan && $dxchan ne $self) {
617 dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
620 my $parent = Route::Node::get($ncall);
622 dbg("PCPROT: Route::Node $ncall not in config") if isdbg('chanerr');
626 # input filter if required
627 return unless $self->in_filter_route($parent);
629 my @rout = $parent->del_user($ucall);
630 $self->route_pc17($parent, @rout) if @rout;
634 if ($pcno == 18) { # link request
635 $self->state('init');
637 # first clear out any nodes on this dxchannel
638 my $parent = Route::Node::get($self->{call});
639 my @rout = $parent->del_nodes;
640 $self->route_pc21(@rout, $parent);
641 $self->send_local_config();
643 return; # we don't pass these on
646 if ($pcno == 19) { # incoming cluster list
648 my $newline = "PC19^";
650 if (eph_dup($line)) {
651 dbg("PCPROT: dup PC19 detected") if isdbg('chanerr');
657 my $parent = Route::Node::get($self->{call});
659 dbg("DXPROT: my parent $self->{call} has disappeared");
665 for ($i = 1; $i < $#field-1; $i += 4) {
666 my $here = $field[$i];
667 my $call = uc $field[$i+1];
668 my $conf = $field[$i+2];
669 my $ver = $field[$i+3];
670 next unless defined $here && defined $conf && is_callsign($call);
672 eph_del_regex("^PC(?:21\^$call|17\^[^\^]+\^$call)");
674 # check for sane parameters
675 $ver = 5000 if $ver eq '0000';
676 next if $ver < 5000; # only works with version 5 software
677 next if length $call < 3; # min 3 letter callsigns
678 next if $call eq $main::mycall;
680 # update it if required
681 my $r = Route::Node::get($call);
682 my $flags = Route::here($here)|Route::conf($conf);
685 if ($call ne $parent->call) {
686 if ($self->in_filter_route($r)) {
687 $ar = $parent->add($call, $ver, $flags);
688 push @rout, $ar if $ar;
693 if ($r->version ne $ver || $r->flags != $flags) {
696 push @rout, $r unless $ar;
699 if ($call eq $self->{call}) {
700 dbg("DXPROT: my channel route for $call has disappeared");
704 my $new = Route->new($call); # throw away
705 if ($self->in_filter_route($new)) {
706 my $r = $parent->add($call, $ver, $flags);
713 # unbusy and stop and outgoing mail (ie if somehow we receive another PC19 without a disconnect)
714 my $mref = DXMsg::get_busy($call);
715 $mref->stop_msg($call) if $mref;
717 # add this station to the user database, if required (don't remove SSID from nodes)
718 my $user = DXUser->get_current($call);
720 $user = DXUser->new($call);
722 $user->priv(1); # I have relented and defaulted nodes
723 $self->{priv} = 1; # to user RCMDs allowed
724 $user->homenode($call);
727 $user->lastin($main::systime) unless DXChannel->get($call);
731 $self->route_pc19(@rout) if @rout;
735 if ($pcno == 20) { # send local configuration
736 $self->send_local_config();
738 $self->state('normal');
742 if ($pcno == 21) { # delete a cluster from the list
743 if (eph_dup($line)) {
744 dbg("PCPROT: dup PC21 detected") if isdbg('chanerr');
748 my $call = uc $field[1];
750 eph_del_regex("^PC1[79].*$call");
753 my $parent = Route::Node::get($self->{call});
755 dbg("DXPROT: my parent $self->{call} has disappeared");
759 my $node = Route::Node::get($call);
760 if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me!
761 if ($call eq $self->{call}) {
762 dbg("PCPROT: Trying to disconnect myself with PC21") if isdbg('chanerr');
768 return unless $self->in_filter_route($node);
771 push @rout, $node->del($parent);
774 dbg("PCPROT: I WILL _NOT_ be disconnected!") if isdbg('chanerr');
777 $self->route_pc21(@rout) if @rout;
782 $self->state('normal');
786 if ($pcno == 23 || $pcno == 27) { # WWV info
788 # route 'foreign' pc27s
790 if ($field[8] ne $main::mycall) {
791 $self->route($field[8], $line);
797 my $d = cltounix($field[1], sprintf("%02d18Z", $field[2]));
798 my $sfi = unpad($field[3]);
799 my $k = unpad($field[4]);
800 my $i = unpad($field[5]);
801 my ($r) = $field[6] =~ /R=(\d+)/;
803 if (($pcno == 23 && $d < $main::systime - $pc23_max_age) || $d > $main::systime + 1500 || $field[2] < 0 || $field[2] > 23) {
804 dbg("PCPROT: WWV Date ($field[1] $field[2]) out of range") if isdbg('chanerr');
807 if (Geomag::dup($d,$sfi,$k,$i,$field[6])) {
808 dbg("PCPROT: Dup WWV Spot ignored\n") if isdbg('chanerr');
811 $field[7] =~ s/-\d+$//o; # remove spotter's ssid
813 my $wwv = Geomag::update($d, $field[2], $sfi, $k, $i, @field[6..8], $r);
817 $rep = Local::wwv($self, $field[1], $field[2], $sfi, $k, $i, @field[6..8], $r);
819 # dbg("Local::wwv2 error $@") if isdbg('local') if $@;
822 # DON'T be silly and send on PC27s!
823 return if $pcno == 27;
825 # broadcast to the eager world
826 send_wwv_spot($self, $line, $d, $field[2], $sfi, $k, $i, @field[6..8]);
830 if ($pcno == 24) { # set here status
831 my $call = uc $field[1];
833 $nref = Route::Node::get($call);
834 $uref = Route::User::get($call);
835 return unless $nref || $uref; # if we don't know where they are, it's pointless sending it on
837 unless (eph_dup($line)) {
838 $nref->here($field[2]) if $nref;
839 $uref->here($field[2]) if $uref;
840 my $ref = $nref || $uref;
841 return unless $self->in_filter_route($ref);
842 $self->route_pc24($ref, $field[3]);
847 if ($pcno == 25) { # merge request
848 if ($field[1] ne $main::mycall) {
849 $self->route($field[1], $line);
852 if ($field[2] eq $main::mycall) {
853 dbg("PCPROT: Trying to merge to myself, ignored") if isdbg('chanerr');
857 Log('DXProt', "Merge request for $field[3] spots and $field[4] WWV from $field[1]");
861 my @in = reverse Spot::search(1, undef, undef, 0, $field[3]);
864 $self->send(pc26(@{$in}[0..4], $field[2]));
870 my @in = reverse Geomag::search(0, $field[4], time, 1);
873 $self->send(pc27(@{$in}[0..5], $field[2]));
879 if (($pcno >= 28 && $pcno <= 33) || $pcno == 40 || $pcno == 42 || $pcno == 49) { # mail/file handling
880 if ($pcno == 49 || $field[1] eq $main::mycall) {
881 DXMsg::process($self, $line);
883 $self->route($field[1], $line) unless $self->is_clx;
888 if ($pcno == 34 || $pcno == 36) { # remote commands (incoming)
889 $self->process_rcmd($field[1], $field[2], $field[2], $field[3]);
893 if ($pcno == 35) { # remote command replies
894 $self->process_rcmd_reply($field[1], $field[2], $field[1], $field[3]);
898 # for pc 37 see 44 onwards
900 if ($pcno == 38) { # node connected list from neighbour
904 if ($pcno == 39) { # incoming disconnect
905 if ($field[1] eq $self->{call}) {
906 $self->disconnect(1);
907 eph_dup_regex("^PC(?:1[679]|21).*$field[1]");
909 dbg("PCPROT: came in on wrong channel") if isdbg('chanerr');
914 if ($pcno == 41) { # user info
915 my $call = $field[1];
917 # input filter if required
918 # my $ref = Route::get($call) || Route->new($call);
919 # return unless $self->in_filter_route($ref);
921 # add this station to the user database, if required
922 my $user = DXUser->get_current($call);
923 $user = DXUser->new($call) if !$user;
925 if ($field[2] == 1) {
926 $user->name($field[3]);
927 } elsif ($field[2] == 2) {
928 $user->qth($field[3]);
929 } elsif ($field[2] == 3) {
930 if (is_latlong($field[3])) {
931 my ($lat, $long) = DXBearing::stoll($field[3]);
934 $user->qra(DXBearing::lltoqra($lat, $long));
936 dbg('PCPROT: not a valid lat/long') if isdbg('chanerr');
939 } elsif ($field[2] == 4) {
940 $user->homenode($field[3]);
941 } elsif ($field[2] == 5) {
942 if (is_qra($field[3])) {
943 my ($lat, $long) = DXBearing::qratoll($field[3]);
946 $user->qra($field[3]);
948 dbg('PCPROT: not a valid QRA locator') if isdbg('chanerr');
952 $user->lastoper($main::systime); # to cut down on excessive for/opers being generated
955 # perhaps this IS what we want after all
956 # $self->route_pc41($ref, $call, $field[2], $field[3], $field[4]);
964 if ($pcno == 37 || $pcno == 44 || $pcno == 45 || $pcno == 46 || $pcno == 47 || $pcno == 48) {
965 DXDb::process($self, $line);
969 if ($pcno == 50) { # keep alive/user list
970 my $call = $field[1];
971 my $node = Route::Node::get($call);
973 return unless $node->call eq $self->{call};
974 $node->usercount($field[2]);
976 # input filter if required
977 return unless $self->in_filter_route($node);
979 $self->route_pc50($node, $field[2], $field[3]) unless eph_dup($line);
984 if ($pcno == 51) { # incoming ping requests/answers
986 my $from = $field[2];
987 my $flag = $field[3];
990 if ($to eq $main::mycall) {
992 $self->send(pc51($from, $to, '0'));
994 # it's a reply, look in the ping list for this one
995 my $ref = $pings{$from};
997 my $tochan = DXChannel->get($from);
1000 my $dxchan = DXChannel->get($r->{call});
1001 next unless $dxchan;
1002 my $t = tv_interval($r->{t}, [ gettimeofday ]);
1003 if ($dxchan->is_user) {
1004 my $s = sprintf "%.2f", $t;
1005 my $ave = sprintf "%.2f", $tochan ? ($tochan->{pingave} || $t) : $t;
1006 $dxchan->send($dxchan->msg('pingi', $from, $s, $ave))
1007 } elsif ($dxchan->is_node) {
1009 $tochan->{nopings} = $tochan->user->nopings || 2; # pump up the timer
1010 push @{$tochan->{pingtime}}, $t;
1011 shift @{$tochan->{pingtime}} if @{$tochan->{pingtime}} > 6;
1013 for (@{$tochan->{pingtime}}) {
1016 $tochan->{pingave} = $st / @{$tochan->{pingtime}};
1023 # route down an appropriate thingy
1024 $self->route($to, $line);
1029 if ($pcno == 75) { # dunno but route it
1030 my $call = $field[1];
1031 if ($call ne $main::mycall) {
1032 $self->route($call, $line);
1037 if ($pcno == 73) { # WCY broadcasts
1038 my $call = $field[1];
1041 my $d = cltounix($call, sprintf("%02d18Z", $field[2]));
1042 if (($pcno == 23 && $d < $main::systime - $pc23_max_age) || $d > $main::systime + 1500 || $field[2] < 0 || $field[2] > 23) {
1043 dbg("PCPROT: WCY Date ($call $field[2]) out of range") if isdbg('chanerr');
1046 @field = map { unpad($_) } @field;
1047 if (WCY::dup($d,@field[3..7])) {
1048 dbg("PCPROT: Dup WCY Spot ignored\n") if isdbg('chanerr');
1052 my $wcy = WCY::update($d, @field[2..12]);
1056 $rep = Local::wwv($self, @field[1..12]);
1058 # dbg("Local::wcy error $@") if isdbg('local') if $@;
1061 # broadcast to the eager world
1062 send_wcy_spot($self, $line, $d, @field[2..12]);
1066 if ($pcno == 84) { # remote commands (incoming)
1067 $self->process_rcmd($field[1], $field[2], $field[3], $field[4]);
1071 if ($pcno == 85) { # remote command replies
1072 $self->process_rcmd_reply($field[1], $field[2], $field[3], $field[4]);
1078 # if get here then rebroadcast the thing with its Hop count decremented (if
1079 # there is one). If it has a hop count and it decrements to zero then don't
1082 # NOTE - don't arrive here UNLESS YOU WANT this lump of protocol to be
1086 if (eph_dup($line)) {
1087 dbg("PCPROT: Ephemeral dup, dropped") if isdbg('chanerr');
1089 unless ($self->{isolate}) {
1090 broadcast_ak1a($line, $self); # send it to everyone but me
1096 # This is called from inside the main cluster processing loop and is used
1097 # for despatching commands that are doing some long processing job
1102 my @dxchan = DXChannel->get_all();
1105 foreach $dxchan (@dxchan) {
1106 next unless $dxchan->is_node();
1107 next if $dxchan == $me;
1109 # send a pc50 out on this channel
1110 $dxchan->{pc50_t} = $main::systime unless exists $dxchan->{pc50_t};
1111 if ($t >= $dxchan->{pc50_t} + $DXProt::pc50_interval) {
1112 my $s = pc50($me, scalar DXChannel::get_all_users);
1115 $dxchan->{pc50_t} = $t;
1118 # send a ping out on this channel
1119 if ($dxchan->{pingint} && $t >= $dxchan->{pingint} + $dxchan->{lastping}) {
1120 if ($dxchan->{nopings} <= 0) {
1121 $dxchan->disconnect;
1123 addping($main::mycall, $dxchan->call);
1124 $dxchan->{nopings} -= 1;
1125 $dxchan->{lastping} = $t;
1131 if ($t - $last10 >= 10) {
1132 # clean out ephemera
1139 if ($main::systime - 3600 > $last_hour) {
1140 $last_hour = $main::systime;
1145 # finish up a pc context
1149 # some active measures
1156 my @dxchan = DXChannel->get_all();
1159 # send it if it isn't the except list and isn't isolated and still has a hop count
1160 # taking into account filtering and so on
1161 foreach $dxchan (@dxchan) {
1162 next if $dxchan == $me;
1163 next if $dxchan == $self && $self->is_node;
1164 $dxchan->dx_spot($line, $self->{isolate}, @_, $self->{call});
1172 my $isolate = shift;
1173 my ($filter, $hops);
1175 if ($self->{spotsfilter}) {
1176 ($filter, $hops) = $self->{spotsfilter}->it(@_);
1177 return unless $filter;
1179 send_prot_line($self, $filter, $hops, $isolate, $line);
1184 my ($self, $filter, $hops, $isolate, $line) = @_;
1189 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1191 $routeit = adjust_hops($self, $line); # adjust its hop count by node name
1192 return unless $routeit;
1195 $self->send($routeit);
1197 $self->send($routeit) unless $self->{isolate} || $isolate;
1206 my @dxchan = DXChannel->get_all();
1208 my ($wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1209 my @dxcc = Prefix::extract($_[7]);
1211 $wwv_dxcc = $dxcc[1]->dxcc;
1212 $wwv_itu = $dxcc[1]->itu;
1213 $wwv_cq = $dxcc[1]->cq;
1215 @dxcc = Prefix::extract($_[8]);
1217 $org_dxcc = $dxcc[1]->dxcc;
1218 $org_itu = $dxcc[1]->itu;
1219 $org_cq = $dxcc[1]->cq;
1222 # send it if it isn't the except list and isn't isolated and still has a hop count
1223 # taking into account filtering and so on
1224 foreach $dxchan (@dxchan) {
1225 next if $dxchan == $me;
1226 next if $dxchan == $self && $self->is_node;
1228 my ($filter, $hops);
1230 $dxchan->wwv($line, $self->{isolate}, @_, $self->{call}, $wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq);
1239 my $isolate = shift;
1240 my ($filter, $hops);
1242 if ($self->{wwvfilter}) {
1243 ($filter, $hops) = $self->{wwvfilter}->it(@_);
1244 return unless $filter;
1246 send_prot_line($self, $filter, $hops, $isolate, $line)
1253 my @dxchan = DXChannel->get_all();
1255 my ($wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1256 my @dxcc = Prefix::extract($_[11]);
1258 $wcy_dxcc = $dxcc[1]->dxcc;
1259 $wcy_itu = $dxcc[1]->itu;
1260 $wcy_cq = $dxcc[1]->cq;
1262 @dxcc = Prefix::extract($_[12]);
1264 $org_dxcc = $dxcc[1]->dxcc;
1265 $org_itu = $dxcc[1]->itu;
1266 $org_cq = $dxcc[1]->cq;
1269 # send it if it isn't the except list and isn't isolated and still has a hop count
1270 # taking into account filtering and so on
1271 foreach $dxchan (@dxchan) {
1272 next if $dxchan == $me;
1273 next if $dxchan == $self;
1275 $dxchan->wcy($line, $self->{isolate}, @_, $self->{call}, $wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq);
1283 my $isolate = shift;
1284 my ($filter, $hops);
1286 if ($self->{wcyfilter}) {
1287 ($filter, $hops) = $self->{wcyfilter}->it(@_);
1288 return unless $filter;
1290 send_prot_line($self, $filter, $hops, $isolate, $line) if $self->is_clx || $self->is_spider || $self->is_dxnet;
1298 my @dxchan = DXChannel->get_all();
1302 my $text = unpad($_[2]);
1304 if ($_[3] eq '*') { # sysops
1306 } elsif ($_[3] gt ' ') { # speciality list handling
1307 my ($name) = split /\./, $_[3];
1308 $target = "$name"; # put the rest in later (if bothered)
1315 $target = "ALL" if !$target;
1317 Log('ann', $target, $_[0], $text);
1319 # obtain country codes etc
1320 my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1321 my @dxcc = Prefix::extract($_[0]);
1323 $ann_dxcc = $dxcc[1]->dxcc;
1324 $ann_itu = $dxcc[1]->itu;
1325 $ann_cq = $dxcc[1]->cq;
1327 @dxcc = Prefix::extract($_[4]);
1329 $org_dxcc = $dxcc[1]->dxcc;
1330 $org_itu = $dxcc[1]->itu;
1331 $org_cq = $dxcc[1]->cq;
1334 # send it if it isn't the except list and isn't isolated and still has a hop count
1335 # taking into account filtering and so on
1336 foreach $dxchan (@dxchan) {
1337 next if $dxchan == $me;
1338 next if $dxchan == $self && $self->is_node;
1340 my ($filter, $hops);
1342 $dxchan->announce($line, $self->{isolate}, $to, $target, $text, @_, $self->{call}, $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq)
1350 my $isolate = shift;
1353 my ($filter, $hops);
1355 if ($self->{annfilter}) {
1356 ($filter, $hops) = $self->{annfilter}->it(@_);
1357 return unless $filter;
1359 send_prot_line($self, $filter, $hops, $isolate, $line) unless $_[1] eq $main::mycall;
1363 sub send_local_config
1371 dbg('DXProt::send_local_config') if isdbg('trace');
1374 if ($self->{isolate}) {
1375 @localnodes = ( $main::routeroot );
1377 # create a list of all the nodes that are not connected to this connection
1378 # and are not themselves isolated, this to make sure that isolated nodes
1379 # don't appear outside of this node
1380 my @dxchan = grep { $_->call ne $main::mycall && $_->call ne $self->{call} } DXChannel::get_all_nodes();
1381 @localnodes = map { my $r = Route::Node::get($_->{call}); $r ? $r : () } @dxchan if @dxchan;
1382 my @intcalls = map { $_->nodes } @localnodes if @localnodes;
1383 my $ref = Route::Node::get($self->{call});
1384 my @rnodes = $ref->nodes;
1385 for my $n (@intcalls) {
1386 push @remotenodes, Route::Node::get($n) unless grep $n eq $_, @rnodes;
1388 unshift @localnodes, $main::routeroot;
1391 send_route($self, \&pc19, scalar(@localnodes)+scalar(@remotenodes), @localnodes, @remotenodes);
1393 # get all the users connected on the above nodes and send them out
1394 foreach $n (@localnodes, @remotenodes) {
1396 send_route($self, \&pc16, 1, $n, map {my $r = Route::User::get($_); $r ? ($r) : ()} $n->users);
1398 dbg("sent a null value") if isdbg('chanerr');
1404 # route a message down an appropriate interface for a callsign
1406 # is called route(to, pcline);
1410 my ($self, $call, $line) = @_;
1412 if (ref $self && $call eq $self->{call}) {
1413 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
1417 # always send it down the local interface if available
1418 my $dxchan = DXChannel->get($call);
1420 my $cl = Route::get($call);
1421 $dxchan = $cl->dxchan if $cl;
1423 if (ref $self && $dxchan eq $self) {
1424 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
1430 my $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1432 $dxchan->send($routeit) unless $dxchan == $me;
1435 dbg("PCPROT: No route available, dropped") if isdbg('chanerr');
1439 # broadcast a message to all clusters taking into account isolation
1440 # [except those mentioned after buffer]
1443 my $s = shift; # the line to be rebroadcast
1444 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1445 my @dxchan = DXChannel::get_all_nodes();
1448 # send it if it isn't the except list and isn't isolated and still has a hop count
1449 foreach $dxchan (@dxchan) {
1450 next if grep $dxchan == $_, @except;
1451 next if $dxchan == $me;
1453 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
1454 $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit;
1458 # broadcast a message to all clusters ignoring isolation
1459 # [except those mentioned after buffer]
1460 sub broadcast_all_ak1a
1462 my $s = shift; # the line to be rebroadcast
1463 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1464 my @dxchan = DXChannel::get_all_nodes();
1467 # send it if it isn't the except list and isn't isolated and still has a hop count
1468 foreach $dxchan (@dxchan) {
1469 next if grep $dxchan == $_, @except;
1470 next if $dxchan == $me;
1472 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
1473 $dxchan->send($routeit);
1477 # broadcast to all users
1478 # storing the spot or whatever until it is in a state to receive it
1481 my $s = shift; # the line to be rebroadcast
1482 my $sort = shift; # the type of transmission
1483 my $fref = shift; # a reference to an object to filter on
1484 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1485 my @dxchan = DXChannel::get_all_users();
1489 foreach $dxchan (@dxchan) {
1490 next if grep $dxchan == $_, @except;
1493 broadcast_list($s, $sort, $fref, @out);
1496 # broadcast to a list of users
1504 foreach $dxchan (@_) {
1506 next if $dxchan == $me;
1508 if ($sort eq 'dx') {
1509 next unless $dxchan->{dx};
1510 ($filter) = $dxchan->{spotsfilter}->it(@{$fref}) if ref $fref;
1511 next unless $filter;
1513 next if $sort eq 'ann' && !$dxchan->{ann} && $s !~ /^To\s+LOCAL\s+de\s+(?:$main::myalias|$main::mycall)/i;
1514 next if $sort eq 'wwv' && !$dxchan->{wwv};
1515 next if $sort eq 'wcy' && !$dxchan->{wcy};
1516 next if $sort eq 'wx' && !$dxchan->{wx};
1518 $s =~ s/\a//og unless $dxchan->{beep};
1520 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1530 # obtain the hops from the list for this callsign and pc no
1536 my $hops = $DXProt::hopcount{$pcno};
1537 $hops = $DXProt::def_hopcount if !$hops;
1542 # adjust the hop count on a per node basis using the user loadable
1543 # hop table if available or else decrement an existing one
1550 my $call = $self->{call};
1553 if (($hops) = $s =~ /\^H(\d+)\^~?$/o) {
1554 my ($pcno) = $s =~ /^PC(\d\d)/o;
1555 confess "$call called adjust_hops with '$s'" unless $pcno;
1556 my $ref = $nodehops{$call} if %nodehops;
1558 my $newhops = $ref->{$pcno};
1559 return "" if defined $newhops && $newhops == 0;
1560 $newhops = $ref->{default} unless $newhops;
1561 return "" if defined $newhops && $newhops == 0;
1562 $newhops = $hops if !$newhops;
1563 $s =~ s/\^H(\d+)(\^~?)$/\^H$newhops$2/ if $newhops;
1565 # simply decrement it
1567 return "" if !$hops;
1568 $s =~ s/\^H(\d+)(\^~?)$/\^H$hops$2/ if $hops;
1580 return $self->msg('lh1') unless -e "$main::data/hop_table.pl";
1581 do "$main::data/hop_table.pl";
1587 # add a ping request to the ping queues
1590 my ($from, $to) = @_;
1591 my $ref = $pings{$to} || [];
1594 $r->{t} = [ gettimeofday ];
1595 route(undef, $to, pc51($to, $main::mycall, 1));
1602 my ($self, $tonode, $fromnode, $user, $cmd) = @_;
1603 if ($tonode eq $main::mycall) {
1604 my $ref = DXUser->get_current($fromnode);
1605 my $cref = Route::Node::get($fromnode);
1606 Log('rcmd', 'in', $ref->{priv}, $fromnode, $cmd);
1607 if ($cmd !~ /^\s*rcmd/i && $cref && $ref && $cref->call eq $ref->homenode) { # not allowed to relay RCMDS!
1608 if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
1609 $self->{remotecmd} = 1; # for the benefit of any command that needs to know
1610 my $oldpriv = $self->{priv};
1611 $self->{priv} = $ref->{priv}; # assume the user's privilege level
1612 my @in = (DXCommandmode::run_cmd($self, $cmd));
1613 $self->{priv} = $oldpriv;
1614 $self->send_rcmd_reply($main::mycall, $fromnode, $user, @in);
1615 delete $self->{remotecmd};
1617 $self->send_rcmd_reply($main::mycall, $fromnode, $user, "sorry...!");
1620 $self->send_rcmd_reply($main::mycall, $fromnode, $user, "your attempt is logged, Tut tut tut...!");
1623 my $ref = DXUser->get_current($tonode);
1624 if ($ref && $ref->is_clx) {
1625 $self->route($tonode, pc84($fromnode, $tonode, $user, $cmd));
1627 $self->route($tonode, pc34($fromnode, $tonode, $cmd));
1632 sub process_rcmd_reply
1634 my ($self, $tonode, $fromnode, $user, $line) = @_;
1635 if ($tonode eq $main::mycall) {
1636 my $s = $rcmds{$fromnode};
1638 my $dxchan = DXChannel->get($s->{call});
1639 my $ref = $user eq $tonode ? $dxchan : (DXChannel->get($user) || $dxchan);
1640 $ref->send($line) if $ref;
1641 delete $rcmds{$fromnode} if !$dxchan;
1643 # send unsolicited ones to the sysop
1644 my $dxchan = DXChannel->get($main::myalias);
1645 $dxchan->send($line) if $dxchan;
1648 my $ref = DXUser->get_current($tonode);
1649 if ($ref && $ref->is_clx) {
1650 $self->route($tonode, pc85($fromnode, $tonode, $user, $line));
1652 $self->route($tonode, pc35($fromnode, $tonode, $line));
1661 my $fromnode = shift;
1666 Log('rcmd', 'out', $fromnode, $line);
1667 if ($self->is_clx) {
1668 $self->send(pc85($main::mycall, $fromnode, $user, "$main::mycall:$line"));
1670 $self->send(pc35($main::mycall, $fromnode, "$main::mycall:$line"));
1675 # add a rcmd request to the rcmd queues
1678 my ($self, $to, $cmd) = @_;
1681 $r->{call} = $self->{call};
1682 $r->{t} = $main::systime;
1686 my $ref = Route::Node::get($to);
1687 my $dxchan = $ref->dxchan;
1688 if ($dxchan && $dxchan->is_clx) {
1689 route(undef, $to, pc84($main::mycall, $to, $self->{call}, $cmd));
1691 route(undef, $to, pc34($main::mycall, $to, $cmd));
1698 my $pc39flag = shift;
1699 my $call = $self->call;
1701 unless ($pc39flag && $pc39flag == 1) {
1702 $self->send_now("D", DXProt::pc39($main::mycall, $self->msg('disc1', "System Op")));
1706 my $node = Route::Node::get($call);
1709 @rout = $node->del_nodes; # at the next level
1710 @rout = $node->del($main::routeroot);
1713 # unbusy and stop and outgoing mail
1714 my $mref = DXMsg::get_busy($call);
1715 $mref->stop_msg($call) if $mref;
1717 # broadcast to all other nodes that all the nodes connected to via me are gone
1718 unless ($pc39flag && $pc39flag == 2) {
1719 $self->route_pc21(@rout) if @rout;
1722 # remove outstanding pings
1723 delete $pings{$call};
1725 # I was the last node visited
1726 $self->user->node($main::mycall);
1728 # send info to all logged in thingies
1729 $self->tell_login('logoutn');
1731 Log('DXProt', $call . " Disconnected");
1733 $self->SUPER::disconnect;
1738 # send a talk message to this thingy
1742 my ($self, $from, $to, $via, $line) = @_;
1744 $line =~ s/\^/\\5E/g; # remove any ^ characters
1745 $self->send(DXProt::pc10($from, $to, $via, $line));
1746 Log('talk', $self->call, $from, $via?$via:$main::mycall, $line);
1749 # send it if it isn't the except list and isn't isolated and still has a hop count
1750 # taking into account filtering and so on
1754 my $generate = shift;
1755 my $no = shift; # the no of things to filter on
1757 my ($filter, $hops);
1760 for (; @_ && $no; $no--) {
1763 if ($self->{routefilter}) {
1766 ($filter, $hops) = $self->{routefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq);
1770 dbg("DXPROT: $self->{call}/" . $r->call . " rejected by output filter") if isdbg('chanerr');
1773 dbg("was sent a null value") if isdbg('chanerr');
1780 foreach my $line (&$generate(@rin, @_)) {
1783 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1785 $routeit = adjust_hops($self, $line); # adjust its hop count by node name
1786 next unless $routeit;
1788 $self->send($routeit);
1796 my $generate = shift;
1797 my @dxchan = DXChannel::get_all_nodes();
1801 foreach $dxchan (@dxchan) {
1802 next if $dxchan == $self;
1803 next if $dxchan == $me;
1804 if ($dxchan->{routefilter}) {
1805 $dxchan->send_route($generate, @_);
1807 $dxchan->send_route($generate, @_) unless $self->{isolate} || $dxchan->{isolate};
1815 broadcast_route($self, \&pc16, 1, @_);
1821 broadcast_route($self, \&pc17, 1, @_);
1827 broadcast_route($self, \&pc19, scalar @_, @_);
1833 broadcast_route($self, \&pc21, scalar @_, @_);
1839 broadcast_route($self, \&pc24, 1, @_);
1845 broadcast_route($self, \&pc41, 1, @_);
1851 broadcast_route($self, \&pc50, 1, @_);
1858 my ($filter, $hops) = (1, 1);
1860 if ($self->{inroutefilter}) {
1861 ($filter, $hops) = $self->{inroutefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq);
1862 dbg("PCPROT: $self->{call}/" . $r->call . ' rejected by in_filter_route') if !$filter && isdbg('chanerr');
1872 $s =~ s/\^H\d\d?\^?\~?$//;
1873 return 1 if exists $eph{$s};
1874 $eph{$s} = $main::systime;
1882 while (($key, $val) = each %eph) {
1883 if ($key =~ m{$regex}) {
1893 while (($key, $val) = each %eph) {
1894 if ($main::systime - $val > 90) {