diff options
| author | Paul Donald | 2026-02-19 04:11:37 +0000 |
|---|---|---|
| committer | Paul Donald | 2026-02-20 00:29:43 +0000 |
| commit | 7f2614caecfa91fad8c90c19a0e9865a28211a0d (patch) | |
| tree | c2b06b89b7e9a3e667bac96375691980754241ee | |
| parent | c7a778719f6bd90d007936898d5bad6e5ee4aa2d (diff) | |
| download | luci-7f2614caecfa91fad8c90c19a0e9865a28211a0d.tar.gz | |
luci-base: firewall fixes
Firewall.newZone() treated this.getZone(name)
(an async function returning a Promise) as if it
were synchronous, causing the while loop never
to terminate. Although, it's not used anywhere.
Sort in getZones was not producing expected results.
Now use a localeCompare which returns an integer result
for sorting purposes. The previous comparison
returned a boolean, but for sorting to work, it must
return either -1 to go before, +1 to go after, or 0 for
equality.
Rule and Redirect shall also have a sid.
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
| -rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/firewall.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/firewall.js b/modules/luci-base/htdocs/luci-static/resources/firewall.js index 45eca10045..8db4268dae 100644 --- a/modules/luci-base/htdocs/luci-static/resources/firewall.js +++ b/modules/luci-base/htdocs/luci-static/resources/firewall.js @@ -95,11 +95,11 @@ Firewall = L.Class.extend({ }, newZone: function() { - return initFirewallState().then(L.bind(function() { + return initFirewallState().then(L.bind(async function() { var name = 'newzone', count = 1; - while (this.getZone(name) != null) + while ((await this.getZone(name)) != null) name = 'newzone%d'.format(++count); return this.addZone(name); @@ -140,7 +140,7 @@ Firewall = L.Class.extend({ for (let s of sections) zones.push(new Zone(s['.name'])); - zones.sort(function(a, b) { return a.getName() > b.getName() }); + zones.sort(function(a, b) { return L.naturalCompare(a.getName() || '', b.getName() || '') }); return zones; }); @@ -546,6 +546,10 @@ Forwarding = AbstractFirewallItem.extend({ Rule = AbstractFirewallItem.extend({ + __init__: function(sid) { + this.sid = sid; + }, + getSource: function() { return this.get('src'); }, @@ -565,6 +569,10 @@ Rule = AbstractFirewallItem.extend({ Redirect = AbstractFirewallItem.extend({ + __init__: function(sid) { + this.sid = sid; + }, + getSource: function() { return this.get('src'); }, |