summaryrefslogtreecommitdiffhomepage
path: root/modules/niu/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/niu/luasrc')
-rw-r--r--modules/niu/luasrc/controller/niu/network.lua10
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/assign.lua17
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/assign1.lua66
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/routes.lua17
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/routes1.lua55
-rw-r--r--modules/niu/luasrc/view/niu/network.htm10
6 files changed, 168 insertions, 7 deletions
diff --git a/modules/niu/luasrc/controller/niu/network.lua b/modules/niu/luasrc/controller/niu/network.lua
index b17e6e760..41da30a37 100644
--- a/modules/niu/luasrc/controller/niu/network.lua
+++ b/modules/niu/luasrc/controller/niu/network.lua
@@ -20,8 +20,14 @@ function index()
.dbtemplate = "niu/network"
entry({"niu", "network", "lan"},
- cbi("niu/network/lan", {on_success_to={"niu"}}), "Configure LAN")
+ cbi("niu/network/lan", {on_success_to={"niu"}}), "Configure LAN", 10)
entry({"niu", "network", "wan"},
- cbi("niu/network/wan", {on_success_to={"niu"}}), "Configure Internet")
+ cbi("niu/network/wan", {on_success_to={"niu"}}), "Configure Internet", 20)
+
+ entry({"niu", "network", "assign"}, cbi("niu/network/assign",
+ {on_success_to={"niu"}}), "Address Assignment", 30)
+
+ entry({"niu", "network", "routes"}, cbi("niu/network/routes",
+ {on_success_to={"niu"}}), "Custom Routing", 40)
end
diff --git a/modules/niu/luasrc/model/cbi/niu/network/assign.lua b/modules/niu/luasrc/model/cbi/niu/network/assign.lua
new file mode 100644
index 000000000..b61e4f400
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/network/assign.lua
@@ -0,0 +1,17 @@
+local cursor = require "luci.model.uci".cursor()
+local d = Delegator()
+d.allow_finish = true
+d.allow_back = true
+d.allow_cancel = true
+
+d:add("assign1", load("niu/network/assign1"))
+
+function d.on_cancel()
+ cursor:revert("dhcp")
+end
+
+function d.on_done()
+ cursor:commit("dhcp")
+end
+
+return d \ No newline at end of file
diff --git a/modules/niu/luasrc/model/cbi/niu/network/assign1.lua b/modules/niu/luasrc/model/cbi/niu/network/assign1.lua
new file mode 100644
index 000000000..704e9ae66
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/network/assign1.lua
@@ -0,0 +1,66 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+local uci = require "luci.model.uci".cursor()
+local sys = require "luci.sys"
+local wa = require "luci.tools.webadmin"
+local fs = require "nixio.fs"
+
+m2 = Map("dhcp", "Address Assignment")
+
+local leasefn, leasefp, leases
+uci:foreach("dhcp", "dnsmasq",
+ function(section)
+ leasefn = section.leasefile
+ end
+)
+local leasefp = leasefn and fs.access(leasefn) and io.lines(leasefn)
+if leasefp then
+ leases = {}
+ for lease in leasefp do
+ table.insert(leases, luci.util.split(lease, " "))
+ end
+end
+
+if leases then
+ v = m2:section(Table, leases, translate("dhcp_leases_active"))
+ ip = v:option(DummyValue, 3, translate("ipaddress"))
+
+ mac = v:option(DummyValue, 2, translate("macaddress"))
+
+ ltime = v:option(DummyValue, 1, translate("dhcp_timeremain"))
+ function ltime.cfgvalue(self, ...)
+ local value = DummyValue.cfgvalue(self, ...)
+ return wa.date_format(os.difftime(tonumber(value), os.time()))
+ end
+end
+
+s = m2:section(TypedSection, "host")
+s.addremove = true
+s.anonymous = true
+s.template = "cbi/tblsection"
+
+hn = s:option(Value, "name", translate("hostnames_hostname"))
+mac = s:option(Value, "mac", translate("macaddress"))
+ip = s:option(Value, "ip", translate("ipaddress"))
+sys.net.arptable(function(entry)
+ ip:value(entry["IP address"])
+ mac:value(
+ entry["HW address"],
+ entry["HW address"] .. " (" .. entry["IP address"] .. ")"
+ )
+end)
+
+
+return m2
diff --git a/modules/niu/luasrc/model/cbi/niu/network/routes.lua b/modules/niu/luasrc/model/cbi/niu/network/routes.lua
new file mode 100644
index 000000000..64a587c81
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/network/routes.lua
@@ -0,0 +1,17 @@
+local cursor = require "luci.model.uci".cursor()
+local d = Delegator()
+d.allow_finish = true
+d.allow_back = true
+d.allow_cancel = true
+
+d:add("routes1", load("niu/network/routes1"))
+
+function d.on_cancel()
+ cursor:revert("network")
+end
+
+function d.on_done()
+ cursor:commit("network")
+end
+
+return d \ No newline at end of file
diff --git a/modules/niu/luasrc/model/cbi/niu/network/routes1.lua b/modules/niu/luasrc/model/cbi/niu/network/routes1.lua
new file mode 100644
index 000000000..3e8e29715
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/network/routes1.lua
@@ -0,0 +1,55 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+m = Map("network", translate("a_n_routes"), translate("a_n_routes1"))
+
+local routes6 = luci.sys.net.routes6()
+local bit = require "bit"
+
+s = m:section(TypedSection, "route", translate("a_n_routes_static4"))
+s.addremove = true
+s.anonymous = true
+
+s.template = "cbi/tblsection"
+
+iface1 = s:option(ListValue, "interface", translate("interface"))
+
+s:option(Value, "target", translate("target"), translate("a_n_r_target1"))
+s:option(Value, "netmask", translate("netmask"), translate("a_n_r_netmask1")).rmemepty = true
+s:option(Value, "gateway", translate("gateway"))
+
+if routes6 then
+ s = m:section(TypedSection, "route6", translate("a_n_routes_static6"))
+ s.addremove = true
+ s.anonymous = true
+
+ s.template = "cbi/tblsection"
+
+ iface2 = s:option(ListValue, "interface", translate("interface"))
+
+ s:option(Value, "target", translate("target"), translate("a_n_r_target6"))
+ s:option(Value, "gateway", translate("gateway6")).rmempty = true
+end
+
+m.uci:foreach("network", "interface", function(s)
+ if s[".name"] ~= "loopback" then
+ iface:value(s[".name"])
+ if iface2 then
+ iface2:value(s[".name"])
+ end
+ end
+end)
+
+
+return m
diff --git a/modules/niu/luasrc/view/niu/network.htm b/modules/niu/luasrc/view/niu/network.htm
index 71296371f..a022b0af8 100644
--- a/modules/niu/luasrc/view/niu/network.htm
+++ b/modules/niu/luasrc/view/niu/network.htm
@@ -7,10 +7,6 @@ local nws = {}
str.uci_state:foreach("network", "interface", function(s)
nws[#nws+1] = s
end)
-
-local function cmp(a, b)
- return (a.order or 100) < (b.order or 100)
-end
%>
<div>Status:</div>
<table>
@@ -23,7 +19,11 @@ for _, v in ipairs(nws) do if v[".name"] ~= "loopback" then
<br />
<ul>
<%
-for k, v in utl.spairs(dsp.node("niu", "network").nodes, cmp) do
+local nodes = dsp.node("niu", "network").nodes
+local function cmp(a, b)
+ return (nodes[a].order or 100) < (nodes[b].order or 100)
+end
+for k, v in utl.spairs(nodes, cmp) do
%>
<li><a href="<%=dsp.build_url("niu", "network", k)%>"><%=v.title%></a></li>
<%