Fix generation scripts

This change leverages #130 and also applies this to the dnsmasq script.

As it currently stands both generation scripts (unbound and dnsmasq) have a condition where a domain will be skipped if it fuzzy matches a domain already parsed that is higher in the CDN domain list.

For example the latter of the below two samples would never be added.
8793ce1531/steam.txt (L20) 8793ce1531/steam.txt (L29)

I've also taken the liberty to sort the output of said scripts for readability and troubleshooting purposes.

Closes #130.
This commit is contained in:
Amir Zarrinkafsh 2020-10-29 23:05:45 +11:00
parent 8793ce1531
commit 74cab757af
No known key found for this signature in database
GPG key ID: ECDB8EF9E77E4EBF
2 changed files with 12 additions and 12 deletions

View file

@ -50,32 +50,32 @@ while read -r entry; do
touch "$outputfile"
# Wildcard entries
while read -r fileentry; do
# Ignore comments
if [[ $fileentry == \#* ]]; then
# Ignore comments and non-wildcards
if [[ $fileentry == \#* ]] || [[ ! $fileentry =~ ^\*\. ]]; then
continue
fi
wildcard=$(echo $fileentry | grep "*." | sed -e "s/^\*\.//")
if grep -q "$wildcard" "$lancacheconf"; then
wildcard=$(echo $fileentry | sed -e "s/^\*\.//")
if grep -qx "$wildcard" "$lancacheconf"; then
continue
fi
for i in ${cacheip}; do
echo "address=/${wildcard}/${i}" >> "$lancacheconf"
done
done <<< $(cat ${basedir}/$filename);
done <<< $(cat ${basedir}/$filename | sort);
# All other entries
while read -r fileentry; do
# Ignore comments
if [[ $fileentry == \#* ]]; then
# Ignore comments and wildcards
if [[ $fileentry =~ ^(\#|\*\.) ]]; then
continue
fi
parsed=$(echo $fileentry | sed -e "s/^\*\.//")
if grep -q "$parsed" "$outputfile"; then
parsed=$(echo $fileentry)
if grep -qx "$parsed" "$outputfile"; then
continue
fi
for i in ${cacheip}; do
echo "${i} ${parsed}" >> "$outputfile"
done
done <<< $(cat ${basedir}/$filename);
done <<< $(cat ${basedir}/$filename | sort);
done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path)
done <<< $(jq -r ".cache_domains[$entry].domain_files | to_entries[] | .key" $path)
done <<< $(jq -r '.cache_domains | to_entries[] | .key' $path)

View file

@ -52,14 +52,14 @@ while read entry; do
continue
fi
parsed=$(echo $fileentry | sed -e "s/^\*\.//")
if grep -q "$parsed" $outputfile; then
if grep -qx "$parsed" $outputfile; then
continue
fi
echo " local-zone: \"${parsed}\" redirect" >> $outputfile
for i in ${cacheip}; do
echo " local-data: \"${parsed} 30 IN A ${i}\"" >> $outputfile
done
done <<< $(cat ${basedir}/$filename);
done <<< $(cat ${basedir}/$filename | sort);
done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path)
done <<< $(jq -r ".cache_domains[$entry].domain_files | to_entries[] | .key" $path)
done <<< $(jq -r '.cache_domains | to_entries[] | .key' $path)