summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-base/luasrc')
-rw-r--r--modules/luci-base/luasrc/model/network.lua6
-rw-r--r--modules/luci-base/luasrc/sys.lua40
-rw-r--r--modules/luci-base/luasrc/tools/status.lua19
-rw-r--r--modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm5
-rw-r--r--modules/luci-base/luasrc/view/lease_status.htm31
5 files changed, 71 insertions, 30 deletions
diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua
index 67a2de4ed2..a36a23f321 100644
--- a/modules/luci-base/luasrc/model/network.lua
+++ b/modules/luci-base/luasrc/model/network.lua
@@ -622,6 +622,12 @@ function del_network(self, n)
_uci:delete("wireless", s['.name'], "network")
end
end)
+
+ local ok, fw = pcall(require, "luci.model.firewall")
+ if ok then
+ fw.init()
+ fw:del_network(n)
+ end
end
return r
end
diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua
index 7e4a9d63cf..bb4c67fe88 100644
--- a/modules/luci-base/luasrc/sys.lua
+++ b/modules/luci-base/luasrc/sys.lua
@@ -137,7 +137,7 @@ end
net = {}
local function _nethints(what, callback)
- local _, k, e, mac, ip, name
+ local _, k, e, mac, ip, name, duid, iaid
local cur = uci.cursor()
local ifn = { }
local hosts = { }
@@ -189,6 +189,24 @@ local function _nethints(what, callback)
end
end
)
+
+ cur:foreach("dhcp", "odhcpd",
+ function(s)
+ if type(s.leasefile) == "string" and fs.access(s.leasefile) then
+ for e in io.lines(s.leasefile) do
+ duid, iaid, name, _, ip = e:match("^# %S+ (%S+) (%S+) (%S+) (-?%d+) %S+ %S+ ([0-9a-f:.]+)/[0-9]+")
+ mac = net.duid_to_mac(duid)
+ if mac then
+ if ip and iaid == "ipv4" then
+ _add(what, mac, ip, nil, name ~= "*" and name)
+ elseif ip then
+ _add(what, mac, nil, ip, name ~= "*" and name)
+ end
+ end
+ end
+ end
+ end
+ )
cur:foreach("dhcp", "host",
function(s)
@@ -386,6 +404,26 @@ function net.devices()
return devs
end
+function net.duid_to_mac(duid)
+ local b1, b2, b3, b4, b5, b6
+
+ if type(duid) == "string" then
+ -- DUID-LLT / Ethernet
+ if #duid == 28 then
+ b1, b2, b3, b4, b5, b6 = duid:match("^00010001(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)%x%x%x%x%x%x%x%x$")
+
+ -- DUID-LL / Ethernet
+ elseif #duid == 20 then
+ b1, b2, b3, b4, b5, b6 = duid:match("^00030001(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$")
+
+ -- DUID-LL / Ethernet (Without Header)
+ elseif #duid == 12 then
+ b1, b2, b3, b4, b5, b6 = duid:match("^(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$")
+ end
+ end
+
+ return b1 and luci.ip.checkmac(table.concat({ b1, b2, b3, b4, b5, b6 }, ":"))
+end
process = {}
diff --git a/modules/luci-base/luasrc/tools/status.lua b/modules/luci-base/luasrc/tools/status.lua
index 635995310f..e4bc4451a2 100644
--- a/modules/luci-base/luasrc/tools/status.lua
+++ b/modules/luci-base/luasrc/tools/status.lua
@@ -6,21 +6,6 @@ module("luci.tools.status", package.seeall)
local uci = require "luci.model.uci".cursor()
local ipc = require "luci.ip"
-local function duid_to_mac(duid)
- local b1, b2, b3, b4, b5, b6
-
- -- DUID-LLT / Ethernet
- if type(duid) == "string" and #duid == 28 then
- b1, b2, b3, b4, b5, b6 = duid:match("^00010001(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)%x%x%x%x%x%x%x%x$")
-
- -- DUID-LL / Ethernet
- elseif type(duid) == "string" and #duid == 20 then
- b1, b2, b3, b4, b5, b6 = duid:match("^00030001(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$")
- end
-
- return b1 and ipc.checkmac(table.concat({ b1, b2, b3, b4, b5, b6 }, ":"))
-end
-
local function dhcp_leases_common(family)
local rv = { }
local nfs = require "nixio.fs"
@@ -93,7 +78,7 @@ local function dhcp_leases_common(family)
elseif ip and iaid == "ipv4" and family == 4 then
rv[#rv+1] = {
expires = (expire >= 0) and os.difftime(expire, os.time()),
- macaddr = ipc.checkmac(duid:gsub("^(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$", "%1:%2:%3:%4:%5:%6")) or "00:00:00:00:00:00",
+ macaddr = sys.net.duid_to_mac(duid) or "00:00:00:00:00:00",
ipaddr = ip,
hostname = (name ~= "-") and name
}
@@ -107,7 +92,7 @@ local function dhcp_leases_common(family)
local _, lease
local hosts = sys.net.host_hints()
for _, lease in ipairs(rv) do
- local mac = duid_to_mac(lease.duid)
+ local mac = sys.net.duid_to_mac(lease.duid)
local host = mac and hosts[mac]
if host then
if not lease.name then
diff --git a/modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm b/modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm
index ebb02e489b..eeb1d5c5cb 100644
--- a/modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm
+++ b/modules/luci-base/luasrc/view/cbi/wireless_modefreq.htm
@@ -4,6 +4,7 @@
var freqlist = <%= luci.http.write_json(self.iwinfo.freqlist) %>;
var hwmodes = <%= luci.http.write_json(self.iwinfo.hwmodelist or {}) %>;
var htmodes = <%= luci.http.write_json(self.iwinfo.htmodelist) %>;
+ var acs = <%= luci.http.write_json(self.hostapd_acs or 0) %>;
var channels = {
'11g': [
@@ -14,6 +15,10 @@
]
};
+ if (acs < 1) {
+ channels[(freqlist[freqlist.length - 1].mhz > 2484) ? '11a' : '11g'].length = 0;
+ }
+
for (var i = 0; i < freqlist.length; i++)
channels[(freqlist[i].mhz > 2484) ? '11a' : '11g'].push(
freqlist[i].channel,
diff --git a/modules/luci-base/luasrc/view/lease_status.htm b/modules/luci-base/luasrc/view/lease_status.htm
index bf2a8968d1..bbaf5986ba 100644
--- a/modules/luci-base/luasrc/view/lease_status.htm
+++ b/modules/luci-base/luasrc/view/lease_status.htm
@@ -79,17 +79,24 @@
</div>
</div>
-<div class="cbi-section" style="display:none">
- <h3><%:Active DHCPv6 Leases%></h3>
- <div class="table" id="lease6_status_table">
- <div class="tr table-titles">
- <div class="th"><%:Host%></div>
- <div class="th"><%:IPv6-Address%></div>
- <div class="th"><%:DUID%></div>
- <div class="th"><%:Leasetime remaining%></div>
- </div>
- <div class="tr placeholder">
- <div class="td"><em><%:Collecting data...%></em></div>
+<%
+ local fs = require "nixio.fs"
+ local has_ipv6 = fs.access("/proc/net/ipv6_route")
+
+ if has_ipv6 then
+-%>
+ <div class="cbi-section" style="display:none">
+ <h3><%:Active DHCPv6 Leases%></h3>
+ <div class="table" id="lease6_status_table">
+ <div class="tr table-titles">
+ <div class="th"><%:Host%></div>
+ <div class="th"><%:IPv6-Address%></div>
+ <div class="th"><%:DUID%></div>
+ <div class="th"><%:Leasetime remaining%></div>
+ </div>
+ <div class="tr placeholder">
+ <div class="td"><em><%:Collecting data...%></em></div>
+ </div>
</div>
</div>
-</div>
+<% end -%>