mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Refine regex filter generation
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
c7afe3e9a4
commit
2809579dd7
1 changed files with 3 additions and 3 deletions
|
@ -19,10 +19,10 @@ convert_wildcard_to_regex() {
|
||||||
local addrlines domains uniquedomains
|
local addrlines domains uniquedomains
|
||||||
# Obtain wildcard domains from old file
|
# Obtain wildcard domains from old file
|
||||||
addrlines="$(grep -oE "/.*/" ${wildcardFile})"
|
addrlines="$(grep -oE "/.*/" ${wildcardFile})"
|
||||||
# Strip "/" from domain names
|
# Strip "/" from domain names and convert "." to regex-compatible "\."
|
||||||
domains="$(sed 's/\///g;' <<< "${addrlines}")"
|
domains="$(sed 's/\///g;s/\./\\./g' <<< "${addrlines}")"
|
||||||
# Remove repeated domains (may have been inserted two times due to A and AAAA blocking)
|
# Remove repeated domains (may have been inserted two times due to A and AAAA blocking)
|
||||||
uniquedomains="$(uniq <<< "${domains}")"
|
uniquedomains="$(uniq <<< "${domains}")"
|
||||||
# Automatically generate regex filters and remove old wildcards file
|
# Automatically generate regex filters and remove old wildcards file
|
||||||
awk '{print "(^)|(\\.)"$0"$"}' <<< "${uniquedomains}" >> "${regexFile:?}" && rm "${wildcardFile}"
|
awk '{print "((^)|(\\.))"$0"$"}' <<< "${uniquedomains}" >> "${regexFile:?}" && rm "${wildcardFile}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue