summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
c87f5c8)
Fix the situation where GB7DXC exists and is locked out and $allowmultiple
is active than GB7DXC-5 logs in and is locked by dint of GB7DXC's locked
status and ignores GB7DXC-5's unlocked status.
Run convert-users-v3-to-v4.pl automatically if there are no users.v4[.o/.n]
files present in local_data or data. Then copy users.v4 to users.v4,n and
do an export_users, creating users_json.
File user export so that it actually works!
}
my $strip = $flag eq 'strip';
}
my $strip = $flag eq 'strip';
-my @out = DXUser::export(undef, $strip); # for now
+my @out = DXUser::export(); # for now
my $call = $self->{call};
foreach my $l (@_) {
my $call = $self->{call};
foreach my $l (@_) {
- for (ref $l ? @$l : $l) {
+ for (ref($l) eq 'ARRAY' ? @$l : $l) {
my @lines = split /\n/;
for (@lines) {
$conn->send_later("D$call|$_");
my @lines = split /\n/;
for (@lines) {
$conn->send_later("D$call|$_");
- 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;
$json = JSON->new()->canonical(1);
$filename = localdata("users.v4");
if (-e $filename || -e "$filename.n" || -e "$filename.o") {
$v4 = 1;
- 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;
my $name = shift;
my $fn = $name || localdata("user_json"); # force use of local_data
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";
# save old ones
move "$fn.oooo", "$fn.ooooo" if -e "$fn.oooo";
move "$fn", "$fn.o" if -e "$fn";
my $json = JSON->new;
move "$fn", "$fn.o" if -e "$fn";
my $json = JSON->new;
my $count = 0;
my $err = 0;
my $count = 0;
my $err = 0;
my $key = 0;
my $val = undef;
foreach my $k (sort keys %u) {
my $key = 0;
my $val = undef;
foreach my $k (sort keys %u) {
if ($r->{sort} eq 'U' && !$r->{priv} && $main::systime > $r->{lastin}+$tooold ) {
unless ($r->{lat} || $r->{long} || $r->{qra} || $r->{qth} || $r->{name}) {
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;
delete $u{$k};
++$del;
next;
}
eval {$val = json_encode($r);};
if ($@) {
}
eval {$val = json_encode($r);};
if ($@) {
- LogDbg('DXUser', "DXUser::export error encoding call: $k $@");
+ LogDbg('export', "DXUser::export error encoding call: $k $@");
- 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;
}
LogDbg('DXUser', $s);
return $s;
}
$basecall =~ s/-\d+$//; # remember this for later multiple user processing
my $lock;
if ($user) {
$basecall =~ s/-\d+$//; # remember this for later multiple user processing
my $lock;
if ($user) {
+ # make sure we act on any locked status that the actual incoming call has.
- } 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;
}
$user = DXUser::get_current($basecall);
$lock = $user->lockout if $user;
}
+
+ # now deal with the lock
if ($lock) {
my $host = $conn->peerhost;
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;
}
$conn->disconnect;
return;
}
my $allow = 0;
if (@lastconns >= $DXUser::maxconnlist) {
$allow = $lastconns[-1]->[0] - $lastconns[0]->[0] < $min_reconnection_rate;
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;
# 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));
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));
$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;
$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;
}
already_conn($conn, $call, DXM::msg($lang, 'contomany', $call, $v, $nodes));
return;
}
- $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') {
$conn->set_on_eof(sub {$dxchan->disconnect});
$conn->set_rproc(sub {my ($conn,$msg) = @_; $dxchan->rec($msg);});
if ($sort eq 'W') {