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