Skip to content

Commit

Permalink
Faster and persistent whitelist setup
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Oct 22, 2024
1 parent c7a1a47 commit f73bcfc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
22 changes: 6 additions & 16 deletions src/whitelist/refresh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,16 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

bash "$SCRIPT_DIR/resolve.sh"

### Create Ipset
ipset -! create whitelist hash:ip
ipset -! create whitelist-v6 hash:ip family inet6
### Clear Ipset
ipset flush whitelist
ipset flush whitelist-v6

while read p; do
if [[ $p != "" ]];
then
ipset -! add whitelist $p
fi
done <"$SCRIPT_DIR/ipv4_addresses.txt"
ipset flush whitelist
ipset restore -! <"$SCRIPT_DIR/ipv4_addresses.txt"
ipset save whitelist > /etc/ipset

while read p; do
if [[ $p != "" ]];
then
ipset -! add whitelist-v6 $p
fi
done <"$SCRIPT_DIR/ipv6_addresses.txt"
ipset flush whitelist-v6
ipset restore -! <"$SCRIPT_DIR/ipv6_addresses.txt"
ipset save whitelist-v6 > /etc/ipset6

if [ ! -f "$SCRIPT_DIR/hosts.txt" ]; then
cat /etc/hosts > "$SCRIPT_DIR/hosts.txt"
Expand Down
4 changes: 2 additions & 2 deletions src/whitelist/resolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ for RECORD_TYPE in A AAAA; do
if [[ $q != "" ]]; then
HOST_ADDRESSES+="$q $p"$'\n'
if [[ $RECORD_TYPE == "A" ]]; then
IPV4_ADDRESSES+="$q"$'\n'
IPV4_ADDRESSES+="add whitelist $q"$'\n'
else
IPV6_ADDRESSES+="$q"$'\n'
IPV6_ADDRESSES+="add whitelist-v6 $q"$'\n'
fi
fi
done <<< "$FFI"
Expand Down

0 comments on commit f73bcfc

Please sign in to comment.