1
0

bcp38-cbi.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --[[
  2. LuCI - Lua Configuration Interface
  3. Copyright 2014 Toke Høiland-Jørgensen <toke@toke.dk>
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. $Id$
  9. ]]--
  10. local wa = require "luci.tools.webadmin"
  11. local net = require "luci.model.network".init()
  12. local ifaces = net:get_interfaces()
  13. m = Map("bcp38", translate("BCP38"),
  14. translate("This function blocks packets with private address destinations " ..
  15. "from going out onto the internet as per " ..
  16. "<a href=\"http://tools.ietf.org/html/bcp38\">BCP 38</a>. " ..
  17. "For IPv6, only source specific default routes are installed, so " ..
  18. "no BCP38 firewall routes are needed."))
  19. s = m:section(TypedSection, "bcp38", translate("BCP38 config"))
  20. s.anonymous = true
  21. -- BASIC
  22. e = s:option(Flag, "enabled", translate("Enable"))
  23. e.rmempty = false
  24. a = s:option(Flag, "detect_upstream", translate("Auto-detect upstream IP"),
  25. translate("Attempt to automatically detect if the upstream IP " ..
  26. "will be blocked by the configuration, and add an exception if it will. " ..
  27. "If this does not work correctly, you can add exceptions manually below."))
  28. a.rmempty = false
  29. n = s:option(ListValue, "interface", translate("Interface name"), translate("Interface to apply the blocking to " ..
  30. "(should be the upstream WAN interface)."))
  31. for _, iface in ipairs(ifaces) do
  32. if iface:is_up() then
  33. n:value(iface:name())
  34. end
  35. end
  36. n.rmempty = false
  37. ma = s:option(DynamicList, "match",
  38. translate("Blocked IP ranges"))
  39. ma.datatype = "ip4addr"
  40. nm = s:option(DynamicList, "nomatch",
  41. translate("Allowed IP ranges"), translate("Takes precedence over blocked ranges. "..
  42. "Use to whitelist your upstream network if you're behind a double NAT " ..
  43. "and the auto-detection doesn't work."))
  44. nm.datatype = "ip4addr"
  45. return m