applications/luci-statistics: fix translations of cbi models and controller
[project/luci.git] / applications / luci-statistics / luasrc / model / cbi / luci_statistics / iptables.lua
1 --[[
2
3 Luci configuration model for statistics - collectd iptables plugin configuration
4 (c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13
14 ]]--
15
16 require("luci.sys.iptparser")
17
18 ip = luci.sys.iptparser.IptParser()
19 chains  = { }
20 targets = { }
21
22 for i, rule in ipairs( ip:find() ) do 
23         chains[rule.chain] = true
24         targets[rule.target] = true
25 end
26
27
28 m = Map("luci_statistics",
29         translate("Iptables Plugin Configuration"),
30         translate(
31                 "The iptables plugin will monitor selected firewall rules and " ..
32                 "collect informations about processed bytes and packets per rule."
33         ))
34
35 -- collectd_iptables config section
36 s = m:section( NamedSection, "collectd_iptables", "luci_statistics" )
37
38 -- collectd_iptables.enable
39 enable = s:option( Flag, "enable", translate("Enable this plugin") )
40 enable.default = 0
41
42
43 -- collectd_iptables_match config section (Chain directives)
44 rule = m:section( TypedSection, "collectd_iptables_match",
45         translate("Add matching rule"),
46         translate(
47                 "Here you can define various criteria by which the monitored " ..
48                 "iptables rules are selected."
49         ))
50 rule.addremove = true
51 rule.anonymous = true
52
53
54 -- collectd_iptables_match.name
55 rule_table = rule:option( Value, "name",
56         translate("Name of the rule"), translate("max. 16 chars") )
57
58 -- collectd_iptables_match.table
59 rule_table = rule:option( ListValue, "table", translate("Table") )
60 rule_table.default  = "filter"
61 rule_table.rmempty  = true
62 rule_table.optional = true
63 rule_table:value("")
64 rule_table:value("filter")
65 rule_table:value("nat")
66 rule_table:value("mangle")
67
68
69 -- collectd_iptables_match.chain
70 rule_chain = rule:option( ListValue, "chain", translate("Chain") )
71 rule_chain.rmempty  = true
72 rule_chain.optional = true
73 rule_chain:value("")
74
75 for chain, void in pairs( chains ) do
76         rule_chain:value( chain )
77 end
78
79
80 -- collectd_iptables_match.target
81 rule_target = rule:option( ListValue, "target", translate("Action (target)") )
82 rule_target.rmempty  = true
83 rule_target.optional = true
84 rule_target:value("")
85
86 for target, void in pairs( targets ) do
87         rule_target:value( target )
88 end
89
90
91 -- collectd_iptables_match.protocol
92 rule_protocol = rule:option( ListValue, "protocol", translate("Network protocol") )
93 rule_protocol.rmempty  = true
94 rule_protocol.optional = true
95 rule_protocol:value("")
96 rule_protocol:value("tcp")
97 rule_protocol:value("udp")
98 rule_protocol:value("icmp")
99
100 -- collectd_iptables_match.source
101 rule_source = rule:option( Value, "source", translate("Source ip range") )
102 rule_source.default  = "0.0.0.0/0"
103 rule_source.rmempty  = true
104 rule_source.optional = true
105
106 -- collectd_iptables_match.destination
107 rule_destination = rule:option( Value, "destination", translate("Destination ip range") )
108 rule_destination.default  = "0.0.0.0/0"
109 rule_destination.rmempty  = true
110 rule_destination.optional = true
111
112 -- collectd_iptables_match.inputif
113 rule_inputif = rule:option( Value, "inputif",
114         translate("Incoming interface"), translate("e.g. br-lan") )
115 rule_inputif.rmempty  = true
116 rule_inputif.optional = true
117
118 -- collectd_iptables_match.outputif
119 rule_outputif = rule:option( Value, "outputif",
120         translate("Outgoing interface"), translate("e.g. br-ff") )
121 rule_outputif.rmempty  = true
122 rule_outputif.optional = true
123
124 -- collectd_iptables_match.options
125 rule_options = rule:option( Value, "options",
126         translate("Options"), translate("e.g. reject-with tcp-reset") )
127 rule_options.rmempty  = true
128 rule_options.optional = true
129
130 return m