Skip to content

Commit

Permalink
Support passing multiple IP addresses
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Vanlancker <carroarmato0@inuits.eu>
  • Loading branch information
carroarmato0 committed Jun 15, 2019
1 parent f6e7004 commit 76d3d27
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion scripts/config.example.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 7 additions & 3 deletions scripts/create-dnsmasq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -39,7 +39,8 @@ while read entry; do
continue;
fi
cacheipname="cacheip${!cachename}"
cacheip=${!cacheipname}
#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/')
Expand All @@ -54,7 +55,10 @@ while read entry; do
if grep -q "$parsed" $outputfile; then
continue
fi
echo "address=/${parsed}/${cacheip}" >> $outputfile
#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)
Expand Down
8 changes: 5 additions & 3 deletions scripts/create-unbound.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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/')
Expand All @@ -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)
Expand Down

0 comments on commit 76d3d27

Please sign in to comment.