mirror of
				https://github.com/uklans/cache-domains
				synced 2025-11-04 02:28:51 +01:00 
			
		
		
		
	Refactor Dnsmasq script to support multiple cache ips
This change is a continuation of #54, it modifies the output of the dnsmasq script to host file format which allows round robin DNS entries. There is a caveat with round robin DNS entries in dnsmasq, they only supports a single address for wildcard domains, for example: *.cdn.blizzard.com. If previously you had the generated .conf files dumped into a directory where dnsmasq automatically loaded on start-up, you will need to create config that loads all the host files, for example: **lancache.conf** ```conf addn-hosts=/etc/dnsmasq/conf.d/blizzard.hosts addn-hosts=/etc/dnsmasq/conf.d/steam.hosts addn-hosts=/etc/dnsmasq/conf.d/uplay.hosts ``` Closes #107.
This commit is contained in:
		
							parent
							
								
									a5eab76953
								
							
						
					
					
						commit
						85f05fcc77
					
				@ -42,7 +42,7 @@ while read -r entry; do
 | 
				
			|||||||
        cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs)
 | 
					        cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs)
 | 
				
			||||||
        while read -r fileid; do
 | 
					        while read -r fileid; do
 | 
				
			||||||
                while read -r filename; do
 | 
					                while read -r filename; do
 | 
				
			||||||
                        destfilename=$(echo $filename | sed -e 's/txt/conf/')
 | 
					                        destfilename=$(echo $filename | sed -e 's/txt/hosts/')
 | 
				
			||||||
                        outputfile=${outputdir}/${destfilename}
 | 
					                        outputfile=${outputdir}/${destfilename}
 | 
				
			||||||
                        touch "$outputfile"
 | 
					                        touch "$outputfile"
 | 
				
			||||||
                        while read -r fileentry; do
 | 
					                        while read -r fileentry; do
 | 
				
			||||||
@ -55,7 +55,7 @@ while read -r entry; do
 | 
				
			|||||||
                                        continue
 | 
					                                        continue
 | 
				
			||||||
                                fi
 | 
					                                fi
 | 
				
			||||||
                                for i in ${cacheip}; do
 | 
					                                for i in ${cacheip}; do
 | 
				
			||||||
                                        echo "address=/${parsed}/${i}" >> "$outputfile"
 | 
					                                        echo "${i} ${parsed}" >> "$outputfile"
 | 
				
			||||||
                                done
 | 
					                                done
 | 
				
			||||||
                        done <<< $(cat ${basedir}/$filename);
 | 
					                        done <<< $(cat ${basedir}/$filename);
 | 
				
			||||||
                done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path)
 | 
					                done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user