Allow changing configuration with tincctl without the "config" keyword.

This saves typing some characters, and forces one to be more explicit about the
desired command (get, set).
This commit is contained in:
Guus Sliepen 2013-03-08 11:40:40 +01:00
parent 1d226977a4
commit af77e5d475
2 changed files with 20 additions and 12 deletions

View file

@ -51,12 +51,12 @@ Create initial configuration files and RSA and ECDSA keypairs with default lengt
If no
.Ar name
for this node is given, it will be asked for.
.It config Oo get Oc Ar variable
.It get Ar variable
Print the current value of configuration variable
.Ar variable .
If more than one variable with the same name exists,
the value of each of them will be printed on a separate line.
.It config Oo set Oc Ar variable Ar value
.It set Ar variable Ar value
Set configuration variable
.Ar variable
to the given
@ -64,9 +64,9 @@ to the given
All previously existing configuration variables with the same name are removed.
To set a variable for a specific host, use the notation
.Ar host Ns Li . Ns Ar variable .
.It config add Ar variable Ar value
.It add Ar variable Ar value
As above, but without removing any previously existing configuration variables.
.It config del Ar variable Op Ar value
.It del Ar variable Op Ar value
Remove configuration variables with the same name and
.Ar value .
If no
@ -191,9 +191,9 @@ Example of configuring tinc using
.Nm :
.Bd -literal -offset indent
tincctl -n vpn init foo
tincctl -n vpn config Subnet 192.168.1.0/24
tincctl -n vpn config bar.Address bar.example.com
tincctl -n vpn config ConnectTo bar
tincctl -n vpn add Subnet 192.168.1.0/24
tincctl -n vpn add bar.Address bar.example.com
tincctl -n vpn add ConnectTo bar
tincctl -n vpn export | gpg --clearsign | mail -s "My config" vpnmaster@example.com
.Ed
.Sh TOP

View file

@ -112,11 +112,10 @@ static void usage(bool status) {
"\n"
"Valid commands are:\n"
" init [name] Create initial configuration files.\n"
" config Change configuration:\n"
" [get] VARIABLE - print current value of VARIABLE\n"
" [set] VARIABLE VALUE - set VARIABLE to VALUE\n"
" add VARIABLE VALUE - add VARIABLE with the given VALUE\n"
" del VARIABLE [VALUE] - remove VARIABLE [only ones with watching VALUE]\n"
" get VARIABLE Print current value of VARIABLE\n"
" set VARIABLE VALUE Set VARIABLE to VALUE\n"
" add VARIABLE VALUE Add VARIABLE with the given VALUE\n"
" del VARIABLE [VALUE] Remove VARIABLE [only ones with watching VALUE]\n"
" start [tincd options] Start tincd.\n"
" stop Stop tincd.\n"
" restart Restart tincd.\n"
@ -1311,6 +1310,9 @@ static int cmd_config(int argc, char *argv[]) {
return 1;
}
if(strcasecmp(argv[0], "config"))
argv--, argc++;
int action = -2;
if(!strcasecmp(argv[1], "get")) {
argv++, argc--;
@ -1988,6 +1990,12 @@ static const struct {
{"log", cmd_log},
{"pid", cmd_pid},
{"config", cmd_config},
{"add", cmd_config},
{"del", cmd_config},
{"get", cmd_config},
{"set", cmd_config},
{"change", cmd_config},
{"replace", cmd_config},
{"init", cmd_init},
{"generate-keys", cmd_generate_keys},
{"generate-rsa-keys", cmd_generate_rsa_keys},