{
my $mode = shift;
- my $ufn;
- my $convert;
-
+ my $convert = "$main::root/perl/convert-users-v3-to-v4.pl";
+ my $export;
+
$json = JSON->new()->canonical(1);
$filename = localdata("users.v4");
if (-e $filename || -e "$filename.n" || -e "$filename.o") {
$v4 = 1;
- readinjson();
} else {
- die "User file $filename missing, please run convert-users-v3-to-v4.pl or copy a user_json backup from somewhere\n";
+ if (-e localdata('users.v3')) {
+ LogDbg('DXUser', "Converting " . localdata('users.v3') . " to new json version of users file, please wait");
+ if (-x $convert) {
+ system($convert);
+ ++$export;
+ }
+ }
+
+ die "User file $filename missing, please run $convert or copy a user_json backup from somewhere\n" unless -e "$filename.n" || -s $filename;
}
+ readinjson();
+ copy $filename, "$filename.n" unless -e "$filename.n";
+ export() if $export;
}
sub del_file
my $name = shift;
my $fn = $name || localdata("user_json"); # force use of local_data
+ my $ta = [gettimeofday];
# save old ones
move "$fn.oooo", "$fn.ooooo" if -e "$fn.oooo";
move "$fn", "$fn.o" if -e "$fn";
my $json = JSON->new;
- $json->canonical(1);
+ $json->canonical(1);;
my $count = 0;
my $err = 0;
my $key = 0;
my $val = undef;
foreach my $k (sort keys %u) {
- my $r = $u{$k};
+ my $r = get($k);
if ($r->{sort} eq 'U' && !$r->{priv} && $main::systime > $r->{lastin}+$tooold ) {
unless ($r->{lat} || $r->{long} || $r->{qra} || $r->{qth} || $r->{name}) {
- LogDbg('DXUser', "DXUser::export deleting $k - too old, last in " . cldatetime($r->lastin) . " " . difft([$r->lastin, $main::systime]));
+ LogDbg('export', "DXUser::export deleting $k - too old, last in " . cldatetime($r->lastin) . " " . difft([$r->lastin, $main::systime]));
delete $u{$k};
++$del;
next;
}
eval {$val = json_encode($r);};
if ($@) {
- LogDbg('DXUser', "DXUser::export error encoding call: $k $@");
+ LogDbg('export', "DXUser::export error encoding call: $k $@");
++$err;
next;
}
}
$fh->close;
}
- my $s = qq{Exported users to $fn - $count Users $del Deleted $err Errors ('sh/log Export' for details)};
+ my $t = _diffms($ta);
+ my $s = qq{Exported users to $fn - $count Users $del Deleted $err Errors in $t mS ('sh/log Export' for details)};
LogDbg('DXUser', $s);
return $s;
}
$basecall =~ s/-\d+$//; # remember this for later multiple user processing
my $lock;
if ($user) {
- # we are a real user
+ # make sure we act on any locked status that the actual incoming call has.
$lock = $user->lockout;
- } elsif ($allowmultiple) {
- # could we be a potential "pseudo" connection
+ } elsif ($allowmultiple && $call ne $basecall) {
+ # if we are allowing multiple connections and there is a basecall minus incoming ssid, use the basecall's lock status
$user = DXUser::get_current($basecall);
$lock = $user->lockout if $user;
}
+
+ # now deal with the lock
if ($lock) {
my $host = $conn->peerhost;
- LogDbg('DXCommand', "$call on $host is locked out, disconnected");
+ LogDbg('', "$call on $host is locked out, disconnected");
$conn->disconnect;
return;
}
my $allow = 0;
if (@lastconns >= $DXUser::maxconnlist) {
$allow = $lastconns[-1]->[0] - $lastconns[0]->[0] < $min_reconnection_rate;
- }
+ }
# search for a spare ssid
L1: for (my $count = $call =~ /-\d+$/?0:1; $allow && $count < $allowmultiple; ) { # remember we have one call already
my $lastid = 1;
if ($bumpexisting) {
my $ip = $dxchan->hostname;
$dxchan->send_now('D', DXM::msg($lang, 'conbump', $call, $ip));
- Log('', "$call bumped off by $ip, disconnected");
+ LogDbg('', "$call bumped off by $ip, disconnected");
$dxchan->disconnect;
} else {
already_conn($conn, $call, DXM::msg($lang, 'conother', $call, $main::mycall));
$v = defined $c ? $c : $m;
if ($v && @n >= $v+$allowmultiple) {
my $nodes = join ',', @n;
- LogDbg('DXCommand', "$call has too many connections ($v) at $nodes - disconnected");
+ LogDbg('', "$call has too many connections ($v) at $nodes - disconnected");
already_conn($conn, $call, DXM::msg($lang, 'contomany', $call, $v, $nodes));
return;
}
# set callbacks
- $conn->set_error(sub {my $err = shift; LogDbg('DXCommand', "Comms error '$err' received for call $dxchan->{call}"); $dxchan->disconnect(1);});
+ $conn->set_error(sub {my $err = shift; LogDbg('', "Comms error '$err' received for call $dxchan->{call}"); $dxchan->disconnect(1);});
$conn->set_on_eof(sub {$dxchan->disconnect});
$conn->set_rproc(sub {my ($conn,$msg) = @_; $dxchan->rec($msg);});
if ($sort eq 'W') {