mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-26 01:00:33 +00:00
Add automated wildcard list -> regex filter conversion
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
d254d6075a
commit
bc705aac03
2 changed files with 26 additions and 9 deletions
18
advanced/Scripts/wildcard_regex_converter.sh
Normal file
18
advanced/Scripts/wildcard_regex_converter.sh
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
wildcardFile="/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||
|
||||
convert_wildcard_to_regex() {
|
||||
if [ ! -f "${wildcardFile}" ]; then
|
||||
return
|
||||
fi
|
||||
local addrlines domains uniquedomains
|
||||
# Obtain wildcard domains from old file
|
||||
addrlines="$(grep -oE "/.*/" ${wildcardFile})"
|
||||
# Strip "/" from domain names
|
||||
domains="$(sed 's/\///g;' <<< "${addrlines}")"
|
||||
# Remove repeated domains (may have been inserted two times due to A and AAAA blocking)
|
||||
uniquedomains="$(uniq <<< "${domains}")"
|
||||
# Automatically generate regex filters and remove old wildcards file
|
||||
awk '{print "(^)|(\\.)"$0"$"}' <<< "${uniquedomains}" >> "${regexFile}" && rm "${wildcardFile}"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue