From 47d87915503b996c6b020aa325e8e7dd54920b0c Mon Sep 17 00:00:00 2001 From: "skribbles32@gmail.com" Date: Sun, 16 Mar 2025 11:44:08 -0700 Subject: [PATCH 01/27] Added hosts support, as well as support for plain domains. --- update_blocklist.nix | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index f248295..5ba9116 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -10,7 +10,7 @@ let in '' # Clear ipset from previous address. - # Ignore if it fails, because we don't care + # Ignore if it fails, because we don't care set -e urls=( @@ -40,16 +40,44 @@ in # Create an ip set and add each ip to it one by one # IPv4 and IPv6 regex patterns with CIDR notation support - WARNING: might not be correct for all IPs (e.g. ignore valid ones or accept wrong ones), but seems to work fine + # Also supports hosts files, as well as plain lists of domains. ipv4_regex="^([0-9]{1,3}\.){3}[0-9]{1,3}(\/[0-9]{1,2})?$" ipv6_regex="^([0-9a-fA-F:]+::?[0-9a-fA-F]*)+(\/[0-9]{1,3})?$" + domain_regex"^([A-Za-z0-9-]+(? $IP" >&2 fi From c2b031be9d0f8947878dbcb89462a30f8993d5a1 Mon Sep 17 00:00:00 2001 From: athyfr Date: Sun, 16 Mar 2025 19:17:42 +0000 Subject: [PATCH 02/27] ipset should `add` the ip if not already added Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 5ba9116..570a3b9 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -48,7 +48,7 @@ in # Define the functions to be used. blockIPv4 () { - echo "${ipSetName}" "$1" + echo -exist add "${ipSetName}" "$1" } blockIPv6 () { From a64cb6934a7584b787473a3e1451275abe2d934e Mon Sep 17 00:00:00 2001 From: athyfr Date: Sun, 16 Mar 2025 19:18:03 +0000 Subject: [PATCH 03/27] ipset should `add` the ip if not already added Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 570a3b9..dd0f2f2 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -52,7 +52,7 @@ in } blockIPv6 () { - echo "${ipV6SetName}" "$1" + echo -exist add "${ipV6SetName}" "$1" } blockDomain () { From d804f9606b2fb442009e117d1e86c745f1f5bd4b Mon Sep 17 00:00:00 2001 From: athyfr Date: Sun, 16 Mar 2025 19:26:07 +0000 Subject: [PATCH 04/27] Fix escape syntax Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index dd0f2f2..afac56c 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -75,7 +75,7 @@ in if [[ $IP =~ $ipv6_regex ]]; then blockIPv6 $IP elif [[ $IP =~ $host_regex ]]; then - blockDomain $\{IP:8\} + blockDomain \${IP:8} elif [[ $IP =~ $domain_regex ]]; then blockDomain $IP else From 3ff1dc02bb8334f326e7f5bb3bf52d228c1ccaf9 Mon Sep 17 00:00:00 2001 From: "skribbles32@gmail.com" Date: Sun, 16 Mar 2025 12:47:26 -0700 Subject: [PATCH 05/27] Fixed escape syntax. --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index afac56c..f9470de 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -75,7 +75,7 @@ in if [[ $IP =~ $ipv6_regex ]]; then blockIPv6 $IP elif [[ $IP =~ $host_regex ]]; then - blockDomain \${IP:8} + blockDomain ''${IP:8} elif [[ $IP =~ $domain_regex ]]; then blockDomain $IP else From dc314b03cc619d4d8b426e377afc5ae486554bc7 Mon Sep 17 00:00:00 2001 From: athyfr Date: Sun, 16 Mar 2025 20:00:58 +0000 Subject: [PATCH 06/27] Fix escape syntax Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index f9470de..25c7e29 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -44,7 +44,7 @@ in ipv4_regex="^([0-9]{1,3}\.){3}[0-9]{1,3}(\/[0-9]{1,2})?$" ipv6_regex="^([0-9a-fA-F:]+::?[0-9a-fA-F]*)+(\/[0-9]{1,3})?$" domain_regex"^([A-Za-z0-9-]+(? Date: Sun, 16 Mar 2025 20:01:15 +0000 Subject: [PATCH 07/27] Remove redundant comment Co-authored-by: Michael Lohmann --- update_blocklist.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 25c7e29..224e373 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -46,7 +46,6 @@ in domain_regex"^([A-Za-z0-9-]+(? Date: Sun, 16 Mar 2025 20:01:39 +0000 Subject: [PATCH 08/27] Add comments around variable call Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 224e373..8644926 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -55,7 +55,7 @@ in } blockDomain () { - hostIPv4=$(dig $1 A +short) + hostIPv4=$(dig "$1" A +short) while IFS= read -r IP; do echo $(blockIPv4 $1) done < $hostIPv4s From e3bd343ee5a1dc7f3c8b93571a874938aa2aea82 Mon Sep 17 00:00:00 2001 From: athyfr Date: Sun, 16 Mar 2025 20:01:57 +0000 Subject: [PATCH 09/27] Remove redundant echo Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 8644926..415975b 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -57,7 +57,7 @@ in blockDomain () { hostIPv4=$(dig "$1" A +short) while IFS= read -r IP; do - echo $(blockIPv4 $1) + blockIPv4 "$1" done < $hostIPv4s hostIPv6=$(dig $1 AAAA +short) From 0975a267b5abf29f6d05ef887c6e2302942a2245 Mon Sep 17 00:00:00 2001 From: athyfr Date: Sun, 16 Mar 2025 20:02:09 +0000 Subject: [PATCH 10/27] Remove redundant echo Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 415975b..c00c448 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -62,7 +62,7 @@ in hostIPv6=$(dig $1 AAAA +short) while IFS= read -r IP; do - echo $(blockIPv6 $1) + blockIPv6 "$1" done < $hostIPv6s } From 37c26e145bd81bf94a2ac7a10d1ac3ad513e5464 Mon Sep 17 00:00:00 2001 From: athyfr Date: Sun, 16 Mar 2025 20:02:29 +0000 Subject: [PATCH 11/27] Quote variable references Co-authored-by: Michael Lohmann --- update_blocklist.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index c00c448..aec57aa 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -70,13 +70,13 @@ in { while IFS= read -r IP; do if [[ $IP =~ $ipv4_regex ]]; then - blockIPv4 $IP - if [[ $IP =~ $ipv6_regex ]]; then - blockIPv6 $IP - elif [[ $IP =~ $host_regex ]]; then + blockIPv4 "$IP" + if [[ "$IP" =~ $ipv6_regex ]]; then + blockIPv6 "$IP" + elif [[ "$IP" =~ $host_regex ]]; then blockDomain ''${IP:8} - elif [[ $IP =~ $domain_regex ]]; then - blockDomain $IP + elif [[ "$IP" =~ $domain_regex ]]; then + blockDomain "$IP" else echo "Warning: Invalid line skipped -> $IP" >&2 fi From cf3de3525a95dbf7003b2049c8c93a994d1e4338 Mon Sep 17 00:00:00 2001 From: athyfr Date: Sun, 16 Mar 2025 20:14:23 +0000 Subject: [PATCH 12/27] Fix issue: `if` to `elif` Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index aec57aa..d87f234 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -71,7 +71,7 @@ in while IFS= read -r IP; do if [[ $IP =~ $ipv4_regex ]]; then blockIPv4 "$IP" - if [[ "$IP" =~ $ipv6_regex ]]; then + elif [[ "$IP" =~ $ipv6_regex ]]; then blockIPv6 "$IP" elif [[ "$IP" =~ $host_regex ]]; then blockDomain ''${IP:8} From f82d675697c5fbff72048e31f9eeb720c37d1e91 Mon Sep 17 00:00:00 2001 From: athyfr Date: Sun, 16 Mar 2025 20:14:40 +0000 Subject: [PATCH 13/27] Fix variable assignment Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index d87f234..fa35468 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -43,7 +43,7 @@ in # Also supports hosts files, as well as plain lists of domains. ipv4_regex="^([0-9]{1,3}\.){3}[0-9]{1,3}(\/[0-9]{1,2})?$" ipv6_regex="^([0-9a-fA-F:]+::?[0-9a-fA-F]*)+(\/[0-9]{1,3})?$" - domain_regex"^([A-Za-z0-9-]+(? Date: Sun, 16 Mar 2025 20:15:04 +0000 Subject: [PATCH 14/27] Fix variable assignment Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index fa35468..aedb2da 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -44,7 +44,7 @@ in ipv4_regex="^([0-9]{1,3}\.){3}[0-9]{1,3}(\/[0-9]{1,2})?$" ipv6_regex="^([0-9a-fA-F:]+::?[0-9a-fA-F]*)+(\/[0-9]{1,3})?$" domain_regex="^([A-Za-z0-9-]+(? Date: Sun, 16 Mar 2025 20:19:11 +0000 Subject: [PATCH 15/27] Remove unnecessary variable assignments Co-authored-by: Michael Lohmann --- update_blocklist.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index aedb2da..e6ee579 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -55,15 +55,15 @@ in } blockDomain () { - hostIPv4=$(dig "$1" A +short) + dig "$1" A +short | while IFS= read -r IP; do blockIPv4 "$1" done < $hostIPv4s - hostIPv6=$(dig $1 AAAA +short) + dig $1 AAAA +short | while IFS= read -r IP; do blockIPv6 "$1" - done < $hostIPv6s + done } # Use a temporary buffer to improve performance From c08a99b26366d68e61a21861bc5ab3f455d33ce0 Mon Sep 17 00:00:00 2001 From: "skribbles32@gmail.com" Date: Sun, 16 Mar 2025 14:05:24 -0700 Subject: [PATCH 16/27] Fixed regex. --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index e6ee579..cf6e640 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -44,7 +44,7 @@ in ipv4_regex="^([0-9]{1,3}\.){3}[0-9]{1,3}(\/[0-9]{1,2})?$" ipv6_regex="^([0-9a-fA-F:]+::?[0-9a-fA-F]*)+(\/[0-9]{1,3})?$" domain_regex="^([A-Za-z0-9-]+(? Date: Mon, 17 Mar 2025 22:45:37 +0000 Subject: [PATCH 17/27] Removed reference to undefined variable Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index cf6e640..0d720d4 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -58,7 +58,7 @@ in dig "$1" A +short | while IFS= read -r IP; do blockIPv4 "$1" - done < $hostIPv4s + done dig $1 AAAA +short | while IFS= read -r IP; do From f0d7bc8694a5599ac573dc802c96d4845616732d Mon Sep 17 00:00:00 2001 From: "skribbles32@gmail.com" Date: Mon, 17 Mar 2025 15:52:42 -0700 Subject: [PATCH 18/27] Simplified domain regex --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 0d720d4..94b880b 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -43,7 +43,7 @@ in # Also supports hosts files, as well as plain lists of domains. ipv4_regex="^([0-9]{1,3}\.){3}[0-9]{1,3}(\/[0-9]{1,2})?$" ipv6_regex="^([0-9a-fA-F:]+::?[0-9a-fA-F]*)+(\/[0-9]{1,3})?$" - domain_regex="^([A-Za-z0-9-]+(? Date: Mon, 17 Mar 2025 17:14:52 -0700 Subject: [PATCH 19/27] Fixed dig call: `dig` -> `${dig}/bin/dig` --- update_blocklist.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 94b880b..3a3c4ad 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -55,12 +55,12 @@ in } blockDomain () { - dig "$1" A +short | + ${dig}/bin/dig "$1" A +short | while IFS= read -r IP; do blockIPv4 "$1" done - dig $1 AAAA +short | + ${dig}/bin/dig $1 AAAA +short | while IFS= read -r IP; do blockIPv6 "$1" done From 75064df1c2e0aa9bf0ed5ec73bd959210b33f9ed Mon Sep 17 00:00:00 2001 From: "skribbles32@gmail.com" Date: Mon, 17 Mar 2025 17:17:32 -0700 Subject: [PATCH 20/27] Added `dig` to inherit statement. --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 3a3c4ad..097bbdb 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -1,6 +1,6 @@ { pkgs, config }: let - inherit (pkgs) ipset wget; + inherit (pkgs) ipset wget dig; inherit (config.services.blocklist-updater) blocklists ipSetName From bac866f7e64f48bdc8e3b56eb148fdf8b6bd4d05 Mon Sep 17 00:00:00 2001 From: "skribbles32@gmail.com" Date: Mon, 17 Mar 2025 17:34:38 -0700 Subject: [PATCH 21/27] Fixed weird IP error: ipset v7.23: Error in line 1: Syntax error: cannot parse 3dns: resolving to IPv4 address failed --- update_blocklist.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 097bbdb..3db39b1 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -57,12 +57,20 @@ in blockDomain () { ${dig}/bin/dig "$1" A +short | while IFS= read -r IP; do - blockIPv4 "$1" + if [[$IP =~ $ipv4_regex]]; then + blockIPv4 "$1" + else + echo "Warning: Invalid ipv4 skipped -> $IP" >&2 + fi done ${dig}/bin/dig $1 AAAA +short | while IFS= read -r IP; do - blockIPv6 "$1" + if [[$IP =~ $ipv6_regex]]; then + blockIPv6 "$1" + else + echo "Warning: Invalid ipv6 skipped -> $IP" >&2 + fi done } From 0a3158f29ab10ff98d54aec0607291598808efe4 Mon Sep 17 00:00:00 2001 From: "skribbles32@gmail.com" Date: Mon, 17 Mar 2025 17:37:51 -0700 Subject: [PATCH 22/27] Fixed if statement spacing --- update_blocklist.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 3db39b1..7be8c04 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -57,7 +57,7 @@ in blockDomain () { ${dig}/bin/dig "$1" A +short | while IFS= read -r IP; do - if [[$IP =~ $ipv4_regex]]; then + if [[ $IP =~ $ipv4_regex ]]; then blockIPv4 "$1" else echo "Warning: Invalid ipv4 skipped -> $IP" >&2 @@ -66,7 +66,7 @@ in ${dig}/bin/dig $1 AAAA +short | while IFS= read -r IP; do - if [[$IP =~ $ipv6_regex]]; then + if [[ $IP =~ $ipv6_regex ]]; then blockIPv6 "$1" else echo "Warning: Invalid ipv6 skipped -> $IP" >&2 From 050d8362ee1f6113d7941a0db0e39308c1b3ed28 Mon Sep 17 00:00:00 2001 From: "skribbles32@gmail.com" Date: Mon, 17 Mar 2025 17:46:21 -0700 Subject: [PATCH 23/27] Remove if statements again, did not fix weird IP error --- update_blocklist.nix | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 7be8c04..097bbdb 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -57,20 +57,12 @@ in blockDomain () { ${dig}/bin/dig "$1" A +short | while IFS= read -r IP; do - if [[ $IP =~ $ipv4_regex ]]; then - blockIPv4 "$1" - else - echo "Warning: Invalid ipv4 skipped -> $IP" >&2 - fi + blockIPv4 "$1" done ${dig}/bin/dig $1 AAAA +short | while IFS= read -r IP; do - if [[ $IP =~ $ipv6_regex ]]; then - blockIPv6 "$1" - else - echo "Warning: Invalid ipv6 skipped -> $IP" >&2 - fi + blockIPv6 "$1" done } From 80acad2d4072f660bdf6a781bd3846ff98631b9b Mon Sep 17 00:00:00 2001 From: athyfr Date: Tue, 18 Mar 2025 09:02:12 -0700 Subject: [PATCH 24/27] Fix regex `.` syntax Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 097bbdb..aff9b36 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -44,7 +44,7 @@ in ipv4_regex="^([0-9]{1,3}\.){3}[0-9]{1,3}(\/[0-9]{1,2})?$" ipv6_regex="^([0-9a-fA-F:]+::?[0-9a-fA-F]*)+(\/[0-9]{1,3})?$" domain_regex="^[a-zA-Z0-9.-]*[a-zA-Z][a-zA-Z0-9.-]*$" - host_regex="^0\.0\.0\.0 ''${domain_regex:1}" + host_regex="^0\\.0\\.0\\.0 ''${domain_regex:1}" blockIPv4 () { echo -exist add "${ipSetName}" "$1" From b83317128a580ad9c53fb748e7717eb5ce5976a7 Mon Sep 17 00:00:00 2001 From: athyfr Date: Tue, 18 Mar 2025 09:05:55 -0700 Subject: [PATCH 25/27] Update domain regex to require at least one literal `.` Co-authored-by: Michael Lohmann --- update_blocklist.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index aff9b36..bdc1ee7 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -43,7 +43,7 @@ in # Also supports hosts files, as well as plain lists of domains. ipv4_regex="^([0-9]{1,3}\.){3}[0-9]{1,3}(\/[0-9]{1,2})?$" ipv6_regex="^([0-9a-fA-F:]+::?[0-9a-fA-F]*)+(\/[0-9]{1,3})?$" - domain_regex="^[a-zA-Z0-9.-]*[a-zA-Z][a-zA-Z0-9.-]*$" + domain_regex='^[a-zA-Z0-9.-]*\.[a-zA-Z][a-zA-Z0-9.-]+$' host_regex="^0\\.0\\.0\\.0 ''${domain_regex:1}" blockIPv4 () { From 5d55941d60e3190efe1e70daae4d7661fdfae105 Mon Sep 17 00:00:00 2001 From: athyfr Date: Tue, 18 Mar 2025 09:14:40 -0700 Subject: [PATCH 26/27] Fix variable calls Co-authored-by: Michael Lohmann --- update_blocklist.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index bdc1ee7..77b4505 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -57,12 +57,12 @@ in blockDomain () { ${dig}/bin/dig "$1" A +short | while IFS= read -r IP; do - blockIPv4 "$1" + blockIPv4 "$IP" done ${dig}/bin/dig $1 AAAA +short | while IFS= read -r IP; do - blockIPv6 "$1" + blockIPv6 "$IP" done } From f8d0d87b5251fafd8ae80ab182f62021bf226f46 Mon Sep 17 00:00:00 2001 From: athyfr Date: Tue, 18 Mar 2025 11:00:53 -0700 Subject: [PATCH 27/27] Filter out non-IP addresses from `dig` Co-authored-by: Michael Lohmann --- update_blocklist.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/update_blocklist.nix b/update_blocklist.nix index 77b4505..bca753a 100755 --- a/update_blocklist.nix +++ b/update_blocklist.nix @@ -57,12 +57,16 @@ in blockDomain () { ${dig}/bin/dig "$1" A +short | while IFS= read -r IP; do - blockIPv4 "$IP" + if [[ $IP =~ $ipv4_regex ]]; then + blockIPv4 "$IP" + fi done ${dig}/bin/dig $1 AAAA +short | while IFS= read -r IP; do - blockIPv6 "$IP" + if [[ "$IP" =~ $ipv6_regex ]]; then + blockIPv6 "$IP" + fi done }