add localhost client aliasing on spots and PC92A
[spider.git] / perl / DXChannel.pm
1 #
2 # module to manage channel lists & data
3 #
4 # This is the base class for all channel operations, which is everything to do 
5 # with input and output really.
6 #
7 # The instance variable in the outside world will be generally be called $dxchan
8 #
9 # This class is 'inherited' (if that is the goobledegook for what I am doing)
10 # by various other modules. The point to understand is that the 'instance variable'
11 # is in fact what normal people would call the state vector and all useful info
12 # about a connection goes in there.
13 #
14 # Another point to note is that a vector may contain a list of other vectors. 
15 # I have simply added another variable to the vector for 'simplicity' (or laziness
16 # as it is more commonly called)
17 #
18 # PLEASE NOTE - I am a C programmer using this as a method of learning perl
19 # firstly and OO about ninthly (if you don't like the design and you can't 
20 # improve it with better OO and thus make it smaller and more efficient, then tough). 
21 #
22 # Copyright (c) 1998-2016 - Dirk Koopman G1TLH
23 #
24 #
25 #
26 package DXChannel;
27
28 use Msg;
29 use DXM;
30 use DXUtil;
31 use DXVars;
32 use DXDebug;
33 use Filter;
34 use Prefix;
35 use Route;
36
37 use strict;
38 use vars qw(%channels %valid @ISA $count $maxerrors);
39
40 %channels = ();
41 $count = 0;
42
43 %valid = (
44                   'sort' => '5,Type of Channel',
45                   ann => '0,Want Announce,yesno',
46                   ann_talk => '0,Suppress Talk Anns,yesno',
47                   annfilter => '5,Ann Filt-out',
48                   badcount => '1,Bad Word Count',
49                   badip => '9,BAD IP address',
50                   beep => '0,Want Beeps,yesno',
51                   build => '1,Node Build',
52                   call => '0,Callsign',
53                   cluster => '5,Cluster data',
54                   conf => '0,In Conference?,yesno',
55                   conn => '9,Msg Conn ref',
56                   consort => '5,Connection Type',
57                   cq => '0,CQ Zone',
58                   delayed => '5,Delayed messages,parray',
59                   disconnecting => '9,Disconnecting,yesno',
60                   do_pc9x => '9,Handles PC9x,yesno',
61                   dx => '0,DX Spots,yesno',
62                   dxcc => '0,Country Code',
63                   edit => '7,Edit Function',
64                   enhanced => '5,Enhanced Client,yesno',
65                   errors => '9,Errors',
66                   func => '5,Function',
67                   group => '0,Access Group,parray',     # used to create a group of users/nodes for some purpose or other.
68                   gtk => '5,Using GTK,yesno',
69                   handle_xml => '9,Handles XML,yesno',
70                   here => '0,Here?,yesno',
71                   hostname => '0,Hostname',
72                   inannfilter => '5,Ann Filt-inp',
73                   inpc92filter => '5,PC92 Route Filt-inp',
74                   inqueue => '9,Input Queue,parray',
75                   inrbnfilter => '5,RBN Filt-inp',
76                   inroutefilter => '5,Route Filt-inp',
77                   inscript => '9,In a script,yesno',
78                   inspotsfilter => '5,Spot Filt-inp',
79                   inwcyfilter => '5,WCY Filt-inp',
80                   inwwvfilter => '5,WWV Filt-inp',
81                   isbasic => '9,Internal Connection', 
82                   isolate => '5,Isolate network,yesno',
83                   isslugged => '9,Still Slugged,yesno',
84                   itu => '0,ITU Zone',
85                   K => '9,Seen on PC92 K,yesno',
86                   lang => '0,Language',
87                   lastmsgpoll => '0,Last Msg Poll,atime',
88                   lastping => '5,Ping last sent,atime',
89                   lastread => '5,Last Msg Read',
90                   list => '9,Dep Chan List',
91                   loc => '9,Local Vars', # used by func to store local variables in
92                   logininfo => '9,Login info req,yesno',
93                   metric => '1,Route metric',
94                   name => '0,User Name',
95                   newroute => '1,New Style Routing,yesno',
96                   next_pc92_keepalive => '9,Next PC92 KeepAlive,atime',
97                   next_pc92_update => '9,Next PC92 Update,atime',
98                   nopings => '5,Ping Obs Count',
99                   oldstate => '5,Last State',
100                   outbound => '5,outbound?,yesno',
101                   pagedata => '9,Page Data Store',
102                   pagelth => '0,Page Length',
103                   passwd => '9,Passwd List,yesno',
104                   pc50_t => '5,Last PC50 Time,atime',
105                   pc92filter => '5,PC92 Route Filt-out',
106                   pingave => '0,Ping ave time',
107                   pingint => '5,Ping Interval ',
108                   pingtime => '5,Ping totaltime,parray',
109                   priv => '9,Privilege',
110                   prompt => '0,Required Prompt',
111                   rbnfilter => '5,RBN Filt-out',
112                   rbnseeme => '0,RBN See Me,yesno',
113                   redirect => '0,Redirect messages to',
114                   registered => '9,Registered?,yesno',
115                   remotecmd => '9,doing rcmd,yesno',
116                   route => '9,Route Data',
117                   routefilter => '5,Route Filt-out',
118                   senddbg => '8,Sending Debug,yesno',
119                   sluggedpcs => '9,Slugged PCxx Queue,parray',
120                   spotsfilter => '5,Spot Filt-out',
121                   startt => '0,Start Time,atime',
122                   state => '0,Current State',
123                   t => '9,Time,atime',
124                   talk => '0,Want Talk,yesno',
125                   talklist => '0,Talk List,parray',
126                   user => '9,DXUser ref',
127                   ve7cc => '0,VE7CC program special,yesno',
128                   verified => '9,Verified?,yesno',
129                   version => '1,Node Version',
130                   wcy => '0,Want WCY,yesno',
131                   wcyfilter => '5,WCY Filt-out',
132                   width => '0,Column Width',
133                   wwv => '0,Want WWV,yesno',
134                   wwvfilter => '5,WWV Filt-out',
135                   wx => '0,Want WX,yesno',                
136                  );
137
138 $maxerrors = 20;                                # the maximum number of concurrent errors allowed before disconnection
139
140 # object destruction
141 sub DESTROY
142 {
143         my $self = shift;
144         for (keys %$self) {
145                 if (ref($self->{$_})) {
146                         delete $self->{$_};
147                 }
148         }
149         dbg("DXChannel $self->{call} destroyed ($count)") if isdbg('chan');
150         $count--;
151 }
152
153 # create a new channel object [$obj = DXChannel->new($call, $msg_conn_obj, $user_obj)]
154 sub alloc
155 {
156         my ($pkg, $call, $conn, $user) = @_;
157         my $self = {};
158   
159         die "trying to create a duplicate channel for $call" if $channels{$call};
160         $self->{call} = $call;
161         $self->{priv} = 0;
162         $self->{conn} = $conn if defined $conn; # if this isn't defined then it must be a list
163         if (defined $user) {
164                 $self->{user} = $user;
165                 $self->{lang} = $user->lang;
166                 $user->new_group unless $user->group;
167                 $user->new_buddies unless $user->buddies;
168                 $self->{group} = $user->group;
169                 $self->{sort} = $user->sort;
170                 $self->{width} = $user->width;
171         }
172         $self->{startt} = $self->{t} = $main::systime;
173         $self->{state} = 0;
174         $self->{oldstate} = 0;
175         $self->{lang} = $main::lang if !$self->{lang};
176         $self->{func} = "";
177         $self->{width} ||=  80;
178
179         # add in all the dxcc, itu, zone info
180         my @dxcc = Prefix::extract($call);
181         if (@dxcc > 0) {
182                 $self->{dxcc} = $dxcc[1]->dxcc;
183                 $self->{itu} = $dxcc[1]->itu;
184                 $self->{cq} = $dxcc[1]->cq;
185         }
186         $self->{inqueue} = [];
187
188         if ($conn) {
189                 $self->{hostname} = $self->{conn}->peerhost;
190                 $self->{sockhost} = $self->{conn}->sockhost;
191         }
192
193         $count++;
194         dbg("DXChannel $self->{call} created ($count)") if isdbg('chan');
195         bless $self, $pkg; 
196         return $channels{$call} = $self;
197 }
198
199 # count errors and disconnect if too many
200 # this has to be here because it can come from rcmd (DXProt) as
201 # well as DXCommandmode.
202 sub _error_out
203 {
204         my $self = shift;
205         my $e = shift;
206         if (++$self->{errors} > $maxerrors) {
207                 $self->send($self->msg('e26'));
208                 $self->disconnect;
209                 return ();
210         } else {
211                 return ($self->msg($e));
212         }
213 }
214
215 # rebless this channel as something else
216 sub rebless
217 {
218         my $self = shift;
219         my $class = shift;
220         return $channels{$self->{call}} = bless $self, $class;
221 }
222
223 sub rec 
224 {
225         my ($self, $msg) = @_;
226         
227         # queue the message and the channel object for later processing
228         if (defined $msg) {
229                 push @{$self->{inqueue}}, $msg;
230         }
231         $self->process_one;
232 }
233
234 # obtain a channel object by callsign [$obj = DXChannel::get($call)]
235 sub get
236 {
237         my $call = shift;
238         return $channels{$call};
239 }
240
241 # obtain all the channel objects
242 sub get_all
243 {
244         return values(%channels);
245 }
246
247 #
248 # gimme all the ak1a nodes
249 #
250 sub get_all_nodes
251 {
252         my $ref;
253         my @out;
254         foreach $ref (values %channels) {
255                 push @out, $ref if $ref->is_node;
256         }
257         return @out;
258 }
259
260 # return a list of node calls
261 sub get_all_node_calls
262 {
263         my $ref;
264         my @out;
265         foreach $ref (values %channels) {
266                 push @out, $ref->{call} if $ref->is_node;
267         }
268         return @out;
269 }
270
271 # return a list of all users
272 sub get_all_users
273 {
274         my $ref;
275         my @out;
276         foreach $ref (values %channels) {
277                 push @out, $ref if $ref->is_user;
278         }
279         return @out;
280 }
281
282 # return a list of all user callsigns
283 sub get_all_user_calls
284 {
285         my $ref;
286         my @out;
287         foreach $ref (values %channels) {
288                 push @out, $ref->{call} if $ref->is_user;
289         }
290         return @out;
291 }
292
293 # obtain a channel object by searching for its connection reference
294 sub get_by_cnum
295 {
296         my ($pkg, $conn) = @_;
297         my $self;
298   
299         foreach $self (values(%channels)) {
300                 return $self if ($self->{conn} == $conn);
301         }
302         return undef;
303 }
304
305 # get rid of a channel object [$obj->del()]
306 sub del
307 {
308         my $self = shift;
309
310         $self->{group} = undef;         # belt and braces
311         delete $channels{$self->{call}};
312 }
313
314 # is it a bbs
315 sub is_bbs
316 {
317         return $_[0]->{sort} eq 'B';
318 }
319
320 sub is_node
321 {
322         return $_[0]->{sort} =~ /^[ACRSX]$/;
323 }
324 # is it an ak1a node ?
325 sub is_ak1a
326 {
327         return $_[0]->{sort} eq 'A';
328 }
329
330 # is it a user?
331 sub is_user
332 {
333         return $_[0]->{sort} =~ /^[UW]$/;
334 }
335
336 # is it a clx node
337 sub is_clx
338 {
339         return $_[0]->{sort} eq 'C';
340 }
341
342 # it is a Web connected user
343 sub is_web
344 {
345         return $_[0]->{sort} eq 'W';
346 }
347
348 # is it a spider node
349 sub is_spider
350 {
351         return $_[0]->{sort} eq 'S';
352 }
353
354 # is it a DXNet node
355 sub is_dxnet
356 {
357         return $_[0]->{sort} eq 'X';
358 }
359
360 # is it a ar-cluster node
361 sub is_arcluster
362 {
363         return $_[0]->{sort} eq 'R';
364 }
365
366 sub is_rbn
367 {
368         return $_[0]->{sort} eq 'N';
369 }
370
371 sub is_dslink
372 {
373         return $_[0]->{sort} eq 'L';
374 }
375
376 # for perl 5.004's benefit
377 sub sort
378 {
379         my $self = shift;
380         return @_ ? $self->{sort} = shift : $self->{sort} ;
381 }
382
383 # find out whether we are prepared to believe this callsign on this interface
384 sub is_believed
385 {
386         my $self = shift;
387         my $call = shift;
388         
389         return grep $call eq $_, $self->user->believe;
390 }
391
392 # handle out going messages, immediately without waiting for the select to drop
393 # this could, in theory, block
394 sub send_now
395 {
396         my $self = shift;
397         my $conn = $self->{conn};
398         return unless $conn;
399         my $sort = shift;
400         my $call = $self->{call};
401         
402         for (@_) {
403 #               chomp;
404         my @lines = split /\n/;
405                 for (@lines) {
406                         $conn->send_now("$sort$call|$_");
407                         # debug log it, but not if it is a log message
408                         dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
409                 }
410         }
411         $self->{t} = time;
412 }
413
414 #
415 # send later with letter (more control)
416 #
417
418 sub send_later
419 {
420         my $self = shift;
421         my $conn = $self->{conn};
422         return unless $conn;
423         my $sort = shift;
424         my $call = $self->{call};
425         
426         for (@_) {
427 #               chomp;
428         my @lines = split /\n/;
429                 for (@lines) {
430                         $conn->send_later("$sort$call|$_");
431                         # debug log it, but not if it is a log message
432                         dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
433                 }
434         }
435         $self->{t} = time;
436 }
437
438 #
439 # the normal output routine
440 #
441 sub send                                                # this is always later and always data
442 {
443         my $self = shift;
444         my $conn = $self->{conn};
445         return unless $conn;
446         my $call = $self->{call};
447
448         foreach my $l (@_) {
449                 for (ref $l ? @$l : $l) {
450                         my @lines = split /\n/;
451                         for (@lines) {
452                                 $conn->send_later("D$call|$_");
453                                 dbg("-> D $call $_") if isdbg('chan');
454                         }
455                 }
456         }
457         $self->{t} = $main::systime;
458 }
459
460 # send a file (always later)
461 sub send_file
462 {
463         my ($self, $fn) = @_;
464         my $call = $self->{call};
465         my $conn = $self->{conn};
466         my @buf;
467   
468         open(F, $fn) or die "can't open $fn for sending file ($!)";
469         @buf = <F>;
470         close(F);
471         $self->send(@buf);
472 }
473
474 # this will implement language independence (in time)
475 sub msg
476 {
477         my $self = shift;
478         return DXM::msg($self->{lang}, @_);
479 }
480
481 # stick a broadcast on the delayed queue (but only up to 20 items)
482 sub delay
483 {
484         my $self = shift;
485         my $s = shift;
486         
487         $self->{delayed} = [] unless $self->{delayed};
488         push @{$self->{delayed}}, $s;
489         if (@{$self->{delayed}} >= 20) {
490                 shift @{$self->{delayed}};   # lose oldest one
491         }
492 }
493
494 # change the state of the channel - lots of scope for debugging here :-)
495 sub state
496 {
497         my $self = shift;
498         if (@_) {
499                 $self->{oldstate} = $self->{state};
500                 $self->{state} = shift;
501                 $self->{func} = '' unless defined $self->{func};
502                 dbg("$self->{call} channel func $self->{func} state $self->{oldstate} -> $self->{state}\n") if isdbg('state');
503
504                 # if there is any queued up broadcasts then splurge them out here
505                 if ($self->{delayed} && ($self->{state} eq 'prompt' || $self->{state} eq 'talk')) {
506                         $self->send (@{$self->{delayed}});
507                         delete $self->{delayed};
508                 }
509         }
510         return $self->{state};
511 }
512
513 # disconnect this channel
514 sub disconnect
515 {
516         my $self = shift;
517         my $user = $self->{user};
518         
519         $user->close($self->{startt}, $self->{hostname}) if defined $user;
520         $self->{conn}->disconnect if $self->{conn};
521         $self->del();
522 }
523
524 #
525 # just close all the socket connections down without any fiddling about, cleaning, being
526 # nice to other processes and otherwise telling them what is going on.
527 #
528 # This is for the benefit of forked processes to prepare for starting new programs, they
529 # don't want or need all this baggage.
530 #
531
532 sub closeall
533 {
534         my $ref;
535         foreach $ref (values %channels) {
536                 $ref->{conn}->disconnect() if $ref->{conn};
537         }
538 }
539
540 #
541 # Tell all the users that we have come in or out (if they want to know)
542 #
543 sub tell_login
544 {
545         my ($self, $m, $call) = @_;
546         
547         $call ||= $self->{call};
548         
549         # send info to all logged in thingies
550         my @dxchan = get_all_users();
551         my $dxchan;
552         foreach $dxchan (@dxchan) {
553                 next if $dxchan == $self;
554                 next if $dxchan->{call} eq $main::mycall;
555                 $dxchan->send($dxchan->msg($m, $call)) if $dxchan->{logininfo};
556         }
557 }
558
559 #
560 # Tell all the users if a buddy is logged or out
561 #
562 sub tell_buddies
563 {
564         my ($self, $m, $call, $node) = @_;
565         
566         $call ||= $self->{call};
567         $call =~ s/-\d+$//;
568         $m .= 'n' if $node;
569         
570         # send info to all logged in thingies
571         my @dxchan = get_all_users();
572         my $dxchan;
573         foreach $dxchan (@dxchan) {
574                 next if $dxchan == $self;
575                 next if $dxchan->{call} eq $main::mycall;
576                 $dxchan->send($dxchan->msg($m, $call, $node)) if grep $_ eq $call, @{$dxchan->{user}->{buddies}} ;
577         }
578 }
579
580 # various access routines
581
582 #
583 # return a list of valid elements 
584
585
586 sub fields
587 {
588         return keys(%valid);
589 }
590
591 #
592 # return a prompt for a field
593 #
594
595 sub field_prompt
596
597         my ($self, $ele) = @_;
598         return $valid{$ele};
599 }
600
601 # take a standard input message and decode it into its standard parts
602 sub decode_input
603 {
604         my $dxchan = shift;
605         my $data = shift;
606         my ($sort, $call, $line) = $data =~ /^([A-Z])(#?[A-Z0-9\/\-]{3,25})\|(.*)$/;
607
608         my $chcall = (ref $dxchan) ? $dxchan->call : "UN.KNOWN";
609         
610         # the above regexp must work
611         unless (defined $sort && defined $call && defined $line) {
612 #               $data =~ s/([\x00-\x1f\x7f-\xff])/uc sprintf("%%%02x",ord($1))/eg;
613                 dbg("DUFF Line on $chcall: $data");
614                 return ();
615         }
616
617         if(ref($dxchan) && $call ne $chcall) {
618                 dbg("DUFF Line come in for $call on wrong channel $chcall");
619                 return();
620         }
621         
622         return ($sort, $call, $line);
623 }
624
625 # broadcast a message to all clusters taking into account isolation
626 # [except those mentioned after buffer]
627 sub broadcast_nodes
628 {
629         my $s = shift;                          # the line to be rebroadcast
630         my @except = @_;                        # to all channels EXCEPT these (dxchannel refs)
631         my @dxchan = get_all_nodes();
632         my $dxchan;
633         
634         # send it if it isn't the except list and isn't isolated and still has a hop count
635         foreach $dxchan (@dxchan) {
636                 next if grep $dxchan == $_, @except;
637                 next if $dxchan == $main::me;
638                 
639                 my $routeit = $dxchan->can('adjust_hops') ? $dxchan->adjust_hops($s) : $s;      # adjust its hop count by node name
640
641                 $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit;
642         }
643 }
644
645 # broadcast a message to all clusters ignoring isolation
646 # [except those mentioned after buffer]
647 sub broadcast_all_nodes
648 {
649         my $s = shift;                          # the line to be rebroadcast
650         my @except = @_;                        # to all channels EXCEPT these (dxchannel refs)
651         my @dxchan = get_all_nodes();
652         my $dxchan;
653         
654         # send it if it isn't the except list and isn't isolated and still has a hop count
655         foreach $dxchan (@dxchan) {
656                 next if grep $dxchan == $_, @except;
657                 next if $dxchan == $main::me;
658
659                 my $routeit = $dxchan->can('adjust_hops') ? $dxchan->adjust_hops($s) : $s;      # adjust its hop count by node name
660                 $dxchan->send($routeit);
661         }
662 }
663
664 # broadcast to all users
665 # storing the spot or whatever until it is in a state to receive it
666 sub broadcast_users
667 {
668         my $s = shift;                          # the line to be rebroadcast
669         my $sort = shift;           # the type of transmission
670         my $fref = shift;           # a reference to an object to filter on
671         my @except = @_;                        # to all channels EXCEPT these (dxchannel refs)
672         my @dxchan = get_all_users();
673         my $dxchan;
674         my @out;
675         
676         foreach $dxchan (@dxchan) {
677                 next if grep $dxchan == $_, @except;
678                 push @out, $dxchan;
679         }
680         broadcast_list($s, $sort, $fref, @out);
681 }
682
683
684 # broadcast to a list of users
685 sub broadcast_list
686 {
687         my $s = shift;
688         my $sort = shift;
689         my $fref = shift;
690         my $dxchan;
691         
692         foreach $dxchan (@_) {
693                 my $filter = 1;
694                 next if $dxchan == $main::me;
695                 
696                 if ($sort eq 'dx') {
697                     next unless $dxchan->{dx};
698                         ($filter) = $dxchan->{spotsfilter}->it($fref) if $dxchan->{spotsfilter} && ref $fref;
699                         next unless $filter;
700                 }
701                 next if $sort eq 'ann' && !$dxchan->{ann} && $s !~ /^To\s+LOCAL\s+de\s+(?:$main::myalias|$main::mycall)/i;
702                 next if $sort eq 'wwv' && !$dxchan->{wwv};
703                 next if $sort eq 'wcy' && !$dxchan->{wcy};
704                 next if $sort eq 'wx' && !$dxchan->{wx};
705
706                 $s =~ s/\a//og unless $dxchan->{beep};
707
708                 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
709                         $dxchan->send($s);      
710                 } else {
711                         $dxchan->delay($s);
712                 }
713         }
714 }
715
716 sub process_one
717 {
718         my $self = shift;
719
720         while (my $data = shift @{$self->{inqueue}}) {
721                 my ($sort, $call, $line) = $self->decode_input($data);
722                 next unless defined $sort;
723
724                 if ($sort ne 'D') {
725                         if (isdbg('chan')) {
726                                 if (($self->is_rbn && isdbg('rbnchan')) || !$self->is_rbn) {
727                                         dbg("<- $sort $call $line") if isdbg('chan'); # you may think this is tautology, but it's needed get the correct label on the debug line
728                                 }
729                         }
730                 }
731                 
732                 # handle A records
733                 my $user = $self->user;
734                 if ($sort eq 'I') {
735                         die "\$user not defined for $call" unless defined $user;
736                         
737                         # normal input
738                         $self->normal($line);
739                 } elsif ($sort eq 'G') {
740                         $self->enhanced($line);
741                 } elsif ($sort eq 'A' || $sort eq 'O' || $sort eq 'W') {
742                         $self->start($line, $sort);
743                 } elsif ($sort eq 'C') {
744                         $self->width($line); # change number of columns
745                 } elsif ($sort eq 'Z') {
746                         $self->disconnect;
747                 } elsif ($sort eq 'D') {
748                         ;                               # ignored (an echo)
749                 } else {
750                         dbg atime . " DXChannel::process_one: Unknown command letter ($sort) received from $call\n";
751                 }
752         }
753 }
754
755 sub process
756 {
757         foreach my $dxchan (values %channels) {
758                 next if $dxchan->{disconnecting};
759                 $dxchan->process_one;
760         }
761 }
762
763 sub handle_xml
764 {
765         my $self = shift;
766         my $r = 0;
767         
768         if (DXXml::available()) {
769                 $r = $self->{handle_xml} || 0;
770         } else {
771                 delete $self->{handle_xml} if exists $self->{handle_xml};
772         }
773         return $r;
774 }
775
776 sub error_handler
777 {
778         my $self = shift;
779         my $error = shift || '';
780         dbg("$self->{call} ERROR '$error', closing") if isdbg('chan');
781         $self->{conn}->set_error(undef) if exists $self->{conn};
782         $self->disconnect(1);
783 }
784
785 sub refresh_user
786 {
787         my $call = shift;
788         my $user = shift;
789         return unless $call && $user && ref $user;
790         my $self = DXChannel::get($call);
791         $self->{user} = $user;
792         return $user;
793 }
794
795 sub isregistered
796 {
797         my $self = shift;
798
799         # the sysop is registered!
800         return 1 if $self->{call} eq $main::myalias || $self->{call} eq $main::mycall;
801         
802         if ($main::reqreg) {
803                 return $self->{registered};
804         } else {
805                 return 1;
806         }
807 }
808
809 #no strict;
810 sub AUTOLOAD
811 {
812         no strict;
813         my $name = $AUTOLOAD;
814         return if $name =~ /::DESTROY$/;
815         $name =~ s/^.*:://o;
816   
817         confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
818
819         # this clever line of code creates a subroutine which takes over from autoload
820         # from OO Perl - Conway
821         *$AUTOLOAD = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}};
822         goto &$AUTOLOAD;
823 }
824
825
826 1;
827 __END__;