Merge pull request #92 from carroarmato0/master

Support passing multiple IP addresses
This commit is contained in:
James Kinsman 2019-06-23 13:46:56 +01:00 committed by GitHub
commit 37eb135d4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View file

@ -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",

View file

@ -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)

View file

@ -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)