blob: bb1b28608e8ea445e307527cf363bc3b84040523 (
plain) (
blame)
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
|
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
PF="/etc/pf.droplist"
DROPV6="/usr/local/etc/spamhaus-drop-v6.json"
DROPV6_URL="https://www.spamhaus.org/drop/drop_v6.json"
DROPV4="/usr/local/etc/spamhaus-drop-v4.json"
DROPV4_URL="https://www.spamhaus.org/drop/drop_v4.json"
_fetchfile() {
local path="$1"
local url="$2"
local temp="${path}.tmp"
local fetchflags=""
if [ -f "$path" ]; then
fetchflags="$fetchflags -i $path"
fi
if ! fetch $fetchflags -q -o "$temp" "$url"; then
rm -f "$temp"
return 1
fi
if [ -s "$temp" ]; then
mv "$temp" "$path"
fi
}
if ! _fetchfile "$DROPV6" "$DROPV6_URL"; then
printf >&2 '%s: failed to fetch IPv6 drop list\n' "$0"
exit 1
fi
if ! _fetchfile "$DROPV4" "$DROPV4_URL"; then
printf >&2 '%s: failed to fetch IPv6 drop list\n' "$0"
exit 1
fi
rm -f "${PF}.tmp"
cat "$DROPV6" "$DROPV4" | jq -r 'select(has("cidr")) | .cidr' > "${PF}.tmp"
mv "${PF}.tmp" "${PF}"
pfctl -q -Treplace -tdroplist -f /etc/pf.droplist
|