projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix show/dxcc
[spider.git]
/
perl
/
DXUser.pm
diff --git
a/perl/DXUser.pm
b/perl/DXUser.pm
index a2617a31884d80dd632c4193dba45928e9a8d4ee..0b72a680f363a4bbcf45f6912217c110ccec5f6b 100644
(file)
--- a/
perl/DXUser.pm
+++ b/
perl/DXUser.pm
@@
-20,17
+20,17
@@
use File::Copy;
use strict;
use strict;
-use vars qw(%u $dbm $filename %valid $lastoperinterval $lasttime $lru $lrusize $tooold $v3
$noips
);
+use vars qw(%u $dbm $filename %valid $lastoperinterval $lasttime $lru $lrusize $tooold $v3);
%u = ();
$dbm = undef;
$filename = undef;
$lastoperinterval = 60*24*60*60;
$lasttime = 0;
%u = ();
$dbm = undef;
$filename = undef;
$lastoperinterval = 60*24*60*60;
$lasttime = 0;
-$lrusize =
2
000;
+$lrusize =
10
000;
$tooold = 86400 * 365; # this marks an old user who hasn't given enough info to be useful
$v3 = 0;
$tooold = 86400 * 365; # this marks an old user who hasn't given enough info to be useful
$v3 = 0;
-$noips = 4;
+our $maxconnlist = 3; # remember this many connection time (duration) [start, end] pairs
# hash of valid elements and a simple prompt
%valid = (
# hash of valid elements and a simple prompt
%valid = (
@@
-44,6
+44,7
@@
$noips = 4;
email => '0,E-mail Address,parray',
priv => '9,Privilege Level',
lastin => '0,Last Time in,cldatetime',
email => '0,E-mail Address,parray',
priv => '9,Privilege Level',
lastin => '0,Last Time in,cldatetime',
+ lastseen => '0,Last Seen,cldatetime',
passwd => '9,Password,yesno',
passphrase => '9,Pass Phrase,yesno',
addr => '0,Full Address',
passwd => '9,Password,yesno',
passphrase => '9,Pass Phrase,yesno',
addr => '0,Full Address',
@@
-83,6
+84,12
@@
$noips = 4;
wantdxitu => '0,Show ITU Zone,yesno',
wantgtk => '0,Want GTK interface,yesno',
wantpc9x => '0,Want PC9X interface,yesno',
wantdxitu => '0,Show ITU Zone,yesno',
wantgtk => '0,Want GTK interface,yesno',
wantpc9x => '0,Want PC9X interface,yesno',
+ wantrbn => '0,Want RBN spots,yesno',
+ wantft => '0,Want RBN FT4/8,yesno',
+ wantcw => '0,Want RBN CW,yesno',
+ wantrtty => '0,Want RBN RTTY,yesno',
+ wantpsk => '0,Want RBN PSK,yesno',
+ wantbeacon => '0,Want (RBN) Beacon,yesno',
lastoper => '9,Last for/oper,cldatetime',
nothere => '0,Not Here Text',
registered => '9,Registered?,yesno',
lastoper => '9,Last for/oper,cldatetime',
nothere => '0,Not Here Text',
registered => '9,Registered?,yesno',
@@
-92,7
+99,9
@@
$noips = 4;
believe => '1,Believable nodes,parray',
lastping => '1,Last Ping at,ptimelist',
maxconnect => '1,Max Connections',
believe => '1,Believable nodes,parray',
lastping => '1,Last Ping at,ptimelist',
maxconnect => '1,Max Connections',
- ip => '1,IP addresses,piplist',
+ startt => '0,Start Time,cldatetime',
+ connlist => '1,Connections,parraydifft',
+ width => '0,Preferred Width'
);
#no strict;
);
#no strict;
@@
-189,21
+198,6
@@
sub del_file
unlink "$main::local_data/users.v3";
}
unlink "$main::local_data/users.v3";
}
-# IP address handling
-# this allows one to ask whether an IP address has been used with this node or let's one set an IP address for this node.
-sub ip
-{
- my $self = shift;
- my $node = shift;
- my $ipin = shift;
-
- $self->{ip} = {} unless ref $self->{ip};
- my $ref = $self->{ip};
- delete $ref->{''};
- $ref->{$node} = [$ipin, $main::systime] if $ipin;
- return $ref->{$node}->[0];
-}
-
#
# periodic processing
#
#
# periodic processing
#
@@
-221,6
+215,7
@@
sub process
sub finish
{
sub finish
{
+ $dbm->sync;
undef $dbm;
untie %u;
}
undef $dbm;
untie %u;
}
@@
-246,6
+241,7
@@
sub new
# confess "can't create existing call $call in User\n!" if $u{$call};
my $self = $pkg->alloc($call);
# confess "can't create existing call $call in User\n!" if $u{$call};
my $self = $pkg->alloc($call);
+ $self->{lastseen} = $main::systime;
$self->put;
return $self;
}
$self->put;
return $self;
}
@@
-262,7
+258,10
@@
sub get
# is it in the LRU cache?
my $ref = $lru->get($call);
# is it in the LRU cache?
my $ref = $lru->get($call);
- return $ref if $ref && ref $ref eq 'DXUser';
+ if ($ref && ref $ref eq 'DXUser') {
+ $ref->{lastseen} = $main::systime;
+ return $ref;
+ }
# search for it
unless ($dbm->get($call, $data)) {
# search for it
unless ($dbm->get($call, $data)) {
@@
-282,6
+281,7
@@
sub get
}
return undef;
}
}
return undef;
}
+ $ref->{lastseen} = $main::systime;
$lru->put($call, $ref);
return $ref;
}
$lru->put($call, $ref);
return $ref;
}
@@
-412,7
+412,14
@@
sub del
sub close
{
my $self = shift;
sub close
{
my $self = shift;
- $self->{lastin} = time;
+ my $startt = shift;
+ my $ip = shift;
+ $self->{lastseen} = $self->{lastin} = $main::systime;
+ # add a record to the connect list
+ my $ref = [$startt || $self->{startt}, $main::systime];
+ push @$ref, $ip if $ip;
+ push @{$self->{connlist}}, $ref;
+ shift @{$self->{connlist}} if @{$self->{connlist}} > $maxconnlist;
$self->put();
}
$self->put();
}
@@
-533,10
+540,10
@@
print "There are $count user records and $err errors\n";
my $eval = $val;
my $ekey = $key;
$eval =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg;
my $eval = $val;
my $ekey = $key;
$eval =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg;
- $ekey =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg;
- LogDbg('DXCommand', "Export Error1:
$ekey\t$eval
");
+ $ekey =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg;
+ LogDbg('DXCommand', "Export Error1:
invalid call '$key' => '$val'
");
eval {$dbm->del($key)};
eval {$dbm->del($key)};
-
dbg(carp("Export Error1: $ekey\t$eval\n
$@")) if $@;
+
dbg(carp("Export Error1: delete $key => '$val'
$@")) if $@;
++$err;
next;
}
++$err;
next;
}
@@
-547,7
+554,7
@@
print "There are $count user records and $err errors\n";
if ($ref->is_user && !$ref->{priv} && $main::systime > $t + $tooold) {
unless ($ref->{lat} && $ref->{long} || $ref->{qth} || $ref->{qra}) {
eval {$dbm->del($key)};
if ($ref->is_user && !$ref->{priv} && $main::systime > $t + $tooold) {
unless ($ref->{lat} && $ref->{long} || $ref->{qth} || $ref->{qra}) {
eval {$dbm->del($key)};
- dbg(carp("Export Error2:
$key\t$val\n
$@")) if $@;
+ dbg(carp("Export Error2:
delete '$key' => '$val'
$@")) if $@;
LogDbg('DXCommand', "$ref->{call} deleted, too old");
$del++;
next;
LogDbg('DXCommand', "$ref->{call} deleted, too old");
$del++;
next;
@@
-557,9
+564,9
@@
print "There are $count user records and $err errors\n";
print $fh "$key\t" . $ref->asc_encode($basic_info_only) . "\n";
++$count;
} else {
print $fh "$key\t" . $ref->asc_encode($basic_info_only) . "\n";
++$count;
} else {
- LogDbg('DXCommand', "Export Error3:
$key
\t" . carp($val) ."\n$@");
+ LogDbg('DXCommand', "Export Error3:
'$key'
\t" . carp($val) ."\n$@");
eval {$dbm->del($key)};
eval {$dbm->del($key)};
- dbg(carp("Export Error3:
$key\t$val\n
$@")) if $@;
+ dbg(carp("Export Error3:
delete '$key' => '$val'
$@")) if $@;
++$err;
}
}
++$err;
}
}
@@
-842,6
+849,12
@@
sub is_ak1a
return $self->{sort} eq 'A';
}
return $self->{sort} eq 'A';
}
+sub is_rbn
+{
+ my $self = shift;
+ return $self->{sort} eq 'N'
+}
+
sub unset_passwd
{
my $self = shift;
sub unset_passwd
{
my $self = shift;