Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing multiple IP addresses #92

Merged
merged 1 commit into from
Jun 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 5 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,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 @@ -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)
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