custom.lua 754 B

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