Added ability to include multiple IP Addresses for unbound

This commit is contained in:
Garret Picchioni 2019-05-21 22:58:34 -07:00
parent 02b919e1eb
commit 227299f4fe
No known key found for this signature in database
GPG Key ID: AFB3DB1A44B980C2
2 changed files with 21 additions and 3 deletions

View File

@ -57,6 +57,16 @@ The wildcard format shall be defined as per the below
If you are using these files within a squid dst_domain acl you will need to reformat the wildcard entries to be compliant with the squid acl format. The following regex should suffice `s/*\./\./`
### Multiple IP Addresses
unbound supports assigning multiple IP addresses to a record (can be used if using multiple caches). Example config formatting:
```json
"ips": {
"steam": [ "10.10.3.11", "10.10.3.12", "10.10.3.13" ],
"generic": "10.10.3.16"
},
```
## Updates
Please fork this repository and submit pull requests if you have any extra hostnames or services to add. We want this list to be definitive and collaborative!

View File

@ -15,8 +15,13 @@ fi
cachenamedefault="disabled"
while read line; do
ip=$(jq -r ".ips[\"${line}\"]" config.json)
while read line; do
linecount=$(jq -r ".ips[\"${line}\"]" config.json |wc -l)
if [[ $linecount -eq 1 ]]; then
ip=$(jq -r ".ips[\"${line}\"]" config.json)
else
ip=$(jq -r ".ips[\"${line}\"][]" config.json |tr '\n' ' ')
fi
declare "cacheip$line"="$ip"
done <<< $(jq -r '.ips | to_entries[] | .key' config.json)
@ -56,7 +61,10 @@ while read entry; do
continue
fi
echo " local-zone: \"${parsed}\" redirect" >> $outputfile
echo " local-data: \"${parsed} 30 IN A ${cacheip}\"" >> $outputfile
cacheiplist=($cacheip)
for i in "${cacheiplist[@]}"; do
echo " local-data: \"${parsed} 30 IN A ${i}\"" >> $outputfile
done
done <<< $(cat ${basedir}/$filename);
done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path)
done <<< $(jq -r ".cache_domains[$entry].domain_files | to_entries[] | .key" $path)