summaryrefslogtreecommitdiffhomepage
path: root/modules/niu/luasrc/model
diff options
context:
space:
mode:
Diffstat (limited to 'modules/niu/luasrc/model')
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/assign1.lua38
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/etherwan.lua13
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/lan1.lua3
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/routes1.lua10
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/wan.lua36
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/wandevice.lua26
6 files changed, 101 insertions, 25 deletions
diff --git a/modules/niu/luasrc/model/cbi/niu/network/assign1.lua b/modules/niu/luasrc/model/cbi/niu/network/assign1.lua
index e226e23767..fdd0dc00b7 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/assign1.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/assign1.lua
@@ -14,10 +14,39 @@ $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 function date_format(secs)
+ local suff = {"min", "h", "d"}
+ local mins = 0
+ local hour = 0
+ local days = 0
+
+ secs = math.floor(secs)
+ if secs > 60 then
+ mins = math.floor(secs / 60)
+ secs = secs % 60
+ end
+
+ if mins > 60 then
+ hour = math.floor(mins / 60)
+ mins = mins % 60
+ end
+
+ if hour > 24 then
+ days = math.floor(hour / 24)
+ hour = hour % 24
+ end
+
+ if days > 0 then
+ return string.format("%.0fd %02.0fh %02.0fmin %02.0fs", days, hour, mins, secs)
+ else
+ return string.format("%02.0fh %02.0fmin %02.0fs", hour, mins, secs)
+ end
+end
+
+m2 = Map("dhcp", "Display and Customize Address Assignment")
local leasefn, leasefp, leases
uci:foreach("dhcp", "dnsmasq",
@@ -42,11 +71,12 @@ if leases then
ltime = v:option(DummyValue, 1, translate("Leasetime remaining"))
function ltime.cfgvalue(self, ...)
local value = DummyValue.cfgvalue(self, ...)
- return wa.date_format(os.difftime(tonumber(value), os.time()))
+ return date_format(os.difftime(tonumber(value), os.time()))
end
end
-s = m2:section(TypedSection, "host")
+s = m2:section(TypedSection, "host", "Static Assignment",
+"You can assign fixed addresses and DNS names to devices in you local network to make reaching them more easy.")
s.addremove = true
s.anonymous = true
s.template = "cbi/tblsection"
diff --git a/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua b/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua
index e3da1c0aab..4f2744b816 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua
@@ -23,7 +23,7 @@ local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")()
local has_pppoa = fs.glob("/usr/lib/pppd/*/pppoatm.so")()
-m = Map("network", translate("m_n_internet"))
+m = Map("network", "Configure Ethernet Adapter")
nw.init(m.uci)
s = m:section(NamedSection, "wan", "interface")
@@ -32,15 +32,14 @@ s.addremove = false
s:tab("general", translate("General Settings"))
s:tab("expert", translate("Expert Settings"))
-p = s:taboption("general", ListValue, "proto", translate("Protocol"))
+p = s:taboption("general", ListValue, "proto", "Connection Type")
p.override_scheme = true
-p.default = "static"
-p:value("static", translate("static"))
-p:value("dhcp", "DHCP")
-if has_pppoe then p:value("pppoe", "PPPoE") end
+p.default = "dhcp"
+p:value("dhcp", "Cable / Ethernet / DHCP")
+if has_pppoe then p:value("pppoe", "DSL / PPPoE") end
if has_pppoa then p:value("pppoa", "PPPoA") end
if has_pptp then p:value("pptp", "PPTP") end
-p:value("none", translate("none"))
+p:value("static", "Static Ethernet")
diff --git a/modules/niu/luasrc/model/cbi/niu/network/lan1.lua b/modules/niu/luasrc/model/cbi/niu/network/lan1.lua
index 77b0fa76e8..e8069d5b31 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/lan1.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/lan1.lua
@@ -100,6 +100,9 @@ s:tab("expert", translate("Expert Settings"))
start = s:taboption("expert", Value, "start", translate("First leased address"))
limit = s:taboption("expert", Value, "limit", translate("Number of leased addresses"), "")
time = s:taboption("expert", Value, "leasetime", "Lease Time")
+local dd = s:taboption("expert", Flag, "dynamicdhcp", "Also generate addresses for unknown devices")
+dd.rmempty = false
+dd.default = "1"
return m, m2
diff --git a/modules/niu/luasrc/model/cbi/niu/network/routes1.lua b/modules/niu/luasrc/model/cbi/niu/network/routes1.lua
index a1d150807d..094831e72f 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/routes1.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/routes1.lua
@@ -12,12 +12,15 @@ You may obtain a copy of the License at
$Id$
]]--
-m = Map("network", translate("Routes"), translate("a_n_routes1"))
+m = Map("network", translate("Display and Customize Routing"),
+translate("With additional static routes you allow computers on your network to reach unannounced remote hosts or networks."))
local routes6 = luci.sys.net.routes6()
local bit = require "bit"
-s = m:section(TypedSection, "route", translate("Static IPv4 Routes"))
+m:append(Template("niu/network/rtable"))
+
+s = m:section(TypedSection, "route", "Static IPv4 Routes")
s.addremove = true
s.anonymous = true
@@ -30,7 +33,7 @@ s:option(Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\
s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
if routes6 then
- s = m:section(TypedSection, "route6", translate("Static IPv6 Routes"))
+ s = m:section(TypedSection, "route6", "Static IPv6 Routes")
s.addremove = true
s.anonymous = true
@@ -51,5 +54,4 @@ m.uci:foreach("network", "interface", function(s)
end
end)
-
return m
diff --git a/modules/niu/luasrc/model/cbi/niu/network/wan.lua b/modules/niu/luasrc/model/cbi/niu/network/wan.lua
index 6c23738eb6..b7351ff19b 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/wan.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/wan.lua
@@ -1,11 +1,45 @@
local cursor = require "luci.model.uci".cursor()
+
+if not cursor:get("network", "wan") then
+ cursor:section("network", "interface", "wan", {proto = "none"})
+ cursor:save("network")
+end
+
+local function deviceroute(self)
+ cursor:unload("network")
+ local wd = cursor:get("network", "wan", "_wandev") or ""
+
+ if wd == "none" then
+ cursor:set("network", "wan", "proto", "none")
+ end
+
+ if wd:find("ethernet:") == 1 then
+ cursor:set("network", "wan", "defaultroute", "1")
+ cursor:set("network", "wan", "ifname", wd:sub(10))
+ self:set_route("etherwan")
+ else
+ cursor:delete("network", "wan", "ifname")
+ end
+
+ if wd:find("wlan:") == 1 then
+
+ else
+ cursor:delete_all("wireless", "wifi-iface", {network = "wan"})
+ end
+
+ cursor:save("wireless")
+ cursor:save("network")
+end
+
+
local d = Delegator()
d.allow_finish = true
d.allow_back = true
d.allow_cancel = true
d:add("device", load("niu/network/wandevice"))
-d:add("etherwan", load("niu/network/etherwan"))
+d:add("deviceroute", deviceroute)
+d:set("etherwan", load("niu/network/etherwan"))
function d.on_cancel()
cursor:revert("network")
diff --git a/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua b/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua
index 1f65196f14..db7d902541 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua
@@ -12,19 +12,27 @@ You may obtain a copy of the License at
$Id$
]]--
-local cursor = require "luci.model.uci".cursor()
+local cursor = require "luci.model.uci".inst_state
local nw = require "luci.model.network"
nw.init(cursor)
-f = Form("wandev", "Internet Device")
-l = f:field(ListValue, "device", "Gerät")
-l:value("ethernet:eth0", "Ethernet / Cable / DSL (eth0)")
-l:value("none", "No Internet Connection")
+m = Map("network", "Configure Internet Connection")
+s = m:section(NamedSection, "wan", "interface", "Internet Connection Device")
+s.anonymous = true
+s.addremove = false
+
+l = s:option(ListValue, "_wandev", "Internet Connection via")
-function f.handle(self, state, data)
- if state == FORM_VALID then
-
+for _, iface in ipairs(nw.get_interfaces()) do
+ if iface:name():find("eth") == 1 then
+ local net = iface:get_network()
+ if not net or net:name() == "wan" or os.getenv("LUCI_SYSROOT") then
+ l:value("ethernet:%s" % iface:name(),
+ "Cable / DSL / Ethernet Adapter (%s)" % iface:name())
+ end
end
end
-return f
+l:value("none", "No Internet Connection")
+
+return m