X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fshow%2Fnode.pl;h=5fdbf103113c36c34b00eb4f6e74273366c6dc5e;hb=refs%2Fheads%2Fnewusers;hp=46e0b32d9d66e072d6896fce55191a6a052ad34f;hpb=bcf2892aa7f3c9957ee61365a6e032dd93044834;p=spider.git diff --git a/cmd/show/node.pl b/cmd/show/node.pl index 46e0b32d..5fdbf103 100644 --- a/cmd/show/node.pl +++ b/cmd/show/node.pl @@ -9,70 +9,108 @@ # # A special millenium treat just for G4PDQ # -# Copyright (c) 2000 Dirk Koopman G1TLH +# Copyright (c) 2000-2020 Dirk Koopman G1TLH +# # -# $Id$ # -my ($self, $line) = @_; -return (1, $self->msg('e5')) unless $self->priv >= 1; - -my @call = map {uc $_} split /\s+/, $line; -my @out; -my $count; - -# search thru the user for nodes -if ($call[0] eq 'ALL') { - shift @call; - my ($action, $key, $data) = (0,0,0); - for ($action = DXUser::R_FIRST, $count = 0; !$DXUser::dbm->seq($key, $data, $action); $action = DXUser::R_NEXT) { - if ($data =~ m{sort => '[ACRSX]'}) { - push @call, $key; - ++$count; - } - } -} elsif (@call == 0) { - @call = map {$_->call} DXChannel::get_all_nodes(); -} - -my $call; -foreach $call (@call) { - my $clref = Route::Node::get($call); - my $uref = DXUser->get_current($call); - my ($sort, $ver); +sub handle +{ + my ($self, $line) = @_; + return (1, $self->msg('e5')) unless $self->priv >= 1; + my @out; - my $pcall = sprintf "%-11s", $call; - push @out, $self->msg('snode1') unless @out > 0; - if ($uref) { - $sort = "Unknwn"; - $sort = "Spider" if $uref->is_spider; - $sort = "AK1A " if $uref->is_ak1a; - $sort = "Clx " if $uref->is_clx; - $sort = "User " if $uref->is_user; - $sort = "BBS " if $uref->is_bbs; - $sort = "DXNet " if $uref->is_dxnet; - $sort = "ARClus" if $uref->is_arcluster; + my @call = map {uc $_} split /\s+/, $line; + if ($self->{_nospawn}) { + @out = generate($self, @call); } else { - push @out, $self->msg('snode3', $call); - next; + @out = $self->spawn_cmd("show/nodes $line", sub { return (generate($self, @call)); }); } - if ($call eq $main::mycall) { - $sort = "Spider"; - $ver = $main::version; - } else { - $ver = $clref->version if $clref && $clref->version; + return (1, @out); +} + +sub generate +{ + my $self = shift; + my @call = @_; + my @out; + my $count; + + # search thru the user for nodes + if (@call == 0) { + @call = map {$_->call} DXChannel::get_all_nodes(); } + elsif ($call[0] eq 'ALL') { + shift @call; + # my ($action, $key, $data) = (0,0,0); + # for ($action = DXUser::R_FIRST, $count = 0; !$DXUser::dbm->seq($key, $data, $action); $action = DXUser::R_NEXT) { + # if ($data =~ m{\01[ACRSX]\0\0\0\04sort}) { + # push @call, $key; + # ++$count; + # } + # } - my ($major, $minor, $subs) = unpack("AAA*", $ver) if $ver; - if ($uref->is_spider) { - push @out, $self->msg('snode2', $pcall, $sort, "$ver "); - } else { - push @out, $self->msg('snode2', $pcall, $sort, $ver ? "$major\-$minor.$subs" : " "); + push @call, DXUser::scan(sub { + my $k = shift; + # cheat, don't decode because we can easily pull it out from the json test + return $_[0] =~ m{"sort":"[ACRSX]"} ? $k : (); + }); + } + + my $call; + foreach $call (sort @call) { + my $clref = Route::Node::get($call); + my $l = DXUser::get($call, 1); + next unless $l; + my $uref = DXUser::json_decode($l); + next unless $uref; + my ($sort, $ver, $build); + + my $pcall = sprintf "%-11s", $call; + push @out, $self->msg('snode1') unless @out > 0; + if ($uref) { + $sort = "Spider" if $uref->is_spider || ($clref && $clref->do_pc9x); + $sort = "Clx " if $uref->is_clx; + $sort = "User " if $uref->is_user; + $sort = "BBS " if $uref->is_bbs; + $sort = "DXNet " if $uref->is_dxnet; + $sort = "ARClus" if $uref->is_arcluster; + $sort = "AK1A " if !$sort && $uref->is_ak1a; + $sort = "Unknwn" unless $sort; + } else { + push @out, $self->msg('snode3', $call); + next; + } + $ver = ""; + $build = ""; + if ($call eq $main::mycall) { + $sort = "Spider"; + $ver = $main::version; + } else { + $ver = $clref->version if $clref && $clref->version; + $ver = $uref->version if !$ver && $uref->version; + $sort = "CCClus" if $ver >= 1000 && $ver < 4000 && $sort eq "Spider"; + } + + if ($uref->is_spider || ($clref && $clref->do_pc9x)) { + $ver /= 100 if $ver > 5400; + $ver -= 53 if $ver > 54; + if ($clref && $clref->build) { + $build = "build: " . $clref->build + } + elsif ($uref->build) { + $build = "build: " . $uref->build; + } + push @out, $self->msg('snode2', $pcall, $sort, "$ver $build"); + } else { + my ($major, $minor, $subs) = unpack("AAA*", $ver) if $ver; + push @out, $self->msg('snode2', $pcall, $sort, $ver ? "$major\-$minor.$subs" : " "); + } + ++$count; } - ++$count; -} -return (1, @out, $self->msg('rec', $count)); + return (1, @out, $self->msg('rec', $count)); +}