summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-full/luasrc
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-13 22:54:38 +0000
committerSteven Barth <steven@midlink.org>2008-08-13 22:54:38 +0000
commit58f183a28269ded9f41eb980b63a607421689f63 (patch)
tree5cd1a4e51a2a8c5d8e90703ef232f7c064194fe4 /modules/admin-full/luasrc
parent741e0c89a4e4e9821731a28d4117cdac27539a19 (diff)
Completed rewrite of network interface configuration page
Diffstat (limited to 'modules/admin-full/luasrc')
-rw-r--r--modules/admin-full/luasrc/controller/admin/network.lua4
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua57
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/network.lua20
3 files changed, 62 insertions, 19 deletions
diff --git a/modules/admin-full/luasrc/controller/admin/network.lua b/modules/admin-full/luasrc/controller/admin/network.lua
index fa7a8c719a..cc79e57a50 100644
--- a/modules/admin-full/luasrc/controller/admin/network.lua
+++ b/modules/admin-full/luasrc/controller/admin/network.lua
@@ -26,12 +26,12 @@ function index()
local page = node("admin", "network", "vlan")
page.target = cbi("admin_network/vlan")
page.title = i18n("a_n_switch", "Switch")
- page.order = 10
+ page.order = 20
local page = node("admin", "network", "network")
page.target = cbi("admin_network/network")
page.title = i18n("interfaces", "Schnittstellen")
- page.order = 20
+ page.order = 10
luci.model.uci.foreach("network", "interface",
function (section)
local ifc = section[".name"]
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
index 681bfcd6db..ae5f2aeab8 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua
@@ -12,6 +12,7 @@ You may obtain a copy of the License at
$Id$
]]--
+require("luci.tools.webadmin")
arg[1] = arg[1] or ""
m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
@@ -37,6 +38,42 @@ for i,d in ipairs(luci.sys.net.devices()) do
end
end
+local zones = luci.tools.webadmin.network_get_zones(arg[1])
+if zones and #zones == 0 then
+ m:chain("firewall")
+
+ fwzone = s:option(Value, "_fwzone",
+ translate("network_interface_fwzone"),
+ translate("network_interface_fwzone_desc"))
+ fwzone.rmempty = true
+ fwzone:value("", "- " .. translate("none") .. " -")
+ fwzone:value(arg[1])
+ luci.model.uci.foreach("firewall", "zone",
+ function (section)
+ fwzone:value(section.name)
+ end
+ )
+
+ function fwzone.write(self, section, value)
+ local zone = luci.tools.webadmin.firewall_find_zone(value)
+ local stat
+
+ if not zone then
+ stat = luci.model.uci.section("firewall", "zone", nil, {
+ name = value,
+ network = section
+ })
+ else
+ local net = luci.model.uci.get("firewall", zone, "network")
+ net = (net or value) .. " " .. section
+ stat = luci.model.uci.set("firewall", zone, "network", net)
+ end
+
+ if stat then
+ self.render = function() end
+ end
+ end
+end
ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
ipaddr.rmempty = true
@@ -79,24 +116,30 @@ mac.optional = true
user = s:option(Value, "username", translate("username"))
user.rmempty = true
user:depends("proto", "pptp")
-user:depends("proto", "ppoe")
+user:depends("proto", "pppoe")
pass = s:option(Value, "password", translate("password"))
pass.rmempty = true
pass:depends("proto", "pptp")
-pass:depends("proto", "ppoe")
+pass:depends("proto", "pppoe")
-ka = s:option(Value, "keepalive")
+ka = s:option(Value, "keepalive",
+ translate("network_interface_keepalive"),
+ translate("network_interface_keepalive_desc")
+)
ka.rmempty = true
ka:depends("proto", "pptp")
-ka:depends("proto", "ppoe")
+ka:depends("proto", "pppoe")
-demand = s:option(Value, "demand")
+demand = s:option(Value, "demand",
+ translate("network_interface_demand"),
+ translate("network_interface_demand_desc")
+)
demand.rmempty = true
demand:depends("proto", "pptp")
-demand:depends("proto", "ppoe")
+demand:depends("proto", "pppoe")
-srv = s:option(Value, "server")
+srv = s:option(Value, "server", translate("network_interface_server"))
srv:depends("proto", "pptp")
srv.rmempty = true
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
index 00c001e50a..0fffd32b61 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
@@ -16,12 +16,12 @@ require("luci.sys")
require("luci.tools.webadmin")
-m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
+m = Map("network", translate("interfaces"))
local created
local netstat = luci.sys.net.deviceinfo()
-s = m:section(TypedSection, "interface", translate("interfaces"))
+s = m:section(TypedSection, "interface", "")
s.addremove = true
s.extedit = luci.http.getenv("REQUEST_URI") .. "/%s"
s.template = "cbi/tblsection"
@@ -50,6 +50,9 @@ function up.write(self, section, value)
os.execute(call .. " " .. section)
end
+ifname = s:option(DummyValue, "ifname", translate("device"))
+ifname.stateful = true
+
hwaddr = s:option(DummyValue, "_hwaddr")
function hwaddr.cfgvalue(self, section)
local ix = self.map:stateget(section, "ifname") or ""
@@ -57,17 +60,14 @@ function hwaddr.cfgvalue(self, section)
end
-ipaddr = s:option(DummyValue, "ipaddr")
+ipaddr = s:option(DummyValue, "ipaddr", translate("addresses"))
function ipaddr.cfgvalue(self, section)
- local ip = self.map:stateget(section, "ipaddr")
- local nm = self.map:stateget(section, "netmask")
-
- local parsed = ip and luci.ip.IPv4(ip, nm)
- return parsed and parsed:string() or ""
+ local addr = luci.tools.webadmin.network_get_addresses(section)
+ return table.concat(addr, ", ")
end
-txrx = s:option(DummyValue, "_rx", "TX / RX")
+txrx = s:option(DummyValue, "_txrx")
function txrx.cfgvalue(self, section)
local ix = self.map:stateget(section, "ifname")
@@ -81,7 +81,7 @@ function txrx.cfgvalue(self, section)
return string.format("%s / %s", tx, rx)
end
-errors = s:option(DummyValue, "_err", "Errors", "TX / RX")
+errors = s:option(DummyValue, "_err")
function errors.cfgvalue(self, section)
local ix = self.map:stateget(section, "ifname")