1 -- Copyright 2008 Freifunk Leipzig / Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
4 require("luci.sys.iptparser")
6 ip = luci.sys.iptparser.IptParser()
10 for i, rule in ipairs( ip:find() ) do
11 if rule.chain and rule.target then
12 chains[rule.chain] = true
13 targets[rule.target] = true
18 m = Map("luci_statistics",
19 translate("Iptables Plugin Configuration"),
21 "The iptables plugin will monitor selected firewall rules and " ..
22 "collect informations about processed bytes and packets per rule."
25 -- collectd_iptables config section
26 s = m:section( NamedSection, "collectd_iptables", "luci_statistics" )
28 -- collectd_iptables.enable
29 enable = s:option( Flag, "enable", translate("Enable this plugin") )
33 -- collectd_iptables_match config section (Chain directives)
34 rule = m:section( TypedSection, "collectd_iptables_match",
35 translate("Add matching rule"),
37 "Here you can define various criteria by which the monitored " ..
38 "iptables rules are selected."
44 -- collectd_iptables_match.name
45 rule_table = rule:option( Value, "name",
46 translate("Name of the rule"), translate("max. 16 chars") )
48 -- collectd_iptables_match.table
49 rule_table = rule:option( ListValue, "table", translate("Table") )
50 rule_table.default = "filter"
51 rule_table.rmempty = true
52 rule_table.optional = true
54 rule_table:value("filter")
55 rule_table:value("nat")
56 rule_table:value("mangle")
59 -- collectd_iptables_match.chain
60 rule_chain = rule:option( ListValue, "chain", translate("Chain") )
61 rule_chain.rmempty = true
62 rule_chain.optional = true
65 for chain, void in pairs( chains ) do
66 rule_chain:value( chain )
70 -- collectd_iptables_match.target
71 rule_target = rule:option( ListValue, "target", translate("Action (target)") )
72 rule_target.rmempty = true
73 rule_target.optional = true
76 for target, void in pairs( targets ) do
77 rule_target:value( target )
81 -- collectd_iptables_match.protocol
82 rule_protocol = rule:option( ListValue, "protocol", translate("Network protocol") )
83 rule_protocol.rmempty = true
84 rule_protocol.optional = true
85 rule_protocol:value("")
86 rule_protocol:value("tcp")
87 rule_protocol:value("udp")
88 rule_protocol:value("icmp")
90 -- collectd_iptables_match.source
91 rule_source = rule:option( Value, "source", translate("Source ip range") )
92 rule_source.default = "0.0.0.0/0"
93 rule_source.rmempty = true
94 rule_source.optional = true
96 -- collectd_iptables_match.destination
97 rule_destination = rule:option( Value, "destination", translate("Destination ip range") )
98 rule_destination.default = "0.0.0.0/0"
99 rule_destination.rmempty = true
100 rule_destination.optional = true
102 -- collectd_iptables_match.inputif
103 rule_inputif = rule:option( Value, "inputif",
104 translate("Incoming interface"), translate("e.g. br-lan") )
105 rule_inputif.rmempty = true
106 rule_inputif.optional = true
108 -- collectd_iptables_match.outputif
109 rule_outputif = rule:option( Value, "outputif",
110 translate("Outgoing interface"), translate("e.g. br-ff") )
111 rule_outputif.rmempty = true
112 rule_outputif.optional = true
114 -- collectd_iptables_match.options
115 rule_options = rule:option( Value, "options",
116 translate("Options"), translate("e.g. reject-with tcp-reset") )
117 rule_options.rmempty = true
118 rule_options.optional = true