Fix inability to set initial WAN VLAN (#1454)

This commit is contained in:
Tim Wilkinson 2024-09-02 17:50:20 -07:00 committed by GitHub
parent 4ab2629c33
commit 9240bf87cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -150,13 +150,13 @@ if (request.env.REQUEST_METHOD === "PUT") {
}
}
if ("wan_vlan" in request.args) {
const wan_iface = split(configuration.getSettingAsString("wan_intf", ""), ".");
const wan_iface = keys(hardware.getDefaultNetworkConfiguration().wan.ports)[0];
const wan_vlan = int(request.args.wan_vlan || 0);
if (wan_vlan === 0) {
configuration.setSetting("wan_intf", wan_iface[0]);
configuration.setSetting("wan_intf", wan_iface);
}
else if (wan_vlan >= 3 && wan_vlan <= 4095) {
configuration.setSetting("wan_intf", `${wan_iface[0]}.${wan_vlan}`);
configuration.setSetting("wan_intf", `${wan_iface}.${wan_vlan}`);
}
}
if ("olsrd_gw" in request.args) {

View File

@ -143,6 +143,9 @@ export function getSettingAsInt(key, def)
export function setSetting(key, value, def)
{
initSetup();
if (!(key in setup)) {
push(setupKeys, key);
}
const old = setup[key];
setup[key] = replace(`${value ?? def ?? ""}`, /[\r\n]/g, " ");
if (old !== setup[key]) {