mirror of
https://github.com/uklans/cache-domains
synced 2024-11-21 19:03:03 +00:00
Support passing multiple IP addresses
Signed-off-by: Christophe Vanlancker <carroarmato0@inuits.eu>
This commit is contained in:
parent
f6e7004612
commit
66194b3db5
3 changed files with 11 additions and 7 deletions
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue