From 51fc2b9134d2e3bf91daf970c36bb8a80590e34f Mon Sep 17 00:00:00 2001 From: minima Date: Wed, 12 Mar 2003 18:38:21 +0000 Subject: [PATCH] added the ability for HDB to use sh/qrz remotely --- Changes | 5 +++++ cmd/Commands_en.hlp | 11 +++++++++++ cmd/dbavail.pl | 4 ++-- cmd/dbcreate.pl | 7 ++++++- perl/DXDb.pm | 16 +++++++++++++++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index 28a42c5b..1111a68f 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,11 @@ 1. added HC and QRZ.com to possible QSL locations, if you want to pick up historical info (ie start again), run create_qsl.pl after update and restart the node (which you will need to do anyway). +2. changed the dbcreate command so that you can say: + dbcreate dxqsl cmd show/dxqsl +which will allow local and remote users to execute commands as though they +are Databases. You can also include these databases in chains. What you do +with this, is ofcourse a moot question. 11Mar03======================================================================= 1. Changed the name of show/qsl to show/dxqsl. 2. Alter Commands_en.hlp to match new name and issue manual updates (g0vgs) diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 5a2c3345..b5c10c19 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -378,6 +378,7 @@ in the system. It is also aliased to SHOW/COMMAND. === 9^DBCREATE ^Create a database entry === 9^DBCREATE chain [..]^Create a chained database entry === 9^DBCREATE remote ^Create a remote database entry +=== 9^DBCREATE cmd ^make a local command available as a DB DBCREATE allows you to define a database in the system. It doesn't actually create anything, just defines it. @@ -430,6 +431,16 @@ to allow to work as they may be used to. +You can also make local commands available as 'pseudo' databases. You +can therefore make spider special commands available as a database. I +imagine that this will be primarily useful for remote access from +legacy nodes. For example:- + + DBCREATE dxqsl cmd show/dxqsl + +You also use one of these databases in a chain. This may be useful +locally. + See DBIMPORT for the importing of existing AK1A format data to databases. See DBSHOW for generic database enquiry diff --git a/cmd/dbavail.pl b/cmd/dbavail.pl index 0974ee7f..5bfcb32e 100644 --- a/cmd/dbavail.pl +++ b/cmd/dbavail.pl @@ -10,7 +10,7 @@ my @out; my $f; foreach $f (values %DXDb::avail) { - push @out, "DB Name Location Chain" unless @out; - push @out, sprintf "%-15s %-10s %s", $f->name, $f->remote ? $f->remote : "Local", $f->chain ? parray($f->chain) : ""; + push @out, "DB Name Location Cmd Chain" unless @out; + push @out, sprintf "%-15s %-10s %-15s %s", $f->name, $f->remote ? $f->remote : "Local", ($f->localcmd || ""), $f->chain ? parray($f->chain) : ""; } return (1, @out); diff --git a/cmd/dbcreate.pl b/cmd/dbcreate.pl index 8f47b63f..837141e2 100644 --- a/cmd/dbcreate.pl +++ b/cmd/dbcreate.pl @@ -14,12 +14,17 @@ return (1, $self->msg('db6', $name)) if DXDb::getdesc($name); my $remote; my $chain; +my $cmd; while (@f) { my $f = lc shift @f; if ($f eq 'remote') { $remote = uc shift @f if @f; next; } + if ($f eq 'cmd') { + $cmd = lc shift @f if @f; + next; + } if ($f eq 'chain') { if (@f) { $chain = [ @f ]; @@ -27,6 +32,6 @@ while (@f) { } } } -DXDb::new($name, $remote, $chain); +DXDb::new($name, $remote, $chain, $cmd); push @out, $self->msg($remote ? 'db7' : 'db8', $name, $remote); return (1, @out); diff --git a/perl/DXDb.pm b/perl/DXDb.pm index f54d6f14..e399545d 100644 --- a/perl/DXDb.pm +++ b/perl/DXDb.pm @@ -42,6 +42,7 @@ $dbbase = "$main::root/db"; # where all the databases are kept; tae => '9,End App txt', atemplate => '9,App Templates,parray', help => '0,Help txt,parray', + localcmd => '0,Local Command', ); $lastprocesstime = time; @@ -157,7 +158,16 @@ sub getkey # make sure we are open $self->open; - if ($self->{db}) { + if ($self->{localcmd}) { + my $dxchan = $main::me; + $dxchan->{remotecmd} = 1; # for the benefit of any command that needs to know + my $oldpriv = $dxchan->{priv}; + $dxchan->{priv} = 0; + my @in = (DXCommandmode::run_cmd($dxchan, "$self->{localcmd} $key")); + $dxchan->{priv} = $oldpriv; + delete $dxchan->{remotecmd}; + return @in ? join("\n", @in) : undef; + } elsif ($self->{db}) { my $s = $self->{db}->get($key, $value); return $s ? undef : $value; } @@ -187,10 +197,14 @@ sub new my $name = shift; my $remote = shift; my $chain = shift; + my $cmd = shift; + $self->{name} = lc $name; $self->{remote} = uc $remote if $remote; $self->{chain} = $chain if $chain && ref $chain; $self->{accesst} = $self->{createt} = $self->{lastt} = $main::systime; + $self->{localcmd} = lc $cmd if $cmd; + $avail{$self->{name}} = $self; mkdir $dbbase, 02775 unless -e $dbbase; save(); -- 2.34.1