Avoids accessing global net_data from within the function
Signed-off-by: Felix Fietkau <nbd@nbd.name>
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",
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':