applications/luci-fw: Reworked to use the new native UCI-based firewall configuration
[project/luci.git] / applications / luci-fw / luasrc / model / cbi / luci_fw / firewall.lua
index 5ed4559..2919896 100644 (file)
@@ -11,31 +11,23 @@ You may obtain a copy of the License at
 
 $Id$
 ]]--
-m = Map("luci_fw", translate("fw_fw"), translate("fw_fw1"))
+m = Map("firewall", translate("fw_rules"), translate("fw_rules1"))
 
 s = m:section(TypedSection, "rule", "")
 s.addremove = true
 s.anonymous = true
 
-chain = s:option(ListValue, "chain")
-chain:value("forward", "Forward")
-chain:value("input", "Input")
-chain:value("output", "Output")
-chain:value("prerouting", "Prerouting")
-chain:value("postrouting", "Postrouting")
+iface = s:option(ListValue, "src")
+iface:value("")
+iface.rmempty = true
 
-iface = s:option(ListValue, "iface")
-iface.optional = true
-
-oface = s:option(ListValue, "oface")
+oface = s:option(ListValue, "dest")
 oface.optional = true
 
-luci.model.uci.foreach("network", "interface",
+luci.model.uci.foreach("firewall", "zone",
        function (section)
-               if section[".name"] ~= "loopback" then
-                       iface:value(section[".name"])
-                       oface:value(section[".name"])
-               end
+               iface:value(section.name)
+               oface:value(section.name)
        end)
 
 proto = s:option(ListValue, "proto", translate("protocol"))
@@ -43,43 +35,27 @@ proto.optional = true
 proto:value("")
 proto:value("tcp", "TCP")
 proto:value("udp", "UDP")
+proto:value("icmp", "ICMP")
 
-s:option(Value, "source").optional = true
-s:option(Value, "destination").optional = true
-s:option(Value, "mac").optional = true
+s:option(Value, "src_ip").optional = true
+s:option(Value, "dest_ip").optional = true
+s:option(Value, "src_mac").optional = true
 
-sport = s:option(Value, "sport")
+sport = s:option(Value, "src_port")
 sport.optional = true
 sport:depends("proto", "tcp")
 sport:depends("proto", "udp")
 
-dport = s:option(Value, "dport")
+dport = s:option(Value, "dest_port")
 dport.optional = true
 dport:depends("proto", "tcp")
 dport:depends("proto", "udp")
 
-tosrc = s:option(Value, "tosrc")
-tosrc.optional = true
-tosrc:depends("jump", "SNAT")
-
-tosrc = s:option(Value, "todest")
-tosrc.optional = true
-tosrc:depends("jump", "DNAT")
-
-jump = s:option(ListValue, "jump")
+jump = s:option(ListValue, "target")
 jump.rmempty = true
-jump:value("", "")
+jump:value("DROP", translate("fw_drop"))
 jump:value("ACCEPT", translate("fw_accept"))
 jump:value("REJECT", translate("fw_reject"))
-jump:value("DROP", translate("fw_drop"))
-jump:value("LOG", translate("fw_log"))
-jump:value("DNAT", translate("fw_dnat"))
-jump:value("MASQUERADE", translate("fw_masq"))
-jump:value("SNAT", translate("fw_snat"))
-
 
-add = s:option(Value, "command")
-add.size = 50
-add.rmempty = true
 
 return m