applications/luci-fw: Added support for luci-mini
modules/admin-mini: Added portforwarding page, and UCI changes, apply and revert pages
This commit is contained in:
parent
9b1ef9e2b1
commit
429473aed8
11 changed files with 219 additions and 9 deletions
|
@ -4,7 +4,13 @@ function index()
|
|||
require("luci.i18n").loadc("luci-fw")
|
||||
local i18n = luci.i18n.translate
|
||||
|
||||
entry({"admin", "network", "portfw"}, cbi("luci_fw/portfw"), i18n("fw_portfw", "Portweiterleitung"), 70).i18n = "luci-fw"
|
||||
entry({"admin", "network", "routing"}, cbi("luci_fw/routing"), i18n("fw_routing", "Routing"), 73).i18n = "luci-fw"
|
||||
entry({"admin", "network", "firewall"}, cbi("luci_fw/firewall"), i18n("fw_fw", "Firewall"), 76).i18n = "luci-fw"
|
||||
if registered("admin") then
|
||||
entry({"admin", "network", "portfw"}, cbi("luci_fw/portfw"), i18n("fw_portfw", "Portweiterleitung"), 70).i18n = "luci-fw"
|
||||
entry({"admin", "network", "routing"}, cbi("luci_fw/routing"), i18n("fw_routing", "Routing"), 73).i18n = "luci-fw"
|
||||
entry({"admin", "network", "firewall"}, cbi("luci_fw/firewall"), i18n("fw_fw", "Firewall"), 76).i18n = "luci-fw"
|
||||
end
|
||||
|
||||
if registered("mini") then
|
||||
entry({"mini", "network", "portfw"}, cbi("luci_fw/miniportfw"), i18n("fw_portfw", "Portweiterleitung"), 70).i18n = "luci-fw"
|
||||
end
|
||||
end
|
|
@ -27,9 +27,9 @@ fw_portfw1 = [[Portweiterleitungen ermöglichen es interne
|
|||
Netzwerkdienste von einem anderen externen Netzwerk aus erreichbar zu machen.]]
|
||||
lucifw_portfw_iface_desc = "Externe Schnittstelle"
|
||||
lucifw_portfw_dport = "Externer Port"
|
||||
lucifw_portfw_dport_desc = "Port[:Endport]"
|
||||
lucifw_portfw_dport_desc = "Einzelner Port oder Erster Port-Letzter Port"
|
||||
lucifw_portfw_to = "Interne Adresse"
|
||||
lucifw_portfw_to_desc = "IP-Adresse[:Zielport[-Zielendport]]"
|
||||
lucifw_portfw_to_desc = "IP, IP:Port oder IP:Erster Port-Letzter Port"
|
||||
|
||||
fw_routing1 = [[An dieser Stelle wird festlegt, welcher Netzverkehr zwischen einzelnen
|
||||
Schnittstellen erlaubt werden soll. Es werden jeweils nur neue Verbindungen
|
||||
|
|
|
@ -26,9 +26,9 @@ fw_portfw1 = [[Port forwarding allows to provide network services
|
|||
in the internal network to an external network.]]
|
||||
lucifw_portfw_iface_desc = "External interface"
|
||||
lucifw_portfw_dport = "External port"
|
||||
lucifw_portfw_dport_desc = "Port[:last port]"
|
||||
lucifw_portfw_dport_desc = "single port or first port-last port"
|
||||
lucifw_portfw_to = "Internal address"
|
||||
lucifw_portfw_to_desc = "IP-address[:target port[-last port]]"
|
||||
lucifw_portfw_to_desc = "IP, IP:port or IP:first port-last port"
|
||||
|
||||
fw_routing1 = [[Here you can specify which network traffic is allowed to flow between network interfaces.
|
||||
Only new connections will be matched. Packets belonging to already open connections are automatically allowed
|
||||
|
|
37
applications/luci-fw/luasrc/model/cbi/luci_fw/miniportfw.lua
Normal file
37
applications/luci-fw/luasrc/model/cbi/luci_fw/miniportfw.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
--[[
|
||||
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$
|
||||
]]--
|
||||
require("luci.sys")
|
||||
m = Map("luci_fw", translate("fw_portfw"), translate("fw_portfw1"))
|
||||
|
||||
|
||||
s = m:section(TypedSection, "portfw", "")
|
||||
s:depends("iface", "wan")
|
||||
s.defaults.iface = "wan"
|
||||
|
||||
s.template = "cbi/tblsection"
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
|
||||
name = s:option(Value, "_name", translate("name") .. translate("cbi_optional"))
|
||||
|
||||
proto = s:option(ListValue, "proto", translate("protocol"))
|
||||
proto:value("tcp", "TCP")
|
||||
proto:value("udp", "UDP")
|
||||
proto:value("tcpudp", "TCP + UDP")
|
||||
|
||||
dport = s:option(Value, "dport")
|
||||
|
||||
to = s:option(Value, "to")
|
||||
|
||||
return m
|
|
@ -15,6 +15,8 @@ apply_portfw() {
|
|||
[ -n "$ifname" ] || return 0
|
||||
[ -n "$to" ] || return 0
|
||||
|
||||
dport=$(echo $dport | sed -e 's/-/:/')
|
||||
|
||||
ports=$(echo $to | cut -sd: -f2)
|
||||
if [ -n "$ports" ]; then
|
||||
ports="--dport $(echo $ports | sed -e 's/-/:/')"
|
||||
|
|
|
@ -26,7 +26,7 @@ function index()
|
|||
|
||||
entry({"about"}, template("about")).i18n = "admin-core"
|
||||
|
||||
local page = entry({"mini"}, alias("mini", "index"), i18n("mini", "Mini"), 10)
|
||||
local page = entry({"mini"}, alias("mini", "index"), i18n("essentials", "Essentials"), 10)
|
||||
page.i18n = "admin-core"
|
||||
page.sysauth = "root"
|
||||
page.ucidata = true
|
||||
|
|
|
@ -20,5 +20,5 @@ function index()
|
|||
local i18n = luci.i18n.translate
|
||||
|
||||
entry({"mini", "network"}, cbi("mini-network/basic"), i18n("network"))
|
||||
entry({"mini", "network", "dhcp"}, cbi("mini-network/dhcp"), "DHCP")
|
||||
entry({"mini", "network", "dhcp"}, cbi("mini-network/dhcp"), "DHCP", 10)
|
||||
end
|
100
modules/admin-mini/luasrc/controller/mini/uci.lua
Normal file
100
modules/admin-mini/luasrc/controller/mini/uci.lua
Normal file
|
@ -0,0 +1,100 @@
|
|||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
|
||||
|
||||
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$
|
||||
]]--
|
||||
module("luci.controller.mini.uci", package.seeall)
|
||||
|
||||
function index()
|
||||
local i18n = luci.i18n.translate
|
||||
|
||||
entry({"mini", "uci"}, nil, i18n("config"))
|
||||
entry({"mini", "uci", "changes"}, call("action_changes"), i18n("changes"))
|
||||
entry({"mini", "uci", "revert"}, call("action_revert"), i18n("revert"))
|
||||
entry({"mini", "uci", "apply"}, call("action_apply"), i18n("apply"))
|
||||
end
|
||||
|
||||
function convert_changes(changes)
|
||||
local ret = {}
|
||||
for r, tbl in pairs(changes) do
|
||||
for s, os in pairs(tbl) do
|
||||
for o, v in pairs(os) do
|
||||
local val, str
|
||||
if (v == "") then
|
||||
str = "-"
|
||||
val = ""
|
||||
else
|
||||
str = ""
|
||||
val = "="..v
|
||||
end
|
||||
str = r.."."..s
|
||||
if o ~= ".type" then
|
||||
str = str.."."..o
|
||||
end
|
||||
table.insert(ret, str..val)
|
||||
end
|
||||
end
|
||||
end
|
||||
return table.concat(ret, "\n")
|
||||
end
|
||||
|
||||
function action_changes()
|
||||
local changes = convert_changes(luci.model.uci.changes())
|
||||
luci.template.render("mini/uci_changes", {changes=changes})
|
||||
end
|
||||
|
||||
function action_apply()
|
||||
local changes = luci.model.uci.changes()
|
||||
local output = ""
|
||||
|
||||
if changes then
|
||||
local com = {}
|
||||
local run = {}
|
||||
|
||||
-- Collect files to be applied and commit changes
|
||||
for r, tbl in pairs(changes) do
|
||||
if r then
|
||||
luci.model.uci.load(r)
|
||||
luci.model.uci.commit(r)
|
||||
luci.model.uci.unload(r)
|
||||
if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then
|
||||
run[luci.config.uci_oncommit[r]] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Search for post-commit commands
|
||||
for cmd, i in pairs(run) do
|
||||
output = output .. cmd .. ":" .. luci.sys.exec(cmd) .. "\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
luci.template.render("mini/uci_apply", {changes=convert_changes(changes), output=output})
|
||||
end
|
||||
|
||||
|
||||
function action_revert()
|
||||
local changes = luci.model.uci.changes()
|
||||
if changes then
|
||||
local revert = {}
|
||||
|
||||
-- Collect files to be reverted
|
||||
for r, tbl in pairs(changes) do
|
||||
luci.model.uci.load(r)
|
||||
luci.model.uci.revert(r)
|
||||
luci.model.uci.unload(r)
|
||||
end
|
||||
end
|
||||
|
||||
luci.template.render("mini/uci_revert", {changes=convert_changes(changes)})
|
||||
end
|
20
modules/admin-mini/luasrc/view/mini/uci_apply.htm
Normal file
20
modules/admin-mini/luasrc/view/mini/uci_apply.htm
Normal file
|
@ -0,0 +1,20 @@
|
|||
<%#
|
||||
LuCI - Lua Configuration Interface
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
|
||||
|
||||
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$
|
||||
|
||||
-%>
|
||||
<%+header%>
|
||||
<h1><%:config%></h1>
|
||||
<p><%:uci_applied%>:</p>
|
||||
<code><%=(changes or "-")%>
|
||||
<%=output%></code>
|
||||
<%+footer%>
|
26
modules/admin-mini/luasrc/view/mini/uci_changes.htm
Normal file
26
modules/admin-mini/luasrc/view/mini/uci_changes.htm
Normal file
|
@ -0,0 +1,26 @@
|
|||
<%#
|
||||
LuCI - Lua Configuration Interface
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
|
||||
|
||||
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$
|
||||
|
||||
-%>
|
||||
<%+header%>
|
||||
<h1><%:config%></h1>
|
||||
<h2><%:changes%></h2>
|
||||
<code><%=changes%></code>
|
||||
<br /><br />
|
||||
<form class="inline" method="get" action="<%=controller%>/admin/uci/apply">
|
||||
<input type="submit" value="<%:apply%>" />
|
||||
</form>
|
||||
<form class="inline" method="get" action="<%=controller%>/admin/uci/revert">
|
||||
<input type="submit" value="<%:revert%>" />
|
||||
</form>
|
||||
<%+footer%>
|
19
modules/admin-mini/luasrc/view/mini/uci_revert.htm
Normal file
19
modules/admin-mini/luasrc/view/mini/uci_revert.htm
Normal file
|
@ -0,0 +1,19 @@
|
|||
<%#
|
||||
LuCI - Lua Configuration Interface
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
|
||||
|
||||
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$
|
||||
|
||||
-%>
|
||||
<%+header%>
|
||||
<h1><%:config%></h1>
|
||||
<p><%:uci_reverted%>:</p>
|
||||
<code><%=(changes or "-")%></code>
|
||||
<%+footer%>
|
Loading…
Reference in a new issue