From 66194b3db51c9bd30f64c92e7a89ed956d3f755e Mon Sep 17 00:00:00 2001 From: Christophe Vanlancker Date: Sat, 15 Jun 2019 23:27:16 +0200 Subject: [PATCH] Support passing multiple IP addresses Signed-off-by: Christophe Vanlancker --- scripts/config.example.json | 2 +- scripts/create-dnsmasq.sh | 8 +++++--- scripts/create-unbound.sh | 8 +++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/config.example.json b/scripts/config.example.json index 6d58ee4..18362c4 100644 --- a/scripts/config.example.json +++ b/scripts/config.example.json @@ -1,6 +1,6 @@ { "ips": { - "steam": "10.10.3.11", + "steam": ["10.10.3.10", "10.10.3.11"], "origin": "10.10.3.12", "blizzard": "10.10.3.13", "windows": "10.10.3.14", diff --git a/scripts/create-dnsmasq.sh b/scripts/create-dnsmasq.sh index e0e0d43..c2da94b 100755 --- a/scripts/create-dnsmasq.sh +++ b/scripts/create-dnsmasq.sh @@ -16,7 +16,7 @@ fi cachenamedefault="disabled" while read line; do - ip=$(jq -r ".ips[\"${line}\"]" config.json) + ip=$(jq ".ips[\"${line}\"]" config.json) declare "cacheip$line"="$ip" done <<< $(jq -r '.ips | to_entries[] | .key' config.json) @@ -39,7 +39,7 @@ while read entry; do continue; fi cacheipname="cacheip${!cachename}" - cacheip=${!cacheipname} + cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs) while read fileid; do while read filename; do destfilename=$(echo $filename | sed -e 's/txt/conf/') @@ -54,7 +54,9 @@ while read entry; do if grep -q "$parsed" $outputfile; then continue fi - echo "address=/${parsed}/${cacheip}" >> $outputfile + for i in ${cacheip}; do + echo "address=/${parsed}/${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) diff --git a/scripts/create-unbound.sh b/scripts/create-unbound.sh index c0d4c0e..10ee026 100755 --- a/scripts/create-unbound.sh +++ b/scripts/create-unbound.sh @@ -16,7 +16,7 @@ fi cachenamedefault="disabled" while read line; do - ip=$(jq -r ".ips[\"${line}\"]" config.json) + ip=$(jq ".ips[\"${line}\"]" config.json) declare "cacheip$line"="$ip" done <<< $(jq -r '.ips | to_entries[] | .key' config.json) @@ -39,7 +39,7 @@ while read entry; do continue; fi cacheipname="cacheip${!cachename}" - cacheip=${!cacheipname} + cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs) while read fileid; do while read filename; do destfilename=$(echo $filename | sed -e 's/txt/conf/') @@ -56,7 +56,9 @@ while read entry; do continue fi echo " local-zone: \"${parsed}\" redirect" >> $outputfile - echo " local-data: \"${parsed} 30 IN A ${cacheip}\"" >> $outputfile + for i in ${cacheip}; 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)