chilli-redirect: only write values to uci that are defined

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2021-09-04 08:23:48 +02:00
parent 08a0ef6abc
commit 8335267666

View File

@@ -9,20 +9,28 @@ let keys = {
uamport: 3990, uamport: 3990,
radiusauthport: 1812, radiusauthport: 1812,
radiusacctport: 1813, radiusacctport: 1813,
radiusserver1: true, radiusserver1: false,
radiusserver2: true, radiusserver2: false,
radiusnasid: true, radiusnasid: false,
uamallowed: true, uamallowed: false,
uamdomain: true, uamdomain: false,
defidletimeout: 0, defidletimeout: 0,
definteriminterval: 300, definteriminterval: 300,
acctupdate: 9, acctupdate: 9,
uamserver: true, uamserver: false,
radiussecret: true, radiussecret: false,
nasmac: true, nasmac: false,
macauth: true, macauth: false,
macpassword: true, macpassword: false,
}; };
function get_value(key, value) {
if (key in chilli_redirect)
return chilli_redirect[key];
return value ? value : '';
}
%} %}
set chilli.@chilli[0].dhcpif='{{ name }}' set chilli.@chilli[0].dhcpif='{{ name }}'
@@ -43,5 +51,5 @@ set chilli.@chilli[0].nasip='10.0.0.1'
{% endif %} {% endif %}
{% for (let k, v in keys): %} {% for (let k, v in keys): %}
set chilli.@chilli[0].{{ k }}='{{ chilli_redirect[k] ? chilli_redirect[k] : v}}' set chilli.@chilli[0].{{ k }}='{{ get_value(k, v) }}'
{% endfor %} {% endfor %}