summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/luasrc/cbi/datatypes.lua18
-rw-r--r--modules/luci-base/luasrc/http/protocol.luadoc4
-rw-r--r--modules/luci-base/luasrc/model/network.lua13
-rw-r--r--modules/luci-base/luasrc/sys.lua23
-rw-r--r--modules/luci-base/luasrc/tools/status.lua15
-rw-r--r--modules/luci-base/luasrc/util.luadoc4
-rw-r--r--modules/luci-base/luasrc/view/cbi/browser.htm1
-rw-r--r--modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm128
-rw-r--r--modules/luci-mod-admin-full/luasrc/controller/admin/network.lua1
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua9
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/hosts.lua9
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua51
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm2
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm3
-rw-r--r--modules/luci-mod-admin-mini/luasrc/model/cbi/mini/dhcp.lua11
15 files changed, 161 insertions, 131 deletions
diff --git a/modules/luci-base/luasrc/cbi/datatypes.lua b/modules/luci-base/luasrc/cbi/datatypes.lua
index a7e02f350a..55cdf8a74b 100644
--- a/modules/luci-base/luasrc/cbi/datatypes.lua
+++ b/modules/luci-base/luasrc/cbi/datatypes.lua
@@ -196,23 +196,7 @@ function portrange(val)
end
function macaddr(val)
- if val and val:match(
- "^[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+:" ..
- "[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+$"
- ) then
- local parts = util.split( val, ":" )
-
- for i = 1,6 do
- parts[i] = tonumber( parts[i], 16 )
- if parts[i] < 0 or parts[i] > 255 then
- return false
- end
- end
-
- return true
- end
-
- return false
+ return ip.checkmac(val) and true or false
end
function hostname(val)
diff --git a/modules/luci-base/luasrc/http/protocol.luadoc b/modules/luci-base/luasrc/http/protocol.luadoc
index 67a60d9e7a..19a0a3419b 100644
--- a/modules/luci-base/luasrc/http/protocol.luadoc
+++ b/modules/luci-base/luasrc/http/protocol.luadoc
@@ -69,7 +69,7 @@ data line by line with the trailing \r\n stripped of.
Decode a mime encoded http message body with multipart/form-data
Content-Type. Stores all extracted data associated with its parameter name
-in the params table withing the given message object. Multiple parameter
+in the params table within the given message object. Multiple parameter
values are stored as tables, ordinary ones as strings.
If an optional file callback function is given then it is feeded with the
file contents chunk by chunk and only the extracted file name is stored
@@ -92,7 +92,7 @@ with three arguments:
Decode an urlencoded http message body with application/x-www-urlencoded
Content-Type. Stores all extracted data associated with its parameter name
-in the params table withing the given message object. Multiple parameter
+in the params table within the given message object. Multiple parameter
values are stored as tables, ordinary ones as strings.
@class function
@name urldecode_message_body
diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua
index 9ea8e369da..056fc67b14 100644
--- a/modules/luci-base/luasrc/model/network.lua
+++ b/modules/luci-base/luasrc/model/network.lua
@@ -330,7 +330,7 @@ function init(cursor)
if i.family == "packet" then
_interfaces[name].flags = i.flags
_interfaces[name].stats = i.data
- _interfaces[name].macaddr = i.addr
+ _interfaces[name].macaddr = ipc.checkmac(i.addr)
elseif i.family == "inet" then
_interfaces[name].ipaddrs[#_interfaces[name].ipaddrs+1] = ipc.IPv4(i.addr, i.netmask)
elseif i.family == "inet6" then
@@ -543,6 +543,9 @@ end
function del_network(self, n)
local r = _uci:delete("network", n)
if r then
+ _uci:delete_all("luci", "ifstate",
+ function(s) return (s.interface == n) end)
+
_uci:delete_all("network", "alias",
function(s) return (s.interface == n) end)
@@ -998,7 +1001,10 @@ function protocol.ip6addrs(self)
if type(addrs) == "table" then
for n, addr in ipairs(addrs) do
- if type(addr["local-address"]) == "table" then
+ if type(addr["local-address"]) == "table" and
+ type(addr["local-address"].mask) == "number" and
+ type(addr["local-address"].address) == "string"
+ then
rv[#rv+1] = "%s/%d" %{
addr["local-address"].address,
addr["local-address"].mask
@@ -1227,8 +1233,7 @@ function interface.name(self)
end
function interface.mac(self)
- local mac = self:_ubus("macaddr")
- return mac and mac:upper()
+ return ipc.checkmac(self:_ubus("macaddr"))
end
function interface.ipaddrs(self)
diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua
index 84c747f2bd..12b20e4c38 100644
--- a/modules/luci-base/luasrc/sys.lua
+++ b/modules/luci-base/luasrc/sys.lua
@@ -138,17 +138,22 @@ local function _nethints(what, callback)
luci.ip.neighbors(nil, function(neigh)
if neigh.mac and neigh.family == 4 then
- _add(what, neigh.mac:upper(), neigh.dest:string(), nil, nil)
+ _add(what, neigh.mac:string(), neigh.dest:string(), nil, nil)
elseif neigh.mac and neigh.family == 6 then
- _add(what, neigh.mac:upper(), nil, neigh.dest:string(), nil)
+ _add(what, neigh.mac:string(), nil, neigh.dest:string(), nil)
end
end)
if fs.access("/etc/ethers") then
for e in io.lines("/etc/ethers") do
- mac, ip = e:match("^([a-f0-9]%S+) (%S+)")
- if mac and ip then
- _add(what, mac:upper(), ip, nil, nil)
+ mac, name = e:match("^([a-fA-F0-9:-]+)%s+(%S+)")
+ mac = luci.ip.checkmac(mac)
+ if mac and name then
+ if luci.ip.checkip4(name) then
+ _add(what, mac, name, nil, nil)
+ else
+ _add(what, mac, nil, nil, name)
+ end
end
end
end
@@ -158,8 +163,9 @@ local function _nethints(what, callback)
if s.leasefile and fs.access(s.leasefile) then
for e in io.lines(s.leasefile) do
mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
+ mac = luci.ip.checkmac(mac)
if mac and ip then
- _add(what, mac:upper(), ip, nil, name ~= "*" and name)
+ _add(what, mac, ip, nil, name ~= "*" and name)
end
end
end
@@ -169,7 +175,10 @@ local function _nethints(what, callback)
cur:foreach("dhcp", "host",
function(s)
for mac in luci.util.imatch(s.mac) do
- _add(what, mac:upper(), s.ip, nil, s.name)
+ mac = luci.ip.checkmac(mac)
+ if mac then
+ _add(what, mac, s.ip, nil, s.name)
+ end
end
end)
diff --git a/modules/luci-base/luasrc/tools/status.lua b/modules/luci-base/luasrc/tools/status.lua
index 95ff46df15..5012111815 100644
--- a/modules/luci-base/luasrc/tools/status.lua
+++ b/modules/luci-base/luasrc/tools/status.lua
@@ -4,6 +4,7 @@
module("luci.tools.status", package.seeall)
local uci = require "luci.model.uci".cursor()
+local ipc = require "luci.ip"
local function dhcp_leases_common(family)
local rv = { }
@@ -31,7 +32,7 @@ local function dhcp_leases_common(family)
if family == 4 and not ip:match(":") then
rv[#rv+1] = {
expires = (expire ~= 0) and os.difftime(expire, os.time()),
- macaddr = mac,
+ macaddr = ipc.checkmac(mac) or "00:00:00:00:00:00",
ipaddr = ip,
hostname = (name ~= "*") and name
}
@@ -74,19 +75,9 @@ local function dhcp_leases_common(family)
hostname = (name ~= "-") and name
}
elseif ip and iaid == "ipv4" and family == 4 then
- local mac, mac1, mac2, mac3, mac4, mac5, mac6
- if duid and type(duid) == "string" then
- mac1, mac2, mac3, mac4, mac5, mac6 = duid:match("^(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$")
- end
- if not (mac1 and mac2 and mac3 and mac4 and mac5 and mac6) then
- mac = "FF:FF:FF:FF:FF:FF"
- else
- mac = mac1..":"..mac2..":"..mac3..":"..mac4..":"..mac5..":"..mac6
- end
rv[#rv+1] = {
expires = (expire >= 0) and os.difftime(expire, os.time()),
- macaddr = duid,
- macaddr = mac:lower(),
+ 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",
ipaddr = ip,
hostname = (name ~= "-") and name
}
diff --git a/modules/luci-base/luasrc/util.luadoc b/modules/luci-base/luasrc/util.luadoc
index 805eeb7f8e..949aeb21c0 100644
--- a/modules/luci-base/luasrc/util.luadoc
+++ b/modules/luci-base/luasrc/util.luadoc
@@ -109,13 +109,13 @@ Remove leading and trailing whitespace from given string value.
]]
---[[
-Count the occurences of given substring in given string.
+Count the occurrences of given substring in given string.
@class function
@name cmatch
@param str String to search in
@param pattern String containing pattern to find
-@return Number of found occurences
+@return Number of found occurrences
]]
---[[
diff --git a/modules/luci-base/luasrc/view/cbi/browser.htm b/modules/luci-base/luasrc/view/cbi/browser.htm
index a18120141d..2abc975e8d 100644
--- a/modules/luci-base/luasrc/view/cbi/browser.htm
+++ b/modules/luci-base/luasrc/view/cbi/browser.htm
@@ -2,6 +2,7 @@
<%+cbi/valueheader%>
<input class="cbi-input-text" type="text"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
<script type="text/javascript">
+cbi_init()
cbi_browser_init('<%=cbid%>', '<%=resource%>', '<%=url('admin/filebrowser')%>'<%=self.default_path and ", '"..self.default_path.."'"%>);
</script>
<%+cbi/valuefooter%>
diff --git a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm
index 5cb31511f6..b4260707ef 100644
--- a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm
+++ b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm
@@ -24,70 +24,72 @@
end
-%>
-<ul style="margin:0; list-style-type:none; text-align:left">
- <% if self.allowlocal then %>
- <li style="padding:0.5em">
- <input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_empty") .. attr("name", cbid) .. attr("value", "") .. ifattr(checked[""], "checked", "checked")%> /> &#160;
- <label<%=attr("for", cbid .. "_empty")%>></label>
- <label<%=attr("for", cbid .. "_empty")%> style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
- <strong><%:Device%></strong>
- <% if self.allowany and self.allowlocal then %>(<%:input%>)<% end %>
- </label>
- </li>
- <% end %>
- <% if self.allowany then %>
- <li style="padding:0.5em">
- <input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_any") .. attr("name", cbid) .. attr("value", "*") .. ifattr(checked["*"], "checked", "checked")%> /> &#160;
- <label<%=attr("for", cbid .. "_any")%>></label>
- <label<%=attr("for", cbid .. "_any")%> style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
- <strong><%:Any zone%></strong>
- <% if self.allowany and self.allowlocal then %>(<%:forward%>)<% end %>
- </label>
- </li>
- <% end %>
- <%
- for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do
- if zone:name() ~= self.exclude then
- selected = selected or (value == zone:name())
- %>
- <li style="padding:0.5em">
- <input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(checked[zone:name()], "checked", "checked")%> /> &#160;
- <label<%=attr("for", cbid .. "." .. zone:name())%>></label>
- <label<%=attr("for", cbid .. "." .. zone:name())%> style="background-color:<%=zone:get_color()%>" class="zonebadge">
- <strong><%=zone:name()%>:</strong>
- <%
- local zempty = true
- for _, net in ipairs(zone:get_networks()) do
- net = nwm:get_network(net)
- if net then
- zempty = false
- %>
- <span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>:
+<span>
+ <ul style="margin:0; list-style-type:none; text-align:left">
+ <% if self.allowlocal then %>
+ <li style="padding:0.5em">
+ <input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_empty") .. attr("name", cbid) .. attr("value", "") .. ifattr(checked[""], "checked", "checked")%> /> &#160;
+ <label<%=attr("for", cbid .. "_empty")%>></label>
+ <label<%=attr("for", cbid .. "_empty")%> style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
+ <strong><%:Device%></strong>
+ <% if self.allowany and self.allowlocal then %>(<%:input%>)<% end %>
+ </label>
+ </li>
+ <% end %>
+ <% if self.allowany then %>
+ <li style="padding:0.5em">
+ <input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_any") .. attr("name", cbid) .. attr("value", "*") .. ifattr(checked["*"], "checked", "checked")%> /> &#160;
+ <label<%=attr("for", cbid .. "_any")%>></label>
+ <label<%=attr("for", cbid .. "_any")%> style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
+ <strong><%:Any zone%></strong>
+ <% if self.allowany and self.allowlocal then %>(<%:forward%>)<% end %>
+ </label>
+ </li>
+ <% end %>
+ <%
+ for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do
+ if zone:name() ~= self.exclude then
+ selected = selected or (value == zone:name())
+ %>
+ <li style="padding:0.5em">
+ <input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(checked[zone:name()], "checked", "checked")%> /> &#160;
+ <label<%=attr("for", cbid .. "." .. zone:name())%>></label>
+ <label<%=attr("for", cbid .. "." .. zone:name())%> style="background-color:<%=zone:get_color()%>" class="zonebadge">
+ <strong><%=zone:name()%>:</strong>
<%
- local nempty = true
- for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
- nempty = false
- %>
- <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
- <% end %>
- <% if nempty then %><em><%:(empty)%></em><% end %>
- </span>
- <% end end %>
- <% if zempty then %><em><%:(empty)%></em><% end %>
- </label>
- </li>
- <% end end %>
+ local zempty = true
+ for _, net in ipairs(zone:get_networks()) do
+ net = nwm:get_network(net)
+ if net then
+ zempty = false
+ %>
+ <span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>:
+ <%
+ local nempty = true
+ for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
+ nempty = false
+ %>
+ <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
+ <% end %>
+ <% if nempty then %><em><%:(empty)%></em><% end %>
+ </span>
+ <% end end %>
+ <% if zempty then %><em><%:(empty)%></em><% end %>
+ </label>
+ </li>
+ <% end end %>
- <% if self.widget ~= "checkbox" and not self.nocreate then %>
- <li style="padding:0.5em">
- <input class="cbi-input-radio" data-update="click change" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> /> &#160;
- <label<%=attr("for", cbid .. "_new")%>></label>
- <div onclick="document.getElementById('<%=cbid%>_new').checked=true" class="zonebadge" style="background-color:<%=fwm.zone.get_color()%>">
- <em><%:unspecified -or- create:%>&#160;</em>
- <input type="text"<%=attr("name", cbid .. ".newzone") .. ifattr(not selected, "value", luci.http.formvalue(cbid .. ".newzone") or self.default)%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
- </div>
- </li>
- <% end %>
-</ul>
+ <% if self.widget ~= "checkbox" and not self.nocreate then %>
+ <li style="padding:0.5em">
+ <input class="cbi-input-radio" data-update="click change" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> /> &#160;
+ <label<%=attr("for", cbid .. "_new")%>></label>
+ <div onclick="document.getElementById('<%=cbid%>_new').checked=true" class="zonebadge" style="background-color:<%=fwm.zone.get_color()%>">
+ <em><%:unspecified -or- create:%>&#160;</em>
+ <input type="text"<%=attr("name", cbid .. ".newzone") .. ifattr(not selected, "value", luci.http.formvalue(cbid .. ".newzone") or self.default)%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
+ </div>
+ </li>
+ <% end %>
+ </ul>
+</span>
<%+cbi/valuefooter%>
diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua
index 2cb2108b9f..33f6a67038 100644
--- a/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua
+++ b/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua
@@ -258,7 +258,6 @@ function iface_status(ifaces)
type = device:type(),
ifname = device:name(),
macaddr = device:mac(),
- macaddr = device:mac(),
is_up = device:is_up(),
rx_bytes = device:rx_bytes(),
tx_bytes = device:tx_bytes(),
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua
index 2acda0b73b..66d9942a11 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua
@@ -2,6 +2,7 @@
-- Licensed to the public under the Apache License 2.0.
local ipc = require "luci.ip"
+local sys = require "luci.sys"
local o
require "luci.util"
@@ -311,10 +312,10 @@ end
hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)"))
-ipc.neighbors({ family = 4 }, function(n)
- if n.mac and n.dest then
- ip:value(n.dest:string())
- mac:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() })
+sys.net.host_hints(function(m, v4, v6, name)
+ if m and v4 then
+ ip:value(v4)
+ mac:value(m, "%s (%s)" %{ m, name or v4 })
end
end)
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/hosts.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/hosts.lua
index fafacf35c5..46945af58b 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/hosts.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/hosts.lua
@@ -3,6 +3,7 @@
-- Licensed to the public under the Apache License 2.0.
local ipc = require "luci.ip"
+local sys = require "luci.sys"
m = Map("dhcp", translate("Hostnames"))
@@ -19,9 +20,11 @@ ip = s:option(Value, "ip", translate("IP address"))
ip.datatype = "ipaddr"
ip.rmempty = true
-ipc.neighbors({ }, function(n)
- if n.mac and n.dest and not n.dest:is6linklocal() then
- ip:value(n.dest:string(), "%s (%s)" %{ n.dest:string(), n.mac })
+sys.net.host_hints(function(mac, v4, v6, name)
+ v6 = v6 and ipc.IPv6(v6)
+
+ if v4 or (v6 and not v6:is6linklocal()) then
+ ip:value(tostring(v4 or v6), "%s (%s)" %{ tostring(v4 or v6), name or mac })
end
end)
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua
index 4fc71cefab..8e7a3b0667 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua
@@ -16,6 +16,7 @@ local has_firewall = fs.access("/etc/config/firewall")
m = Map("network", translate("Interfaces") .. " - " .. arg[1]:upper(), translate("On this page you can configure the network interfaces. You can bridge several interfaces by ticking the \"bridge interfaces\" field and enter the names of several network interfaces separated by spaces. You can also use <abbr title=\"Virtual Local Area Network\">VLAN</abbr> notation <samp>INTERFACE.VLANNR</samp> (<abbr title=\"for example\">e.g.</abbr>: <samp>eth0.1</samp>)."))
m.redirect = luci.dispatcher.build_url("admin", "network", "network")
m:chain("wireless")
+m:chain("luci")
if has_firewall then
m:chain("firewall")
@@ -27,18 +28,52 @@ fw.init(m.uci)
local net = nw:get_network(arg[1])
+local function set_ifstate(name, option, value)
+ local found = false
+
+ m.uci:foreach("luci", "ifstate", function (s)
+ if s.interface == name then
+ m.uci:set("luci", s[".name"], option, value)
+ found = true
+ return false
+ end
+ end)
+
+ if not found then
+ local sid = m.uci:add("luci", "ifstate")
+ m.uci:set("luci", sid, "interface", name)
+ m.uci:set("luci", sid, option, value)
+ end
+
+ m.uci:save("luci")
+end
+
+local function get_ifstate(name, option)
+ local val
+
+ m.uci:foreach("luci", "ifstate", function (s)
+ if s.interface == name then
+ val = m.uci:get("luci", s[".name"], option)
+ return false
+ end
+ end)
+
+ return val
+end
+
local function backup_ifnames(is_bridge)
- if not net:is_floating() and not m:get(net:name(), "_orig_ifname") then
+ if not net:is_floating() and not get_ifstate(net:name(), "ifname") then
local ifcs = net:get_interfaces() or { net:get_interface() }
if ifcs then
local _, ifn
local ifns = { }
for _, ifn in ipairs(ifcs) do
- ifns[#ifns+1] = ifn:name()
+ local wif = ifn:get_wifinet()
+ ifns[#ifns+1] = wif and wif:id() or ifn:name()
end
if #ifns > 0 then
- m:set(net:name(), "_orig_ifname", table.concat(ifns, " "))
- m:set(net:name(), "_orig_bridge", tostring(net:is_bridge()))
+ set_ifstate(net:name(), "ifname", table.concat(ifns, " "))
+ set_ifstate(net:name(), "bridge", tostring(net:is_bridge()))
end
end
end
@@ -84,10 +119,10 @@ if m:formvalue("cbid.network.%s._switch" % net:name()) then
elseif net:is_floating() and not proto:is_floating() then
-- if we have backup data, then re-add all orphaned interfaces
-- from it and restore the bridge choice
- local br = (m:get(net:name(), "_orig_bridge") == "true")
+ local br = (get_ifstate(net:name(), "bridge") == "true")
local ifn
local ifns = { }
- for ifn in ut.imatch(m:get(net:name(), "_orig_ifname")) do
+ for ifn in ut.imatch(get_ifstate(net:name(), "ifname")) do
ifn = nw:get_interface(ifn)
if ifn and not ifn:get_network() then
proto:add_interface(ifn)
@@ -114,9 +149,7 @@ if m:formvalue("cbid.network.%s._switch" % net:name()) then
for k, v in pairs(m:get(net:name())) do
if k:sub(1,1) ~= "." and
k ~= "type" and
- k ~= "ifname" and
- k ~= "_orig_ifname" and
- k ~= "_orig_bridge"
+ k ~= "ifname"
then
m:del(net:name(), k)
end
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm
index 5f2c074939..f474c71568 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm
@@ -53,7 +53,7 @@
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td class="cbi-value-field"><%=v.dest%></td>
<td class="cbi-value-field"><%=v.mac%></td>
- <td class="cbi-value-field"><%=v.dev%></td>
+ <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></td>
</tr>
<%
style = not style
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm
index 3e3f65d919..b32ef78263 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm
@@ -54,6 +54,9 @@
</div>
</form>
</div>
+ <% if reset_avail then %>
+ <div class="alert-message warning"><%:Custom files (certificates, scripts) may remain on the system. To prevent this, perform a factory-reset first.%></div>
+ <% end %>
</fieldset>
<br />
diff --git a/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/dhcp.lua b/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/dhcp.lua
index 9a1c1fea45..bcc26cd442 100644
--- a/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/dhcp.lua
+++ b/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/dhcp.lua
@@ -3,7 +3,7 @@
-- Licensed to the public under the Apache License 2.0.
local uci = require "luci.model.uci".cursor()
-local ipc = require "luci.ip"
+local sys = require "luci.sys"
local wa = require "luci.tools.webadmin"
local fs = require "nixio.fs"
@@ -87,12 +87,11 @@ name = s2:option(Value, "name", translate("Hostname"))
mac = s2:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
ip = s2:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
-ipc.neighbors({ family = 4 }, function(n)
- if n.mac and n.dest then
- ip:value(n.dest:string())
- mac:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() })
+sys.host_hints(function(m, v4, v6, name)
+ if m and v4 then
+ ip:value(v4)
+ mac:value(m, "%s (%s)" %{ m, name or v4 })
end
end)
return m
-