From: Felix Fietkau Date: Thu, 25 Aug 2022 10:40:17 +0000 (+0200) Subject: unet-cli: pass host object to set_host() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e966627449a700dc8e9c17dd0d94b9e688c497f1;p=project%2Funetd.git unet-cli: pass host object to set_host() Avoids accessing global net_data from within the function Signed-off-by: Felix Fietkau --- diff --git a/scripts/unet-cli b/scripts/unet-cli index f00c817..c10b542 100755 --- a/scripts/unet-cli +++ b/scripts/unet-cli @@ -213,9 +213,7 @@ function set_fields(object, list) { set_field(list[f], object, f, args[f]); } -function set_host(name) { - let host = net_data.hosts[name]; - +function set_host(host) { set_fields(host, { key: "string", endpoint: "string", @@ -372,12 +370,12 @@ case 'set-config': case 'add-host': net_data.hosts[hostname] = {}; assert(args.key, "Missing host key"); - set_host(hostname); + set_host(net_data.hosts[hostname]); break; case 'set-host': assert(net_data.hosts[hostname], `Host '${hostname}' does not exist`); - set_host(hostname); + set_host(net_data.hosts[hostname]); break; case 'add-service':