You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

  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. s = m:section(TypedSection, "bcp38", translate("BCP38 config"))
  18. s.anonymous = true
  19. -- BASIC
  20. e = s:option(Flag, "enabled", translate("Enable"))
  21. e.rmempty = false
  22. a = s:option(Flag, "detect_upstream", translate("Auto-detect upstream IP"),
  23. translate("Attempt to automatically detect if the upstream IP " ..
  24. "will be blocked by the configuration, and add an exception if it will. " ..
  25. "If this does not work correctly, you can add exceptions manually below."))
  26. a.rmempty = false
  27. n = s:option(ListValue, "interface", translate("Interface name"), translate("Interface to apply the blocking to " ..
  28. "(should be the upstream WAN interface)."))
  29. for _, iface in ipairs(ifaces) do
  30. if iface:is_up() then
  31. n:value(iface:name())
  32. end
  33. end
  34. n.rmempty = false
  35. ma = s:option(DynamicList, "match",
  36. translate("Blocked IP ranges"))
  37. ma.datatype = "ip4addr"
  38. nm = s:option(DynamicList, "nomatch",
  39. translate("Allowed IP ranges"), translate("Takes precedence over blocked ranges. "..
  40. "Use to whitelist your upstream network if you're behind a double NAT " ..
  41. "and the auto-detection doesn't work."))
  42. nm.datatype = "ip4addr"
  43. return m