968ac3624f31cc8bfbecda8ba5d6e6eb9dc67246
[project/luci.git] / applications / luci-app-firewall / luasrc / model / cbi / firewall / custom.lua
1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local fs = require "nixio.fs"
5
6 local f = SimpleForm("firewall",
7         translate("Firewall - Custom Rules"),
8         translate("Custom rules allow you to execute arbritary iptables commands \
9                 which are not otherwise covered by the firewall framework. \
10                 The commands are executed after each firewall restart, right after \
11                 the default ruleset has been loaded."))
12
13 local o = f:field(Value, "_custom")
14
15 o.template = "cbi/tvalue"
16 o.rows = 20
17
18 function o.cfgvalue(self, section)
19         return fs.readfile("/etc/firewall.user")
20 end
21
22 function o.write(self, section, value)
23         value = value:gsub("\r\n?", "\n")
24         fs.writefile("/etc/firewall.user", value)
25 end
26
27 return f