WIP RBN
[spider.git] / perl / DXUser.pm
1 #
2 # DX cluster user routines
3 #
4 # Copyright (c) 1998 - Dirk Koopman G1TLH
5 #
6 #
7 #
8
9 package DXUser;
10
11 use DXLog;
12 use DB_File;
13 use Data::Dumper;
14 use Fcntl;
15 use IO::File;
16 use DXDebug;
17 use DXUtil;
18 use LRU;
19 use File::Copy;
20
21 use strict;
22
23 use vars qw(%u $dbm $filename %valid $lastoperinterval $lasttime $lru $lrusize $tooold $v3);
24
25 %u = ();
26 $dbm = undef;
27 $filename = undef;
28 $lastoperinterval = 60*24*60*60;
29 $lasttime = 0;
30 $lrusize = 2000;
31 $tooold = 86400 * 365;          # this marks an old user who hasn't given enough info to be useful
32 $v3 = 0;
33 our $maxconnlist = 3;                   # remember this many connection time (duration) [start, end] pairs
34
35 # hash of valid elements and a simple prompt
36 %valid = (
37                   call => '0,Callsign',
38                   alias => '0,Real Callsign',
39                   name => '0,Name',
40                   qth => '0,Home QTH',
41                   lat => '0,Latitude,slat',
42                   long => '0,Longitude,slong',
43                   qra => '0,Locator',
44                   email => '0,E-mail Address,parray',
45                   priv => '9,Privilege Level',
46                   lastin => '0,Last Time in,cldatetime',
47                   passwd => '9,Password,yesno',
48                   passphrase => '9,Pass Phrase,yesno',
49                   addr => '0,Full Address',
50                   'sort' => '0,Type of User', # A - ak1a, U - User, S - spider cluster, B - BBS
51                   xpert => '0,Expert Status,yesno',
52                   bbs => '0,Home BBS',
53                   node => '0,Last Node',
54                   homenode => '0,Home Node',
55                   lockout => '9,Locked out?,yesno',     # won't let them in at all
56                   dxok => '9,Accept DX Spots?,yesno', # accept his dx spots?
57                   annok => '9,Accept Announces?,yesno', # accept his announces?
58                   lang => '0,Language',
59                   hmsgno => '0,Highest Msgno',
60                   group => '0,Group,parray',    # used to create a group of users/nodes for some purpose or other
61                   buddies => '0,Buddies,parray',
62                   isolate => '9,Isolate network,yesno',
63                   wantbeep => '0,Req Beep,yesno',
64                   wantann => '0,Req Announce,yesno',
65                   wantwwv => '0,Req WWV,yesno',
66                   wantwcy => '0,Req WCY,yesno',
67                   wantecho => '0,Req Echo,yesno',
68                   wanttalk => '0,Req Talk,yesno',
69                   wantwx => '0,Req WX,yesno',
70                   wantdx => '0,Req DX Spots,yesno',
71                   wantemail => '0,Req Msgs as Email,yesno',
72                   pagelth => '0,Current Pagelth',
73                   pingint => '9,Node Ping interval',
74                   nopings => '9,Ping Obs Count',
75                   wantlogininfo => '0,Login Info Req,yesno',
76           wantgrid => '0,Show DX Grid,yesno',
77                   wantann_talk => '0,Talklike Anns,yesno',
78                   wantpc16 => '9,Want Users from node,yesno',
79                   wantsendpc16 => '9,Send PC16,yesno',
80                   wantroutepc19 => '9,Route PC19,yesno',
81                   wantusstate => '0,Show US State,yesno',
82                   wantdxcq => '0,Show CQ Zone,yesno',
83                   wantdxitu => '0,Show ITU Zone,yesno',
84                   wantgtk => '0,Want GTK interface,yesno',
85                   wantpc9x => '0,Want PC9X interface,yesno',
86                   wantrbn => '0,Want RBN spots,yesno',
87                   wantft => '0,Want FT4/8 spots,yesno',
88                   wantcw => '0,Want (RBN) CW spots,yesno',
89                   lastoper => '9,Last for/oper,cldatetime',
90                   nothere => '0,Not Here Text',
91                   registered => '9,Registered?,yesno',
92                   prompt => '0,Required Prompt',
93                   version => '1,Version',
94                   build => '1,Build',
95                   believe => '1,Believable nodes,parray',
96                   lastping => '1,Last Ping at,ptimelist',
97                   maxconnect => '1,Max Connections',
98                   startt => '0,Start Time,cldatetime',
99                   connlist => '1,Connections,parraydifft',
100                  );
101
102 #no strict;
103 sub AUTOLOAD
104 {
105         no strict;
106         my $name = $AUTOLOAD;
107   
108         return if $name =~ /::DESTROY$/;
109         $name =~ s/^.*:://o;
110   
111         confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
112         # this clever line of code creates a subroutine which takes over from autoload
113         # from OO Perl - Conway
114         *$AUTOLOAD = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}};
115        goto &$AUTOLOAD;
116 }
117
118 #use strict;
119
120 #
121 # initialise the system
122 #
123 sub init
124 {
125         my $mode = shift;
126   
127         my $ufn;
128         my $convert;
129         
130         eval {
131                 require Storable;
132         };
133
134         my $fn = "users";
135         
136         if ($@) {
137                 $ufn = localdata("users.v2");
138                 $v3 = $convert = 0;
139                 dbg("the module Storable appears to be missing!!");
140                 dbg("trying to continue in compatibility mode (this may fail)");
141                 dbg("please install Storable from CPAN as soon as possible");
142         } else {
143                 import Storable qw(nfreeze thaw);
144
145                 $ufn = localdata("users.v3");
146                 $v3 = 1;
147                 $convert++ if -e localdata("users.v2") && !-e $ufn;
148         }
149         
150         if ($mode) {
151                 $dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open user file: $fn ($!) [rebuild it from user_asc?]";
152         } else {
153                 $dbm = tie (%u, 'DB_File', $ufn, O_RDONLY, 0666, $DB_BTREE) or confess "can't open user file: $fn ($!) [rebuild it from user_asc?]";
154         }
155
156         die "Cannot open $ufn ($!)\n" unless $dbm;
157
158         $lru = LRU->newbase("DXUser", $lrusize);
159         
160         # do a conversion if required
161         if ($dbm && $convert) {
162                 my ($key, $val, $action, $count, $err) = ('','',0,0,0);
163                 
164                 my %oldu;
165                 dbg("Converting the User File to V3 ");
166                 dbg("This will take a while, I suggest you go and have cup of strong tea");
167                 my $odbm = tie (%oldu, 'DB_File', localdata("users.v2"), O_RDONLY, 0666, $DB_BTREE) or confess "can't open user file: $fn.v2 ($!) [rebuild it from user_asc?]";
168         for ($action = R_FIRST; !$odbm->seq($key, $val, $action); $action = R_NEXT) {
169                         my $ref;
170                         eval { $ref = asc_decode($val) };
171                         unless ($@) {
172                                 if ($ref) {
173                                         $ref->put;
174                                         $count++;
175                                 } else {
176                                         $err++
177                                 }
178                         } else {
179                                 Log('err', "DXUser: error decoding $@");
180                         }
181                 } 
182                 undef $odbm;
183                 untie %oldu;
184                 dbg("Conversion completed $count records $err errors");
185         }
186         $filename = $ufn;
187 }
188
189 sub del_file
190 {
191         # with extreme prejudice
192         unlink "$main::data/users.v3";
193         unlink "$main::local_data/users.v3";
194 }
195
196 #
197 # periodic processing
198 #
199 sub process
200 {
201         if ($main::systime > $lasttime + 15) {
202                 $dbm->sync if $dbm;
203                 $lasttime = $main::systime;
204         }
205 }
206
207 #
208 # close the system
209 #
210
211 sub finish
212 {
213         undef $dbm;
214         untie %u;
215 }
216
217 #
218 # new - create a new user
219 #
220
221 sub alloc
222 {
223         my $pkg = shift;
224         my $call = uc shift;
225         my $self = bless {call => $call, 'sort'=>'U'}, $pkg;
226         return $self;
227 }
228
229 sub new
230 {
231         my $pkg = shift;
232         my $call = shift;
233         #  $call =~ s/-\d+$//o;
234   
235 #       confess "can't create existing call $call in User\n!" if $u{$call};
236
237         my $self = $pkg->alloc($call);
238         $self->put;
239         return $self;
240 }
241
242 #
243 # get - get an existing user - this seems to return a different reference everytime it is
244 #       called - see below
245 #
246
247 sub get
248 {
249         my $call = uc shift;
250         my $data;
251         
252         # is it in the LRU cache?
253         my $ref = $lru->get($call);
254         return $ref if $ref && ref $ref eq 'DXUser';
255         
256         # search for it
257         unless ($dbm->get($call, $data)) {
258                 eval { $ref = decode($data); };
259                 
260                 if ($ref) {
261                         if (!UNIVERSAL::isa($ref, 'DXUser')) {
262                                 dbg("DXUser::get: got strange answer from decode of $call". ref $ref. " ignoring");
263                                 return undef;
264                         }
265                         # we have a reference and it *is* a DXUser
266                 } else {
267                         if ($@) {
268                                 LogDbg('err', "DXUser::get decode error on $call '$@'");
269                         } else {
270                                 dbg("DXUser::get: no reference returned from decode of $call $!");
271                         }
272                         return undef;
273                 }
274                 $lru->put($call, $ref);
275                 return $ref;
276         }
277         return undef;
278 }
279
280 #
281 # get an existing either from the channel (if there is one) or from the database
282 #
283 # It is important to note that if you have done a get (for the channel say) and you
284 # want access or modify that you must use this call (and you must NOT use get's all
285 # over the place willy nilly!)
286 #
287
288 sub get_current
289 {
290         my $call = uc shift;
291   
292         my $dxchan = DXChannel::get($call);
293         if ($dxchan) {
294                 my $ref = $dxchan->user;
295                 return $ref if $ref && UNIVERSAL::isa($ref, 'DXUser');
296
297                 dbg("DXUser::get_current: got invalid user ref for $call from dxchan $dxchan->{call} ". ref $ref. " ignoring");
298         }
299         return get($call);
300 }
301
302 #
303 # get all callsigns in the database 
304 #
305
306 sub get_all_calls
307 {
308         return (sort keys %u);
309 }
310
311 #
312 # put - put a user
313 #
314
315 sub put
316 {
317         my $self = shift;
318         confess "Trying to put nothing!" unless $self && ref $self;
319         my $call = $self->{call};
320
321         $dbm->del($call);
322         delete $self->{annok} if $self->{annok};
323         delete $self->{dxok} if $self->{dxok};
324
325         $lru->put($call, $self);
326         my $ref = $self->encode;
327         $dbm->put($call, $ref);
328 }
329
330 # freeze the user
331 sub encode
332 {
333         goto &asc_encode unless $v3;
334         my $self = shift;
335         return nfreeze($self);
336 }
337
338 # thaw the user
339 sub decode
340 {
341         goto &asc_decode unless $v3;
342         my $ref;
343         $ref = thaw(shift);
344         return $ref;
345 }
346
347
348 # create a string from a user reference (in_ascii)
349 #
350 sub asc_encode
351 {
352         my $self = shift;
353         my $strip = shift;
354         my $p;
355
356         if ($strip) {
357                 my $ref = bless {}, ref $self;
358                 foreach my $k (qw(qth lat long qra sort call homenode node lastoper lastin)) {
359                         $ref->{$k} = $self->{$k} if exists $self->{$k};
360                 }
361                 $ref->{name} = $self->{name} if exists $self->{name} && $self->{name} !~ /selfspot/i;
362                 $p = dd($ref);
363         } else {
364                 $p = dd($self);
365         }
366         return $p;
367 }
368
369 #
370 # create a hash from a string (in ascii)
371 #
372 sub asc_decode
373 {
374         my $s = shift;
375         my $ref;
376         $s =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
377         eval '$ref = ' . $s;
378         if ($@) {
379                 LogDbg('err', "DXUser::asc_decode: on '$s' $@");
380                 $ref = undef;
381         }
382         return $ref;
383 }
384
385 #
386 # del - delete a user
387 #
388
389 sub del
390 {
391         my $self = shift;
392         my $call = $self->{call};
393         $lru->remove($call);
394         $dbm->del($call);
395 }
396
397 #
398 # close - close down a user
399 #
400
401 sub close
402 {
403         my $self = shift;
404         my $startt = shift;
405         my $ip = shift;
406         $self->{lastin} = $main::systime;
407         # add a record to the connect list
408         my $ref = [$startt || $self->{startt}, $main::systime];
409         push @$ref, $ip if $ip;
410         push @{$self->{connlist}}, $ref;
411         shift @{$self->{connlist}} if @{$self->{connlist}} > $maxconnlist;
412         $self->put();
413 }
414
415 #
416 # sync the database
417 #
418
419 sub sync
420 {
421         $dbm->sync;
422 }
423
424 #
425 # return a list of valid elements 
426
427
428 sub fields
429 {
430         return keys(%valid);
431 }
432
433
434 #
435 # export the database to an ascii file
436 #
437
438 sub export
439 {
440         my $name = shift || 'user_asc';
441         my $basic_info_only = shift;
442
443         my $fn = $name ne 'user_asc' ? $name : "$main::local_data/$name";                       # force use of local
444         
445         # save old ones
446         move "$fn.oooo", "$fn.ooooo" if -e "$fn.oooo";
447         move "$fn.ooo", "$fn.oooo" if -e "$fn.ooo";
448         move "$fn.oo", "$fn.ooo" if -e "$fn.oo";
449         move "$fn.o", "$fn.oo" if -e "$fn.o";
450         move "$fn", "$fn.o" if -e "$fn";
451
452         my $count = 0;
453         my $err = 0;
454         my $del = 0;
455         my $fh = new IO::File ">$fn" or return "cannot open $fn ($!)";
456         if ($fh) {
457                 my $key = 0;
458                 my $val = undef;
459                 my $action;
460                 my $t = scalar localtime;
461                 print $fh q{#!/usr/bin/perl
462 #
463 # The exported userfile for a DXSpider System
464 #
465 # Input file: $filename
466 #       Time: $t
467 #
468                         
469 package main;
470                         
471 # search local then perl directories
472 BEGIN {
473         umask 002;
474                                 
475         # root of directory tree for this system
476         $root = "/spider"; 
477         $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
478         
479         unshift @INC, "$root/perl";     # this IS the right way round!
480         unshift @INC, "$root/local";
481         
482         # try to detect a lockfile (this isn't atomic but 
483         # should do for now
484         $lockfn = "$root/local_data/cluster.lck";       # lock file name
485         if (-e $lockfn) {
486                 open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!";
487                 my $pid = <CLLOCK>;
488                 chomp $pid;
489                 die "Lockfile ($lockfn) and process $pid exists - cluster must be stopped first\n" if kill 0, $pid;
490                 close CLLOCK;
491         }
492 }
493
494 use SysVar;
495 use DXUser;
496
497 if (@ARGV) {
498         $main::userfn = shift @ARGV;
499         print "user filename now $userfn\n";
500 }
501
502 package DXUser;
503
504 del_file();
505 init(1);
506 %u = ();
507 my $count = 0;
508 my $err = 0;
509 while (<DATA>) {
510         chomp;
511         my @f = split /\t/;
512         my $ref = asc_decode($f[1]);
513         if ($ref) {
514                 $ref->put();
515                 $count++;
516         DXUser::sync() unless $count % 10000;
517         } else {
518                 print "# Error: $f[0]\t$f[1]\n";
519                 $err++
520         }
521 }
522 DXUser::sync(); DXUser::finish();
523 print "There are $count user records and $err errors\n";
524 };
525                 print $fh "__DATA__\n";
526
527         for ($action = R_FIRST; !$dbm->seq($key, $val, $action); $action = R_NEXT) {
528                         if (!is_callsign($key) || $key =~ /^0/) {
529                                 my $eval = $val;
530                                 my $ekey = $key;
531                                 $eval =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; 
532                                 $ekey =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; 
533                                 LogDbg('DXCommand', "Export Error1: $ekey\t$eval");
534                                 eval {$dbm->del($key)};
535                                 dbg(carp("Export Error1: $ekey\t$eval\n$@")) if $@;
536                                 ++$err;
537                                 next;
538                         }
539                         my $ref;
540                         eval {$ref = decode($val); };
541                         if ($ref) {
542                                 my $t = $ref->{lastin} || 0;
543                                 if ($ref->is_user && !$ref->{priv} && $main::systime > $t + $tooold) {
544                                         unless ($ref->{lat} && $ref->{long} || $ref->{qth} || $ref->{qra}) {
545                                                 eval {$dbm->del($key)};
546                                                 dbg(carp("Export Error2: $key\t$val\n$@")) if $@;
547                                                 LogDbg('DXCommand', "$ref->{call} deleted, too old");
548                                                 $del++;
549                                                 next;
550                                         }
551                                 }
552                                 # only store users that are reasonably active or have useful information
553                                 print $fh "$key\t" . $ref->asc_encode($basic_info_only) . "\n";
554                                 ++$count;
555                         } else {
556                                 LogDbg('DXCommand', "Export Error3: $key\t" . carp($val) ."\n$@");
557                                 eval {$dbm->del($key)};
558                                 dbg(carp("Export Error3: $key\t$val\n$@")) if $@;
559                                 ++$err;
560                         }
561                 } 
562         $fh->close;
563     }
564         my $s = qq{Exported users to $fn - $count Users $del Deleted $err Errors ('sh/log Export' for details)};
565         LogDbg('command', $s);
566         return $s;
567 }
568
569 #
570 # group handling
571 #
572
573 # add one or more groups
574 sub add_group
575 {
576         my $self = shift;
577         my $ref = $self->{group} || [ 'local' ];
578         $self->{group} = $ref if !$self->{group};
579         push @$ref, @_ if @_;
580 }
581
582 # remove one or more groups
583 sub del_group
584 {
585         my $self = shift;
586         my $ref = $self->{group} || [ 'local' ];
587         my @in = @_;
588         
589         $self->{group} = $ref if !$self->{group};
590         
591         @$ref = map { my $a = $_; return (grep { $_ eq $a } @in) ? () : $a } @$ref;
592 }
593
594 # does this thing contain all the groups listed?
595 sub union
596 {
597         my $self = shift;
598         my $ref = $self->{group};
599         my $n;
600         
601         return 0 if !$ref || @_ == 0;
602         return 1 if @$ref == 0 && @_ == 0;
603         for ($n = 0; $n < @_; ) {
604                 for (@$ref) {
605                         my $a = $_;
606                         $n++ if grep $_ eq $a, @_; 
607                 }
608         }
609         return $n >= @_;
610 }
611
612 # simplified group test just for one group
613 sub in_group
614 {
615         my $self = shift;
616         my $s = shift;
617         my $ref = $self->{group};
618         
619         return 0 if !$ref;
620         return grep $_ eq $s, $ref;
621 }
622
623 # set up a default group (only happens for them's that connect direct)
624 sub new_group
625 {
626         my $self = shift;
627         $self->{group} = [ 'local' ];
628 }
629
630 # set up empty buddies (only happens for them's that connect direct)
631 sub new_buddies
632 {
633         my $self = shift;
634         $self->{buddies} = [  ];
635 }
636
637 #
638 # return a prompt for a field
639 #
640
641 sub field_prompt
642
643         my ($self, $ele) = @_;
644         return $valid{$ele};
645 }
646
647 # some variable accessors
648 sub sort
649 {
650         my $self = shift;
651         @_ ? $self->{'sort'} = shift : $self->{'sort'} ;
652 }
653
654 # some accessors
655
656 # want is default = 1
657 sub _want
658 {
659         my $n = shift;
660         my $self = shift;
661         my $val = shift;
662         my $s = "want$n";
663         $self->{$s} = $val if defined $val;
664         return exists $self->{$s} ? $self->{$s} : 1;
665 }
666
667 # wantnot is default = 0
668 sub _wantnot
669 {
670         my $n = shift;
671         my $self = shift;
672         my $val = shift;
673         my $s = "want$n";
674         $self->{$s} = $val if defined $val;
675         return exists $self->{$s} ? $self->{$s} : 0;
676 }
677
678 sub wantbeep
679 {
680         return _want('beep', @_);
681 }
682
683 sub wantann
684 {
685         return _want('ann', @_);
686 }
687
688 sub wantwwv
689 {
690         return _want('wwv', @_);
691 }
692
693 sub wantwcy
694 {
695         return _want('wcy', @_);
696 }
697
698 sub wantecho
699 {
700         return _want('echo', @_);
701 }
702
703 sub wantwx
704 {
705         return _want('wx', @_);
706 }
707
708 sub wantdx
709 {
710         return _want('dx', @_);
711 }
712
713 sub wanttalk
714 {
715         return _want('talk', @_);
716 }
717
718 sub wantgrid
719 {
720         return _want('grid', @_);
721 }
722
723 sub wantemail
724 {
725         return _want('email', @_);
726 }
727
728 sub wantann_talk
729 {
730         return _want('ann_talk', @_);
731 }
732
733 sub wantpc16
734 {
735         return _want('pc16', @_);
736 }
737
738 sub wantsendpc16
739 {
740         return _want('sendpc16', @_);
741 }
742
743 sub wantroutepc16
744 {
745         return _want('routepc16', @_);
746 }
747
748 sub wantusstate
749 {
750         return _want('usstate', @_);
751 }
752
753 sub wantdxcq
754 {
755         return _want('dxcq', @_);
756 }
757
758 sub wantdxitu
759 {
760         return _want('dxitu', @_);
761 }
762
763 sub wantgtk
764 {
765         return _want('gtk', @_);
766 }
767
768 sub wantpc9x
769 {
770         return _want('pc9x', @_);
771 }
772
773 sub wantlogininfo
774 {
775         my $self = shift;
776         my $val = shift;
777         $self->{wantlogininfo} = $val if defined $val;
778         return $self->{wantlogininfo};
779 }
780
781 sub is_node
782 {
783         my $self = shift;
784         return $self->{sort} =~ /^[ACRSX]$/;
785 }
786
787 sub is_local_node
788 {
789         my $self = shift;
790         return grep $_ eq 'local_node', @{$self->{group}};
791 }
792
793 sub is_user
794 {
795         my $self = shift;
796         return $self->{sort} =~ /^[UW]$/;
797 }
798
799 sub is_web
800 {
801         my $self = shift;
802         return $self->{sort} eq 'W';
803 }
804
805 sub is_bbs
806 {
807         my $self = shift;
808         return $self->{sort} eq 'B';
809 }
810
811 sub is_spider
812 {
813         my $self = shift;
814         return $self->{sort} eq 'S';
815 }
816
817 sub is_clx
818 {
819         my $self = shift;
820         return $self->{sort} eq 'C';
821 }
822
823 sub is_dxnet
824 {
825         my $self = shift;
826         return $self->{sort} eq 'X';
827 }
828
829 sub is_arcluster
830 {
831         my $self = shift;
832         return $self->{sort} eq 'R';
833 }
834
835 sub is_ak1a
836 {
837         my $self = shift;
838         return $self->{sort} eq 'A';
839 }
840
841 sub is_rbn
842 {
843         my $self = shift;
844         return $self->{sort} eq 'N'
845 }
846
847 sub unset_passwd
848 {
849         my $self = shift;
850         delete $self->{passwd};
851 }
852
853 sub unset_passphrase
854 {
855         my $self = shift;
856         delete $self->{passphrase};
857 }
858
859 sub set_believe
860 {
861         my $self = shift;
862         my $call = uc shift;
863         $self->{believe} ||= [];
864         push @{$self->{believe}}, $call unless grep $_ eq $call, @{$self->{believe}};
865 }
866
867 sub unset_believe
868 {
869         my $self = shift;
870         my $call = uc shift;
871         if (exists $self->{believe}) {
872                 $self->{believe} = [grep {$_ ne $call} @{$self->{believe}}];
873                 delete $self->{believe} unless @{$self->{believe}};
874         }
875 }
876
877 sub believe
878 {
879         my $self = shift;
880         return exists $self->{believe} ? @{$self->{believe}} : ();
881 }
882
883 sub lastping
884 {
885         my $self = shift;
886         my $call = shift;
887         $self->{lastping} ||= {};
888         $self->{lastping} = {} unless ref $self->{lastping};
889         my $b = $self->{lastping};
890         $b->{$call} = shift if @_;
891         return $b->{$call};     
892 }
893 1;
894 __END__
895
896
897
898
899