migrate blocklist to a txt file

this allows easy copy/pasting of existing deny lists which contain
comments and blank lines
This commit is contained in:
Girish Ramakrishnan
2020-09-14 10:29:48 -07:00
parent 467fa59023
commit 20e206fa43
10 changed files with 78 additions and 29 deletions

View File

@@ -14,10 +14,12 @@ fi
ipset flush cloudron_blocklist
user_firewall_json="/home/yellowtent/boxdata/firewall-config.json"
if blocklist=$(node -e "console.log(JSON.parse(fs.readFileSync('${user_firewall_json}', 'utf8')).blocklist.join(' '))" 2>/dev/null); then
user_firewall_json="/home/yellowtent/boxdata/firewall/blocklist.txt"
for ip in ${blocklist}; do
ipset add cloudron_blocklist "${ip}"
done
if [[ -f "${user_firewall_json}" ]]; then
while read -r line; do
[[ -z "${line}" ]] && continue # ignore empty lines
[[ "$line" =~ ^#.*$ ]] && continue # ignore lines starting with #
ipset add cloudron_blocklist "${line}"
done < "${user_firewall_json}"
fi