Merge pull request #653 from tsl0922/tsl0922-patch-1
[project/luci.git] / applications / luci-app-adblock / luasrc / model / cbi / adblock.lua
1 -- Copyright 2016 Openwrt.org
2 -- Licensed to the public under the Apache License 2.0.
3
4 m = Map("adblock", translate("Adblock"),
5         translate("Configuration of the adblock package to block ad/abuse domains by using DNS."))
6
7 -- General options
8
9 s = m:section(NamedSection, "global", "adblock", translate("Global options"))
10
11 o1 = s:option(Flag, "adb_enabled", translate("Enable adblock"))
12 o1.rmempty = false
13 o1.default = 0
14
15 o2 = s:option(Value, "adb_blacklist", translate("Blacklist file"),
16      translate("File with explicitly blacklisted hosts/domains."))
17 o2.rmempty = false
18 o2.datatype = "file"
19
20 o3 = s:option(Value, "adb_whitelist", translate("Whitelist file"),
21      translate("File with whitelisted hosts/domains that are allowed despite being on a blocklist."))
22 o3.rmempty = false
23 o3.datatype = "file"
24
25 fdns = s:option(Flag, "adb_forcedns", translate("Redirect all DNS queries to the local resolver"),
26         translate("When adblock is active, all DNS queries are redirected to the local resolver " ..
27         "in this server by default. You can disable that to allow queries to external DNS servers."))
28 fdns.rmempty = false
29 fdns.default = fdns.enabled
30
31 -- Blocklist options
32
33 bl = m:section(TypedSection, "source", translate("Blocklist sources"),
34         translate("Available blocklist sources (")
35         .. [[<a href="https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md" target="_blank">]]
36         .. translate("see list details")
37         .. [[</a>]]
38         .. translate("). Note that list URLs and Shallalist category selections are not configurable via Luci."))
39 bl.template = "cbi/tblsection"
40
41 name = bl:option(Flag, "enabled", translate("Enabled"))
42 name.rmempty  = false
43
44 des = bl:option(DummyValue, "adb_srcdesc", translate("Description"))
45 des.rmempty  = false
46
47 -- Additional options
48
49 s2 = m:section(NamedSection, "backup", "service", translate("Backup options"))
50
51 o4 = s2:option(Flag, "enabled", translate("Enable blocklist backup"))
52 o4.rmempty = false
53 o4.default = 0
54
55 o5 = s2:option(Value, "adb_backupdir", translate("Backup directory"))
56 o5.rmempty = false
57 o5.datatype = "directory"
58
59 -- Extra options
60
61 e = m:section(NamedSection, "global", "adblock", translate("Extra options"),
62         translate("Options for further tweaking in case the defaults are not suitable for you."))
63
64 a1 = e:option(Value, "adb_port", translate("Port of the adblock uhttpd instance"))
65 a1.optional = true
66 a1.default = 65535
67 a1.datatype = "port"
68
69 a2 = e:option(Value, "adb_nullipv4", translate("IPv4 blackhole ip address"))
70 a2.optional = true
71 a2.default = "192.0.2.1"
72 a2.datatype = "ip4addr"
73
74 a3 = e:option(Value, "adb_nullipv6", translate("IPv6 blackhole ip address"))
75 a3.optional = true
76 a3.default = "::ffff:c000:0201"
77 a3.datatype = "ip6addr"
78
79 a6 = e:option(Value, "adb_wanif", translate("Name of the logical wan interface"))
80 a6.optional = true
81 a6.default = "wan"
82 a6.datatype = "network"
83
84 a7 = e:option(Value, "adb_lanif", translate("Name of the logical lan interface"))
85 a7.optional = true
86 a7.default = "lan"
87 a7.datatype = "network"
88
89 return m
90