diff options
Diffstat (limited to 'modules/luci-mod-admin-full')
7 files changed, 118 insertions, 59 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua index 055142b53e..52e347d07b 100644 --- a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua +++ b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua @@ -178,13 +178,7 @@ function action_flashops() local image_tmp = "/tmp/firmware.img" local function image_supported() - -- XXX: yay... - return ( 0 == os.execute( - ". /lib/functions.sh; " .. - "include /lib/upgrade; " .. - "platform_check_image %q >/dev/null" - % image_tmp - ) ) + return (os.execute("sysupgrade -T %q >/dev/null" % image_tmp) == 0) end local function image_checksum() 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 88e81bb18c..997a9274d2 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 @@ -1,7 +1,7 @@ -- Copyright 2008 Steven Barth <steven@midlink.org> -- Licensed to the public under the Apache License 2.0. -local sys = require "luci.sys" +local ipc = require "luci.ip" m = Map("dhcp", translate("DHCP and DNS"), translate("Dnsmasq is a combined <abbr title=\"Dynamic Host Configuration Protocol" .. @@ -232,12 +232,11 @@ ip.datatype = "or(ip4addr,'ignore')" hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)")) -sys.net.arptable(function(entry) - ip:value(entry["IP address"]) - mac:value( - entry["HW address"], - entry["HW address"] .. " (" .. entry["IP 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() }) + end end) function ip.validate(self, value, section) 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 da7c1181f7..fafacf35c5 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 @@ -1,9 +1,9 @@ -- Copyright 2008 Steven Barth <steven@midlink.org> --- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org> +-- Copyright 2010-2015 Jo-Philipp Wich <jow@openwrt.org> -- Licensed to the public under the Apache License 2.0. -require("luci.sys") -require("luci.util") +local ipc = require "luci.ip" + m = Map("dhcp", translate("Hostnames")) s = m:section(TypedSection, "domain", translate("Host entries")) @@ -19,12 +19,10 @@ ip = s:option(Value, "ip", translate("IP address")) ip.datatype = "ipaddr" ip.rmempty = true -local arptable = luci.sys.net.arptable() or {} -for i, dataset in ipairs(arptable) do - ip:value( - dataset["IP address"], - "%s (%s)" %{ dataset["IP address"], dataset["HW address"] } - ) -end +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 }) + end +end) return m 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 eabb257680..c2e5c72285 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 @@ -14,6 +14,7 @@ local has_dnsmasq = fs.access("/etc/config/dhcp") 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") if has_firewall then diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/routes.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/routes.lua index 01580f1016..ac02b156e9 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/routes.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/routes.lua @@ -1,14 +1,14 @@ -- Copyright 2008 Steven Barth <steven@midlink.org> -- Licensed to the public under the Apache License 2.0. -require("luci.tools.webadmin") +local wa = require "luci.tools.webadmin" +local fs = require "nixio.fs" + m = Map("network", translate("Routes"), translate("Routes specify over which interface and gateway a certain host or network " .. "can be reached.")) -local routes6 = luci.sys.net.routes6() - s = m:section(TypedSection, "route", translate("Static IPv4 Routes")) s.addremove = true s.anonymous = true @@ -16,7 +16,7 @@ s.anonymous = true s.template = "cbi/tblsection" iface = s:option(ListValue, "interface", translate("Interface")) -luci.tools.webadmin.cbi_add_networks(iface) +wa.cbi_add_networks(iface) t = s:option(Value, "target", translate("Target"), translate("Host-<abbr title=\"Internet Protocol Address\">IP</abbr> or Network")) t.datatype = "ip4addr" @@ -41,7 +41,7 @@ mtu.placeholder = 1500 mtu.datatype = "range(64,9000)" mtu.rmempty = true -if routes6 then +if fs.access("/proc/net/ipv6_route") then s = m:section(TypedSection, "route6", translate("Static IPv6 Routes")) s.addremove = true s.anonymous = true @@ -49,7 +49,7 @@ if routes6 then s.template = "cbi/tblsection" iface = s:option(ListValue, "interface", translate("Interface")) - luci.tools.webadmin.cbi_add_networks(iface) + wa.cbi_add_networks(iface) t = s:option(Value, "target", translate("Target"), translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address or Network (CIDR)")) t.datatype = "ip6addr" diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm index ea60a7f078..b7c44f9073 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm @@ -1,12 +1,12 @@ <%# Copyright 2008-2009 Steven Barth <steven@midlink.org> - Copyright 2008-2013 Jo-Philipp Wich <jow@openwrt.org> + Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org> Licensed to the public under the Apache License 2.0. -%> <%- - local sys = require "luci.sys" + local ip = require "luci.ip" local fs = require "nixio.fs" local utl = require "luci.util" local uci = require "luci.model.uci".cursor() @@ -90,7 +90,9 @@ local devices = ntm:get_wifidevs() local arpcache = { } - sys.net.arptable(function(e) arpcache[e["HW address"]:upper()] = e["IP address"] end) + ip.neighbors({ family = 4 }, function(n) + if n.mac and n.dest then arpcache[n.mac:upper()] = n.dest:string() end + end) local netlist = { } local netdevs = { } 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 2d9a4a3dc8..82dd3a7dfe 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 @@ -1,15 +1,33 @@ <%# Copyright 2008-2009 Steven Barth <steven@midlink.org> - Copyright 2008-2009 Jo-Philipp Wich <jow@openwrt.org> + Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org> Licensed to the public under the Apache License 2.0. -%> <%- - require "luci.sys" require "luci.tools.webadmin" require "nixio.fs" + local ip = require "luci.ip" local style = true + local _, v + + local rtn = { + [255] = "local", + [254] = "main", + [253] = "default", + [0] = "unspec" + } + + if nixio.fs.access("/etc/iproute2/rt_tables") then + local ln + for ln in io.lines("/etc/iproute2/rt_tables") do + local i, n = ln:match("^(%d+)%s+(%S+)") + if i and n then + rtn[tonumber(i)] = n + end + end + end -%> <%+header%> @@ -18,7 +36,7 @@ <h2><a id="content" name="content"><%:Routes%></a></h2> <div class="cbi-map-descr"><%:The following rules are currently active on this system.%></div> - <fieldset class="cbi-section" id="cbi-table-table"> + <fieldset class="cbi-section"> <legend>ARP</legend> <div class="cbi-section-node"> <table class="cbi-section-table"> @@ -28,19 +46,26 @@ <th class="cbi-section-table-cell"><%:Interface%></th> </tr> - <% luci.sys.net.arptable(function(e) %> + <% + for _, v in ipairs(ip.neighbors({ family = 4 })) do + if v.mac then + %> <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>"> - <td class="cbi-value-field"><%=e["IP address"]%></td> - <td class="cbi-value-field"><%=e["HW address"]%></td> - <td class="cbi-value-field"><%=e["Device"]%></td> + <td class="cbi-value-field"><%=v.dest%></td> + <td class="cbi-value-field"><%=v.mac%></td> + <td class="cbi-value-field"><%=v.dev%></td> </tr> - <% style = not style; end) %> + <% + style = not style + end + end + %> </table> </div> </fieldset> <br /> - <fieldset class="cbi-section" id="cbi-table-table"> + <fieldset class="cbi-section"> <legend><%_Active <abbr title="Internet Protocol Version 4">IPv4</abbr>-Routes%></legend> <div class="cbi-section-node"> @@ -50,25 +75,27 @@ <th class="cbi-section-table-cell"><%:Target%></th> <th class="cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Gateway%></th> <th class="cbi-section-table-cell"><%:Metric%></th> + <th class="cbi-section-table-cell"><%:Table%></th> </tr> - <% luci.sys.net.routes(function(rt) %> + <% for _, v in ipairs(ip.routes({ family = 4, type = 1 })) do %> <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>"> - <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(rt.device) or rt.device%></td> - <td class="cbi-value-field"><%=rt.dest:string()%></td> - <td class="cbi-value-field"><%=rt.gateway:string()%></td> - <td class="cbi-value-field"><%=rt.metric%></td> + <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or v.dev%></td> + <td class="cbi-value-field"><%=v.dest%></td> + <td class="cbi-value-field"><%=v.gw%></td> + <td class="cbi-value-field"><%=v.metric or 0%></td> + <td class="cbi-value-field"><%=rtn[v.table] or v.table%></td> </tr> - <% style = not style; end) %> + <% style = not style end %> </table> </div> </fieldset> <br /> - <% if nixio.fs.access("/proc/net/ipv6_route") then - style = true - fe80 = luci.ip.IPv6("fe80::/10") + <% + if nixio.fs.access("/proc/net/ipv6_route") then + style = true %> - <fieldset class="cbi-section" id="cbi-table-table"> + <fieldset class="cbi-section"> <legend><%_Active <abbr title="Internet Protocol Version 6">IPv6</abbr>-Routes%></legend> <div class="cbi-section-node"> @@ -76,17 +103,55 @@ <tr class="cbi-section-table-titles"> <th class="cbi-section-table-cell"><%:Network%></th> <th class="cbi-section-table-cell"><%:Target%></th> - <th class="cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 6">IPv6</abbr>-Gateway%></th> + <th class="cbi-section-table-cell"><%:Source%></th> <th class="cbi-section-table-cell"><%:Metric%></th> + <th class="cbi-section-table-cell"><%:Table%></th> + </tr> + <% + for _, v in ipairs(ip.routes({ family = 6, type = 1 })) do + if v.dest and not v.dest:is6linklocal() then + %> + <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>"> + <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></td> + <td class="cbi-value-field"><%=v.dest%></td> + <td class="cbi-value-field"><%=v.from%></td> + <td class="cbi-value-field"><%=v.metric or 0%></td> + <td class="cbi-value-field"><%=rtn[v.table] or v.table%></td> + </tr> + <% + style = not style + end + end + %> + </table> + </div> + </fieldset> + <br /> + + <fieldset class="cbi-section"> + <legend><%:IPv6 Neighbours%></legend> + + <div class="cbi-section-node"> + <table class="cbi-section-table"> + <tr class="cbi-section-table-titles"> + <th class="cbi-section-table-cell"><%:IPv6-Address%></th> + <th class="cbi-section-table-cell"><%:MAC-Address%></th> + <th class="cbi-section-table-cell"><%:Interface%></th> </tr> - <% luci.sys.net.routes6(function(rt) if fe80:contains(rt.dest) then return end %> + <% + for _, v in ipairs(ip.neighbors({ family = 6 })) do + if v.dest and not v.dest:is6linklocal() and v.mac then + %> <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>"> - <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(rt.device) or '(' .. rt.device .. ')'%></td> - <td class="cbi-value-field"><%=rt.dest:string()%></td> - <td class="cbi-value-field"><%=rt.source:string()%></td> - <td class="cbi-value-field"><%=rt.metric_raw:upper()%></td> + <td class="cbi-value-field"><%=v.dest%></td> + <td class="cbi-value-field"><%=v.mac%></td> + <td class="cbi-value-field"><%=luci.tools.webadmin.iface_get_network(v.dev) or '(' .. v.dev .. ')'%></td> </tr> - <% style = not style; end) %> + <% + style = not style + end + end + %> </table> </div> </fieldset> |