blob: 67ec6bd5fb2520e1c098d8059a1ae18bda82aaea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=90
STOP=10
USE_PROCD=1
PROG=/usr/sbin/dansguardian
CONFIGFILE="/tmp/dansguardian/dansguardian.conf"
validate_dansguardian_section() {
uci_validate_section dansguardian dansguardian "${1}" \
'config_file:string' \
'accessdeniedaddress:string' \
'bannediplist:string' \
'contentscanexceptions:string' \
'contentscannertimeout:uinteger' \
'createlistcachefiles:string' \
'custombannedflashfile:string' \
'custombannedimagefile:string' \
'deletedownloadedtempfiles:string' \
'downloadmanager:string' \
'exceptioniplist:string' \
'filecachedir:string' \
'filtergroups:uinteger' \
'filtergroupslist:string' \
'filterip:ipaddr' \
'filterports:port:8080' \
'forcequicksearch:string' \
'forwardedfor:string' \
'hexdecodecontent:string' \
'initialtrickledelay:uinteger' \
'ipcfilename:string' \
'ipipcfilename:string' \
'languagedir:string' \
'language:string' \
'logadblocks:string' \
'logchildprocesshandling:string' \
'logclienthostnames:string' \
'logconnectionhandlingerrors:string' \
'logexceptionhits:range(0,2)' \
'logfileformat:range(1,4)' \
'loglevel:range(0,3)' \
'loglocation:string' \
'loguseragent:string' \
'maxagechildren:uinteger' \
'maxchildren:uinteger' \
'maxcontentfilecachescansize:uinteger' \
'maxcontentfiltersize:uinteger' \
'maxcontentramcachescansize:uinteger' \
'maxips:uinteger' \
'maxsparechildren:uinteger' \
'maxuploadsize:integer' \
'minchildren:uinteger' \
'minsparechildren:uinteger' \
'nodaemon:string' \
'nologger:string' \
'nonstandarddelimiter:string' \
'perroomblockingdirectory:string' \
'phrasefiltermode:range(0,3)' \
'prefercachedlists:string' \
'preforkchildren:uinteger' \
'preservecase:range(0,2)' \
'proxyip:ipaddr' \
'proxyport:port:3128' \
'proxytimeout:range(20,30)' \
'recheckreplacedurls:string' \
'reportinglevel:range(-1,3)' \
'reverseaddresslookups:string' \
'reverseclientiplookups:string' \
'scancleancache:string' \
'showweightedfound:string' \
'softrestart:string' \
'trickledelay:uinteger' \
'urlcacheage:uinteger' \
'urlcachenumber:uinteger' \
'urlipcfilename:string' \
'usecustombannedflash:string' \
'usecustombannedimage:string' \
'usexforwardedfor:string' \
'weightedphrasemode:range(0,2)'
}
start_service() {
local config_file accessdeniedaddress bannediplist contentscanexceptions contentscannertimeout \
createlistcachefiles custombannedflashfile custombannedimagefile deletedownloadedtempfiles \
downloadmanager exceptioniplist filecachedir filtergroups filtergroupslist filterip filterports \
forcequicksearch forwardedfor hexdecodecontent initialtrickledelay ipcfilename ipipcfilename \
language languagedir logadblocks logchildprocesshandling logclienthostnames logconnectionhandlingerrors \
logexceptionhits logfileformat loglevel loguseragent maxagechildren maxchildren maxcontentfilecachescansize \
maxcontentfiltersize maxcontentramcachescansize maxips maxsparechildren maxuploadsize minchildren minsparechildren \
nodaemon nologger nonstandarddelimiter perroomblockingdirectory phrasefiltermode prefercachedlists preforkchildren \
preservecase proxyip proxyport proxytimeout recheckreplacedurls reportinglevel reverseaddresslookups \
reverseclientiplookups scancleancache showweightedfound softrestart trickledelay urlcacheage urlcachenumber \
urlipcfilename usecustombannedflash usecustombannedimage usexforwardedfor weightedphrasemode
validate_dansguardian_section dansguardian || {
echo "validation failed"
return 1
}
mkdir -p $(dirname $CONFIGFILE)
ln -sf $config_file $(dirname $CONFIGFILE)
echo "accessdeniedaddress = " $accessdeniedaddress > $CONFIGFILE
echo "bannediplist = " $bannediplist >> $CONFIGFILE
echo "contentscanexceptions = " $contentscanexceptions >> $CONFIGFILE
echo "contentscannertimeout = " $contentscannertimeout >> $CONFIGFILE
echo "createlistcachefiles = " $createlistcachefiles >> $CONFIGFILE
echo "custombannedflashfile = " $custombannedflashfile >> $CONFIGFILE
echo "custombannedimagefile = " $custombannedimagefile >> $CONFIGFILE
echo "deletedownloadedtempfiles = " $deletedownloadedtempfiles >> $CONFIGFILE
echo "downloadmanager = " $downloadmanager >> $CONFIGFILE
echo "exceptioniplist = " $exceptioniplist >> $CONFIGFILE
echo "filecachedir = " $filecachedir >> $CONFIGFILE
echo "filtergroups = " $filtergroups >> $CONFIGFILE
echo "filtergroupslist = " $filtergroupslist >> $CONFIGFILE
echo "filterip = " $filterip >> $CONFIGFILE
echo "filterports = " $filterports >> $CONFIGFILE
echo "forcequicksearch = " $forcequicksearch >> $CONFIGFILE
echo "forwardedfor = " $forwardedfor >> $CONFIGFILE
echo "hexdecodecontent = " $hexdecodecontent >> $CONFIGFILE
echo "initialtrickledelay = " $initialtrickledelay >> $CONFIGFILE
echo "ipcfilename = " $ipcfilename >> $CONFIGFILE
echo "ipipcfilename = " $ipipcfilename >> $CONFIGFILE
echo "language = " $language >> $CONFIGFILE
echo "languagedir = " $languagedir >> $CONFIGFILE
echo "logadblocks = " $logadblocks >> $CONFIGFILE
echo "logchildprocesshandling = " $logchildprocesshandling >> $CONFIGFILE
echo "logclienthostnames = " $logclienthostnames >> $CONFIGFILE
echo "logconnectionhandlingerrors = " $logconnectionhandlingerrors >> $CONFIGFILE
echo "logexceptionhits = " $logexceptionhits >> $CONFIGFILE
echo "logfileformat = " $logfileformat >> $CONFIGFILE
echo "loglevel = " $loglevel >> $CONFIGFILE
echo "loglocation = " $loglocation >> $CONFIGFILE
echo "loguseragent = " $loguseragent >> $CONFIGFILE
echo "maxagechildren = " $maxagechildren >> $CONFIGFILE
echo "maxchildren = " $maxchildren >> $CONFIGFILE
echo "maxcontentfilecachescansize = " $maxcontentfilecachescansize >> $CONFIGFILE
echo "maxcontentfiltersize = " $maxcontentfiltersize >> $CONFIGFILE
echo "maxcontentramcachescansize = " $maxcontentramcachescansize >> $CONFIGFILE
echo "maxips = " $maxips >> $CONFIGFILE
echo "maxsparechildren = " $maxsparechildren >> $CONFIGFILE
echo "maxuploadsize = " $maxuploadsize >> $CONFIGFILE
echo "minchildren = " $minchildren >> $CONFIGFILE
echo "minsparechildren = " $minsparechildren >> $CONFIGFILE
echo "nodaemon = " $nodaemon >> $CONFIGFILE
echo "nologger = " $nologger >> $CONFIGFILE
echo "nonstandarddelimiter = " $nonstandarddelimiter >> $CONFIGFILE
echo "perroomblockingdirectory = " $perroomblockingdirectory >> $CONFIGFILE
echo "phrasefiltermode = " $phrasefiltermode >> $CONFIGFILE
echo "prefercachedlists = " $prefercachedlists >> $CONFIGFILE
echo "preforkchildren = " $preforkchildren >> $CONFIGFILE
echo "preservecase = " $preservecase >> $CONFIGFILE
echo "proxyip = " $proxyip >> $CONFIGFILE
echo "proxyport = " $proxyport >> $CONFIGFILE
echo "proxytimeout = " $proxytimeout >> $CONFIGFILE
echo "recheckreplacedurls = " $recheckreplacedurls >> $CONFIGFILE
echo "reportinglevel = " $reportinglevel >> $CONFIGFILE
echo "reverseaddresslookups = " $reverseaddresslookups >> $CONFIGFILE
echo "reverseclientiplookups = " $reverseclientiplookups >> $CONFIGFILE
echo "scancleancache = " $scancleancache >> $CONFIGFILE
echo "showweightedfound = " $showweightedfound >> $CONFIGFILE
echo "softrestart = " $softrestart >> $CONFIGFILE
echo "trickledelay = " $trickledelay >> $CONFIGFILE
echo "urlcacheage = " $urlcacheage >> $CONFIGFILE
echo "urlcachenumber = " $urlcachenumber >> $CONFIGFILE
echo "urlipcfilename = " $urlipcfilename >> $CONFIGFILE
echo "usecustombannedflash = " $usecustombannedflash >> $CONFIGFILE
echo "usecustombannedimage = " $usecustombannedimage >> $CONFIGFILE
echo "usexforwardedfor = " $usexforwardedfor >> $CONFIGFILE
echo "weightedphrasemode = " $weightedphrasemode >> $CONFIGFILE
procd_open_instance
procd_set_param command $PROG -N -c "$CONFIGFILE"
procd_set_param file $CONFIGFILE
procd_set_param respawn
procd_close_instance
}
stop_service()
{
dansguardian -s | awk -F':' '{ print $2}' | xargs kill -9
}
service_triggers()
{
procd_add_reload_trigger "dansguardian"
procd_add_validation validate_dansguardian_section
}
|