@@ -19,6 +19,7 @@ NFSET_TEMP="$TMPDIR/nfset_temp.txt"
19
19
NFSET_SAVERAM_MIN_FILESIZE=16384
20
20
NFSET_SAVERAM_CHUNK_SIZE=1000
21
21
22
+ IPSET_HOOK_TEMP=" $TMPDIR /ipset_hook.txt"
22
23
23
24
while [ -n " $1 " ]; do
24
25
[ " $1 " = " no-update" ] && NO_UPDATE=1
@@ -53,10 +54,15 @@ ipset_restore_chunked()
53
54
54
55
55
56
ipset_get_script ()
57
+ {
58
+ # $1 - ipset name
59
+ sed -nEe " s/^.+$/add $1 &/p"
60
+ }
61
+ ipset_get_script_from_file ()
56
62
{
57
63
# $1 - filename
58
64
# $2 - ipset name
59
- zzcat " $1 " | sort -u | sed -nEe " s/^.+$/add $2 &/p "
65
+ zzcat " $1 " | sort -u | ipset_get_script $2
60
66
}
61
67
ipset_restore ()
62
68
{
@@ -75,11 +81,11 @@ ipset_restore()
75
81
echo $T
76
82
77
83
if [ " $svram " = " 1" ]; then
78
- ipset_get_script " $2 " " $1 " > " $IPSET_CMD "
84
+ ipset_get_script_from_file " $2 " " $1 " > " $IPSET_CMD "
79
85
ipset_restore_chunked " $IPSET_CMD " $IPSET_SAVERAM_CHUNK_SIZE
80
86
rm -f " $IPSET_CMD "
81
87
else
82
- ipset_get_script " $2 " " $1 " | ipset -! restore
88
+ ipset_get_script_from_file " $2 " " $1 " | ipset -! restore
83
89
fi
84
90
}
85
91
create_ipset ()
@@ -97,7 +103,7 @@ create_ipset()
97
103
for f in " $5 " " $6 " ; do
98
104
ipset_restore " $2 " " $f "
99
105
done
100
- ipset_post_hook " $2 "
106
+ [ -n " $IPSET_HOOK " ] && $IPSET_HOOK $2 | ipset_get_script $2 | ipset - ! restore
101
107
}
102
108
return 0
103
109
}
@@ -139,7 +145,13 @@ nfset_restore()
139
145
# $2,$3,... - filenames
140
146
141
147
echo " Adding to nfset $1 : $2 $3 $4 $5 "
142
- nfset_get_script_multi " $@ " | nft -f -
148
+ local hookfile
149
+ [ -n " $IPSET_HOOK " ] && {
150
+ $IPSET_HOOK $1 > " $IPSET_HOOK_TEMP "
151
+ [ -s " $IPSET_HOOK_TEMP " ] && hookfile=$IPSET_HOOK_TEMP
152
+ }
153
+ nfset_get_script_multi " $@ " $hookfile | nft -f -
154
+ rm -f " $IPSET_HOOK_TEMP "
143
155
}
144
156
create_nfset ()
145
157
{
@@ -156,7 +168,6 @@ create_nfset()
156
168
}
157
169
[ " $DO_CLEAR " = " 1" ] || {
158
170
nfset_restore $2 $4 $5
159
- ipset_post_hook " $2 "
160
171
}
161
172
return 0
162
173
}
@@ -192,7 +203,7 @@ create_ipfw_table()
192
203
populate_ipfw_table $name " $1 "
193
204
shift
194
205
done
195
- ipset_post_hook $name
206
+ [ -n " $IPSET_HOOK " ] && $IPSET_HOOK $name | add_ipfw_table $name
196
207
}
197
208
return 0
198
209
}
@@ -211,11 +222,6 @@ print_reloading_backend()
211
222
echo $s
212
223
}
213
224
214
- ipset_post_hook ()
215
- {
216
- [ -n " $IPSET_POST_HOOK " ] && $IPSET_POST_HOOK " $1 "
217
- }
218
-
219
225
220
226
oom_adjust_high
221
227
get_fwtype
@@ -227,7 +233,7 @@ if [ -n "$LISTS_RELOAD" ] ; then
227
233
else
228
234
echo executing custom ip list reload command : $LISTS_RELOAD
229
235
$LISTS_RELOAD
230
- ipset_post_hook
236
+ [ -n " $IPSET_HOOK " ] && $IPSET_HOOK
231
237
fi
232
238
else
233
239
case " $FWTYPE " in
0 commit comments