luci-app-adblock: Add support for optional config values
[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 -- Blocklist options
26
27 bl = m:section(TypedSection, "source", translate("Blocklist sources"),
28         translate("Available blocklist sources (")
29         .. [[<a href="https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md#main-features" target="_blank">]]
30         .. translate("see list details")
31         .. [[</a>]]
32         .. translate("). Note that list URLs and Shallalist category selections are not configurable via Luci."))
33 bl.template = "cbi/tblsection"
34
35 name = bl:option(Flag, "enabled", translate("Enabled"))
36 name.rmempty  = false
37
38 -- Additional options
39
40 s2 = m:section(NamedSection, "backup", "service", translate("Backup options"))
41
42 o4 = s2:option(Flag, "enabled", translate("Enable blocklist backup"))
43 o4.rmempty = false
44 o4.default = 0
45
46 o5 = s2:option(Value, "adb_backupdir", translate("Backup directory"))
47 o5.rmempty = false
48 o5.datatype = "directory"
49
50 s3 = m:section(NamedSection, "debuglog", "service", translate("Debug log options"))
51
52 o6 = s3:option(Flag, "enabled", translate("Enable debug log"))
53 o6.rmempty = false
54 o6.default = 0
55
56 o7 = s3:option(Value, "adb_logfile", translate("Debug log file"))
57 o7.rmempty = false
58 o7.datatype = "string"
59
60 -- Extra options
61
62 e = m:section(NamedSection, "global", "adblock", translate("Extra options"),
63         translate("Options for further tweaking in case the defaults are not suitable for you."))
64
65 a1 = e:option(Value, "adb_port", translate("Port of the adblock uhttpd instance"))
66 a1.optional = true
67 a1.rmempty = true
68 a1.default = 65535
69 a1.datatype = "port"
70
71 a2 = e:option(Value, "adb_nullipv4", translate("IPv4 blackhole ip address"))
72 a2.optional = true
73 a2.rmempty = true
74 a2.default = "192.0.2.1"
75 a2.datatype = "ip4addr"
76
77 a3 = e:option(Value, "adb_nullipv6", translate("IPv6 blackhole ip address"))
78 a3.optional = true
79 a3.rmempty = true
80 a3.default = "::ffff:c000:0201"
81 a3.datatype = "ip6addr"
82
83 a4 = e:option(Value, "adb_maxtime", translate("Download timeout limit in seconds"))
84 a4.optional = true
85 a4.rmempty = true
86 a4.default = 60
87 a4.datatype = "uinteger"
88
89 a5 = e:option(Value, "adb_maxloop", translate("Timeout limit for active wan lookup at startup"))
90 a5.optional = true
91 a5.rmempty = true
92 a5.default = 20
93 a5.datatype = "uinteger"
94
95 a6 = e:option(Value, "adb_wanif", translate("Name of the logical wan interface") )
96 a6.optional = true
97 a6.rmempty = true
98 a6.default = "wan"
99 a6.datatype = "network"
100
101 a7 = e:option(Value, "adb_lanif", translate("Name of the logical lan interface") )
102 a7.optional = true
103 a7.rmempty = true
104 a7.default = "lan"
105 a7.datatype = "network"
106
107 return m
108