diff options
author | Steven Barth <steven@midlink.org> | 2009-10-28 17:38:09 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-10-28 17:38:09 +0000 |
commit | 1e9b205464d0611db5fe7e036c3628ebe484c803 (patch) | |
tree | f4e02cd1907fc21b93594e0b0b077af8739e7ecf /modules/niu/luasrc/model/cbi | |
parent | 9c22efeddbc4144f1bb015fa09d2f0946dc086e5 (diff) |
More NIU
Diffstat (limited to 'modules/niu/luasrc/model/cbi')
4 files changed, 155 insertions, 0 deletions
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 0000000000..b61e4f4007 --- /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 0000000000..704e9ae669 --- /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 0000000000..64a587c813 --- /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 0000000000..3e8e297155 --- /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 |