added IP address logging for connections
[spider.git] / perl / DXCommandmode.pm
1 #!/usr/bin/perl
2 #
3 # This module impliments the user facing command mode for a dx cluster
4 #
5 # Copyright (c) 1998 Dirk Koopman G1TLH
6 #
7 # $Id$
8
9
10 package DXCommandmode;
11
12 use POSIX;
13
14 @ISA = qw(DXChannel);
15
16 use DXUtil;
17 use DXChannel;
18 use DXUser;
19 use DXVars;
20 use DXDebug;
21 use DXM;
22 use DXLog;
23 use DXLogPrint;
24 use DXBearing;
25 use CmdAlias;
26 use Filter;
27 use Minimuf;
28 use DXDb;
29 use AnnTalk;
30 use WCY;
31 use Sun;
32 use Internet;
33
34 use strict;
35 use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug);
36
37 %Cache = ();                                    # cache of dynamically loaded routine's mod times
38 %cmd_cache = ();                                # cache of short names
39 $errstr = ();                                   # error string from eval
40 %aliases = ();                                  # aliases for (parts of) commands
41 $scriptbase = "$main::root/scripts"; # the place where all users start scripts go
42 $maxerrors = 20;                                # the maximum number of concurrent errors allowed before disconnection
43
44 use vars qw($VERSION $BRANCH);
45 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
46 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
47 $main::build += $VERSION;
48 $main::branch += $BRANCH;
49
50 #
51 # obtain a new connection this is derived from dxchannel
52 #
53
54 sub new 
55 {
56         my $self = DXChannel::alloc(@_);
57
58         # routing, this must go out here to prevent race condx
59         my $pkg = shift;
60         my $call = shift;
61         my @rout = $main::routeroot->add_user($call, Route::here(1));
62         DXProt::route_pc16($DXProt::me, $main::routeroot, @rout) if @rout;
63
64         return $self;
65 }
66
67 # this is how a a connection starts, you get a hello message and the motd with
68 # possibly some other messages asking you to set various things up if you are
69 # new (or nearly new and slacking) user.
70
71 sub start
72
73         my ($self, $line, $sort) = @_;
74         my $user = $self->{user};
75         my $call = $self->{call};
76         my $name = $user->{name};
77         
78         # log it
79         my $host = $self->{conn}->{peerhost} || "unknown";
80         Log('DXCommand', "$call connected from $host");
81
82         $self->{name} = $name ? $name : $call;
83         $self->send($self->msg('l2',$self->{name}));
84         $self->send_file($main::motd) if (-e $main::motd);
85         $self->state('prompt');         # a bit of room for further expansion, passwords etc
86         $self->{priv} = $user->priv || 0;
87         $self->{lang} = $user->lang || $main::lang || 'en';
88         $self->{pagelth} = $user->pagelth || 20;
89         $self->{priv} = 0 if $line =~ /^(ax|te)/; # set the connection priv to 0 - can be upgraded later
90         ($self->{width}) = $line =~ /width=(\d+)/;
91         $self->{width} = 80 unless $self->{width} && $self->{width} > 80;
92         $self->{consort} = $line;       # save the connection type
93         
94         # set some necessary flags on the user if they are connecting
95         $self->{beep} = $user->wantbeep;
96         $self->{ann} = $user->wantann;
97         $self->{wwv} = $user->wantwwv;
98         $self->{wcy} = $user->wantwcy;
99         $self->{talk} = $user->wanttalk;
100         $self->{wx} = $user->wantwx;
101         $self->{dx} = $user->wantdx;
102         $self->{logininfo} = $user->wantlogininfo;
103         $self->{here} = 1;
104
105         # get the filters
106         $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'user_default', 0);
107         $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'user_default', 0);
108         $self->{wcyfilter} = Filter::read_in('wcy', $call, 0) || Filter::read_in('wcy', 'user_default', 0);
109         $self->{annfilter} = Filter::read_in('ann', $call, 0) || Filter::read_in('ann', 'user_default', 0) ;
110
111         # clean up qra locators
112         my $qra = $user->qra;
113         $qra = undef if ($qra && !DXBearing::is_qra($qra));
114         unless ($qra) {
115                 my $lat = $user->lat;
116                 my $long = $user->long;
117                 $user->qra(DXBearing::lltoqra($lat, $long)) if (defined $lat && defined $long);  
118         }
119
120         # send prompts and things
121         my $info = Route::cluster();
122         $self->send("Cluster:$info");
123         $self->send($self->msg('namee1')) if !$user->name;
124         $self->send($self->msg('qthe1')) if !$user->qth;
125         $self->send($self->msg('qll')) if !$user->qra || (!$user->lat && !$user->long);
126         $self->send($self->msg('hnodee1')) if !$user->qth;
127         $self->send($self->msg('m9')) if DXMsg::for_me($call);
128         $self->prompt;
129
130         # decide on echo
131         if (!$user->wantecho) {
132                 $self->send_now('E', "0");
133                 $self->send($self->msg('echow'));
134         }
135         
136         $self->tell_login('loginu');
137         
138         # do we need to send a forward/opernam?
139         my $lastoper = $user->lastoper || 0;
140         my $homenode = $user->homenode || ""; 
141         if ($homenode eq $main::mycall && $lastoper + $DXUser::lastoperinterval < $main::systime) {
142                 run_cmd($DXProt::me, "forward/opernam $call");
143                 $user->lastoper($main::systime);
144         }
145 }
146
147 #
148 # This is the normal command prompt driver
149 #
150
151 sub normal
152 {
153         my $self = shift;
154         my $cmdline = shift;
155         my @ans;
156         
157         # remove leading and trailing spaces
158         $cmdline =~ s/^\s*(.*)\s*$/$1/;
159         
160         if ($self->{state} eq 'page') {
161                 my $i = $self->{pagelth};
162                 my $ref = $self->{pagedata};
163                 my $tot = @$ref;
164                 
165                 # abort if we get a line starting in with a
166                 if ($cmdline =~ /^a/io) {
167                         undef $ref;
168                         $i = 0;
169                 }
170         
171                 # send a tranche of data
172                 while ($i-- > 0 && @$ref) {
173                         my $line = shift @$ref;
174                         $line =~ s/\s+$//o;     # why am having to do this? 
175                         $self->send($line);
176                 }
177                 
178                 # reset state if none or else chuck out an intermediate prompt
179                 if ($ref && @$ref) {
180                         $tot -= $self->{pagelth};
181                         $self->send($self->msg('page', $tot));
182                 } else {
183                         $self->state('prompt');
184                 }
185         } elsif ($self->{state} eq 'sysop') {
186                 my $passwd = $self->{user}->passwd;
187                 my @pw = split / */, $passwd;
188                 if ($passwd) {
189                         my @l = @{$self->{passwd}};
190                         my $str = "$pw[$l[0]].*$pw[$l[1]].*$pw[$l[2]].*$pw[$l[3]].*$pw[$l[4]]";
191                         if ($cmdline =~ /$str/) {
192                                 $self->{priv} = $self->{user}->priv;
193                         } else {
194                                 $self->send($self->msg('sorry'));
195                         }
196                 } else {
197                         $self->send($self->msg('sorry'));
198                 }
199                 delete $self->{passwd};
200                 $self->state('prompt');
201         } elsif ($self->{state} eq 'talk') {
202                 if ($cmdline =~ m{^(?:/EX|/ABORT)}i) {
203                         for (@{$self->{talklist}}) {
204                                 $self->send_talks($_,  $self->msg('talkend'));
205                         }
206                         $self->state('prompt');
207                         delete $self->{talklist};
208                 } elsif ($cmdline =~ m(^/\w+)) {
209                         $cmdline =~ s(^/)();
210                         $self->send_ans(run_cmd($self, $cmdline));
211                         $self->send($self->talk_prompt);
212                 } elsif ($self->{talklist} && @{$self->{talklist}}) {
213                         # send what has been said to whoever is in this person's talk list
214                         for (@{$self->{talklist}}) {
215                                 $self->send_talks($_, $cmdline);
216                         }
217                         $self->send($self->talk_prompt) if $self->{state} eq 'talk';
218                 } else {
219                         # for safety
220                         $self->state('prompt');
221                 }
222         } else {
223                 $self->send_ans(run_cmd($self, $cmdline));
224         } 
225         
226         # send a prompt only if we are in a prompt state
227         $self->prompt() if $self->{state} =~ /^prompt/o;
228 }
229
230 # send out the talk messages taking into account vias and connectivity
231 sub send_talks
232 {
233         my ($self, $ent, $line) = @_;
234         
235         my ($to, $via) = $ent =~ /(\S+)>(\S+)/;
236         $to = $ent unless $to;
237         my $call = $via ? $via : $to;
238         my $clref = Route::get($call);
239         my $dxchan = $clref->dxchan if $clref;
240         if ($dxchan) {
241                 $dxchan->talk($self->{call}, $to, $via, $line);
242         } else {
243                 $self->send($self->msg('disc2', $via ? $via : $to));
244                 my @l = grep { $_ ne $ent } @{$self->{talklist}};
245                 if (@l) {
246                         $self->{talklist} = \@l;
247                 } else {
248                         delete $self->{talklist};
249                         $self->state('prompt');
250                 }
251         }
252 }
253
254 sub talk_prompt
255 {
256         my $self = shift;
257         my @call;
258         for (@{$self->{talklist}}) {
259                 my ($to, $via) = /(\S+)>(\S+)/;
260                 $to = $_ unless $to;
261                 push @call, $to;
262         }
263         return $self->msg('talkprompt', join(',', @call));
264 }
265
266 #
267 # send a load of stuff to a command user with page prompting
268 # and stuff
269 #
270
271 sub send_ans
272 {
273         my $self = shift;
274         
275         if ($self->{pagelth} && @_ > $self->{pagelth}) {
276                 my $i;
277                 for ($i = $self->{pagelth}; $i-- > 0; ) {
278                         my $line = shift @_;
279                         $line =~ s/\s+$//o;     # why am having to do this? 
280                         $self->send($line);
281                 }
282                 $self->{pagedata} =  [ @_ ];
283                 $self->state('page');
284                 $self->send($self->msg('page', scalar @_));
285         } else {
286                 for (@_) {
287                         if (defined $_) {
288                                 $self->send($_);
289                         } else {
290                                 $self->send('');
291                         }
292                 }
293         } 
294 }
295
296 # this is the thing that runs the command, it is done like this for the 
297 # benefit of remote command execution
298 #
299
300 sub run_cmd
301 {
302         my $self = shift;
303         my $user = $self->{user};
304         my $call = $self->{call};
305         my $cmdline = shift;
306         my @ans;
307         
308         if ($self->{func}) {
309                 my $c = qq{ \@ans = $self->{func}(\$self, \$cmdline) };
310                 dbg("stored func cmd = $c\n") if isdbg('eval');
311                 eval  $c;
312                 if ($@) {
313                         return ("Syserr: Eval err $errstr on stored func $self->{func}", $@);
314                 }
315         } else {
316
317                 return () if length $cmdline == 0;
318                 
319                 # strip out //
320                 $cmdline =~ s|//|/|og;
321                 
322                 # split the command line up into parts, the first part is the command
323                 my ($cmd, $args) = split /\s+/, $cmdline, 2;
324                 $args = "" unless defined $args;
325                 
326                 if ($cmd) {
327                         
328                         my ($path, $fcmd);
329                         
330                         dbg("cmd: $cmd") if isdbg('command');
331                         
332                         # alias it if possible
333                         my $acmd = CmdAlias::get_cmd($cmd);
334                         if ($acmd) {
335                                 ($cmd, $args) = split /\s+/, "$acmd $args", 2;
336                                 $args = "" unless defined $args;
337                                 dbg("aliased cmd: $cmd $args") if isdbg('command');
338                         }
339                         
340                         # first expand out the entry to a command
341                         ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
342                         ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
343
344                         if ($path && $cmd) {
345                                 dbg("path: $cmd cmd: $fcmd") if isdbg('command');
346                         
347                                 my $package = find_cmd_name($path, $fcmd);
348                                 @ans = (0) if !$package ;
349                                 
350                                 if ($package) {
351                                         dbg("package: $package") if isdbg('command');
352                                         my $c;
353                                         unless (exists $Cache{$package}->{'sub'}) {
354                                                 $c = eval $Cache{$package}->{'eval'};
355                                                 if ($@) {
356                                                         return DXDebug::shortmess($@);
357                                                 }
358                                                 $Cache{$package}->{'sub'} = $c;
359                                         }
360                                         $c = $Cache{$package}->{'sub'};
361                                         eval {
362                                                 @ans = &{$c}($self, $args);
363                                     };
364                                         
365                                         if ($@) {
366                                                 #cluck($@);
367                                                 return (DXDebug::shortmess($@));
368                                         };
369                                 }
370                         } else {
371                                 dbg("cmd: $cmd not found") if isdbg('command');
372                                 if (++$self->{errors} > $maxerrors) {
373                                         $self->send($self->msg('e26'));
374                                         $self->disconnect;
375                                         return ();
376                                 } else {
377                                         return ($self->msg('e1'));
378                                 }
379                         }
380                 }
381         }
382         
383         my $ok = shift @ans;
384         if ($ok) {
385                 delete $self->{errors};
386         } else {
387                 if (++$self->{errors} > $maxerrors) {
388                         $self->send($self->msg('e26'));
389                         $self->disconnect;
390                         return ();
391                 }
392         }
393         return (@ans);
394 }
395
396 #
397 # This is called from inside the main cluster processing loop and is used
398 # for despatching commands that are doing some long processing job
399 #
400 sub process
401 {
402         my $t = time;
403         my @dxchan = DXChannel->get_all();
404         my $dxchan;
405         
406         foreach $dxchan (@dxchan) {
407                 next if $dxchan->sort ne 'U';  
408                 
409                 # send a prompt if no activity out on this channel
410                 if ($t >= $dxchan->t + $main::user_interval) {
411                         $dxchan->prompt() if $dxchan->{state} =~ /^prompt/o;
412                         $dxchan->t($t);
413                 }
414         }
415
416         while (my ($k, $v) = each %nothereslug) {
417                 if ($main::systime >= $v + 300) {
418                         delete $nothereslug{$k};
419                 }
420         }
421 }
422
423 #
424 # finish up a user context
425 #
426 sub disconnect
427 {
428         my $self = shift;
429         my $call = $self->call;
430
431         return if $self->{disconnecting}++;
432
433         delete $self->{senddbg};
434
435         my $uref = Route::User::get($call);
436         my @rout;
437         if ($uref) {
438                 @rout = $main::routeroot->del_user($uref);
439                 dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route');
440         } else {
441                 confess "trying to disconnect a non existant user $call";
442         }
443
444         # issue a pc17 to everybody interested
445         DXProt::route_pc17($DXProt::me, $main::routeroot, @rout) if @rout;
446
447         # I was the last node visited
448     $self->user->node($main::mycall);
449                 
450         # send info to all logged in thingies
451         $self->tell_login('logoutu');
452
453         Log('DXCommand', "$call disconnected");
454
455         $self->SUPER::disconnect;
456 }
457
458 #
459 # short cut to output a prompt
460 #
461
462 sub prompt
463 {
464         my $self = shift;
465         $self->send($self->msg($self->here ? 'pr' : 'pr2', $self->call, cldate($main::systime), ztime($main::systime)));
466 }
467
468 # broadcast a message to all users [except those mentioned after buffer]
469 sub broadcast
470 {
471         my $pkg = shift;                        # ignored
472         my $s = shift;                          # the line to be rebroadcast
473         
474     foreach my $dxchan (DXChannel->get_all()) {
475                 next unless $dxchan->{sort} eq 'U'; # only interested in user channels  
476                 next if grep $dxchan == $_, @_;
477                 $dxchan->send($s);                      # send it
478         }
479 }
480
481 # gimme all the users
482 sub get_all
483 {
484         return grep {$_->{sort} eq 'U'} DXChannel->get_all();
485 }
486
487 # run a script for this user
488 sub run_script
489 {
490         my $self = shift;
491         my $silent = shift || 0;
492         
493 }
494
495 #
496 # search for the command in the cache of short->long form commands
497 #
498
499 sub search
500 {
501         my ($path, $short_cmd, $suffix) = @_;
502         my ($apath, $acmd);
503         
504         # commands are lower case
505         $short_cmd = lc $short_cmd;
506         dbg("command: $path $short_cmd\n") if isdbg('command');
507
508         # do some checking for funny characters
509         return () if $short_cmd =~ /\/$/;
510
511         # return immediately if we have it
512         ($apath, $acmd) = split ',', $cmd_cache{$short_cmd} if $cmd_cache{$short_cmd};
513         if ($apath && $acmd) {
514                 dbg("cached $short_cmd = ($apath, $acmd)\n") if isdbg('command');
515                 return ($apath, $acmd);
516         }
517         
518         # if not guess
519         my @parts = split '/', $short_cmd;
520         my $dirfn;
521         my $curdir = $path;
522         my $p;
523         my $i;
524         my @lparts;
525         
526         for ($i = 0; $i < @parts; $i++) {
527                 my  $p = $parts[$i];
528                 opendir(D, $curdir) or confess "can't open $curdir $!";
529                 my @ls = readdir D;
530                 closedir D;
531                 my $l;
532                 foreach $l (sort @ls) {
533                         next if $l =~ /^\./;
534                         if ($i < $#parts) {             # we are dealing with directories
535                                 if ((-d "$curdir/$l") && $p eq substr($l, 0, length $p)) {
536                                         dbg("got dir: $curdir/$l\n") if isdbg('command');
537                                         $dirfn .= "$l/";
538                                         $curdir .= "/$l";
539                                         last;
540                                 }
541                         } else {                        # we are dealing with commands
542                                 @lparts = split /\./, $l;                  
543                                 next if $lparts[$#lparts] ne $suffix;        # only look for .$suffix files
544                                 if ($p eq substr($l, 0, length $p)) {
545                                         pop @lparts; #  remove the suffix
546                                         $l = join '.', @lparts;
547                                         #                 chop $dirfn;               # remove trailing /
548                                         $dirfn = "" unless $dirfn;
549                                         $cmd_cache{"$short_cmd"} = join(',', ($path, "$dirfn$l")); # cache it
550                                         dbg("got path: $path cmd: $dirfn$l\n") if isdbg('command');
551                                         return ($path, "$dirfn$l"); 
552                                 }
553                         }
554                 }
555         }
556         return ();  
557 }  
558
559 # clear the command name cache
560 sub clear_cmd_cache
561 {
562         %cmd_cache = ();
563 }
564
565 #
566 # the persistant execution of things from the command directories
567 #
568 #
569 # This allows perl programs to call functions dynamically
570
571 # This has been nicked directly from the perlembed pages
572 #
573
574 #require Devel::Symdump;  
575
576 sub valid_package_name {
577         my($string) = @_;
578         $string =~ s/([^A-Za-z0-9\/])/sprintf("_%2x",unpack("C",$1))/eg;
579         
580         #second pass only for words starting with a digit
581         $string =~ s|/(\d)|sprintf("/_%2x",unpack("C",$1))|eg;
582         
583         #Dress it up as a real package name
584         $string =~ s/\//_/og;
585         return $string;
586 }
587
588 # find a cmd reference
589 # this is really for use in user written stubs
590 #
591 # use the result as a symbolic reference:-
592 #
593 # no strict 'refs';
594 # @out = &$r($self, $line);
595 #
596 sub find_cmd_ref
597 {
598         my $cmd = shift;
599         my $r;
600         
601         if ($cmd) {
602                 
603                 # first expand out the entry to a command
604                 my ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
605                 ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
606                 
607                 # make sure it is loaded
608                 $r = find_cmd_name($path, $fcmd);
609         }
610         return $r;
611 }
612
613
614 # this bit of magic finds a command in the offered directory
615 sub find_cmd_name {
616         my $path = shift;
617         my $cmdname = shift;
618         my $package = valid_package_name($cmdname);
619         my $filename = "$path/$cmdname.pl";
620         my $mtime = -M $filename;
621         
622         # return if we can't find it
623         $errstr = undef;
624         unless (defined $mtime) {
625                 $errstr = DXM::msg('e1');
626                 return undef;
627         }
628         
629         if(defined $Cache{$package}->{mtime} &&$Cache{$package}->{mtime} <= $mtime) {
630                 #we have compiled this subroutine already,
631                 #it has not been updated on disk, nothing left to do
632                 #print STDERR "already compiled $package->handler\n";
633                 ;
634         } else {
635
636                 my $sub = readfilestr($filename);
637                 unless ($sub) {
638                         $errstr = "Syserr: can't open '$filename' $!";
639                         return undef;
640                 };
641                 
642                 #wrap the code into a subroutine inside our unique package
643                 my $eval = qq( sub { $sub } );
644                 
645                 if (isdbg('eval')) {
646                         my @list = split /\n/, $eval;
647                         my $line;
648                         for (@list) {
649                                 dbg($_ . "\n") if isdbg('eval');
650                         }
651                 }
652                 
653                 $Cache{$package} = {mtime => $mtime, 'eval' => $eval };
654         }
655
656         return $package;
657 }
658
659 sub local_send
660 {
661         my ($self, $let, $buf) = @_;
662         if ($self->{state} eq 'prompt' || $self->{state} eq 'talk') {
663                 if ($self->{enhanced}) {
664                         $self->send_later($let, $buf);
665                 } else {
666                         $self->send($buf);
667                 }
668         } else {
669                 $self->delay($buf);
670         }
671 }
672
673 # send a talk message here
674 sub talk
675 {
676         my ($self, $from, $to, $via, $line) = @_;
677         $line =~ s/\\5E/\^/g;
678         $self->local_send('T', "$to de $from: $line") if $self->{talk};
679         Log('talk', $to, $from, $main::mycall, $line);
680         # send a 'not here' message if required
681         unless ($self->{here} && $from ne $to) {
682                 my $key = "$to$from";
683                 unless (exists $nothereslug{$key}) {
684                         my ($ref, $dxchan);
685                         if (($ref = Route::get($from)) && ($dxchan = $ref->dxchan)) {
686                                 my $name = $self->user->name || $to;
687                                 my $s = $self->user->nothere || $dxchan->msg('nothere', $name);
688                                 $nothereslug{$key} = $main::systime;
689                                 $dxchan->talk($to, $from, undef, $s);
690                         }
691                 }
692         }
693 }
694
695 # send an announce
696 sub announce
697 {
698         my $self = shift;
699         my $line = shift;
700         my $isolate = shift;
701         my $to = shift;
702         my $target = shift;
703         my $text = shift;
704         my ($filter, $hops);
705
706         if ($self->{annfilter}) {
707                 ($filter, $hops) = $self->{annfilter}->it(@_ );
708                 return unless $filter;
709         }
710
711         unless ($self->{ann}) {
712                 return if $_[0] ne $main::myalias && $_[0] ne $main::mycall;
713         }
714         return if $target eq 'SYSOP' && $self->{priv} < 5;
715         my $buf = "$to$target de $_[0]: $text";
716         $buf =~ s/\%5E/^/g;
717         $buf .= "\a\a" if $self->{beep};
718         $self->local_send($target eq 'WX' ? 'W' : 'N', $buf);
719 }
720
721 # send a dx spot
722 sub dx_spot
723 {
724         my $self = shift;
725         my $line = shift;
726         my $isolate = shift;
727         my ($filter, $hops);
728
729         return unless $self->{dx};
730         
731         if ($self->{spotsfilter}) {
732                 ($filter, $hops) = $self->{spotsfilter}->it(@_ );
733                 return unless $filter;
734         }
735
736         my $buf = Spot::formatb($self->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]);
737         $buf .= "\a\a" if $self->{beep};
738         $buf =~ s/\%5E/^/g;
739         $self->local_send('X', $buf);
740 }
741
742 sub wwv
743 {
744         my $self = shift;
745         my $line = shift;
746         my $isolate = shift;
747         my ($filter, $hops);
748
749         return unless $self->{wwv};
750         
751         if ($self->{wwvfilter}) {
752                 ($filter, $hops) = $self->{wwvfilter}->it(@_ );
753                 return unless $filter;
754         }
755
756         my $buf = "WWV de $_[6] <$_[1]>:   SFI=$_[2], A=$_[3], K=$_[4], $_[5]";
757         $buf .= "\a\a" if $self->{beep};
758         $self->local_send('V', $buf);
759 }
760
761 sub wcy
762 {
763         my $self = shift;
764         my $line = shift;
765         my $isolate = shift;
766         my ($filter, $hops);
767
768         return unless $self->{wcy};
769         
770         if ($self->{wcyfilter}) {
771                 ($filter, $hops) = $self->{wcyfilter}->it(@_ );
772                 return unless $filter;
773         }
774
775         my $buf = "WCY de $_[10] <$_[1]> : K=$_[4] expK=$_[5] A=$_[3] R=$_[6] SFI=$_[2] SA=$_[7] GMF=$_[8] Au=$_[9]";
776         $buf .= "\a\a" if $self->{beep};
777         $self->local_send('Y', $buf);
778 }
779
780 # broadcast debug stuff to all interested parties
781 sub broadcast_debug
782 {
783         my $s = shift;                          # the line to be rebroadcast
784         
785         foreach my $dxchan (DXChannel->get_all) {
786                 next unless $dxchan->{enhanced} && $dxchan->{senddbg};
787                 $dxchan->send_later('L', $s);
788         }
789 }
790
791
792 1;
793 __END__