mirror of
				https://github.com/uklans/cache-domains
				synced 2025-11-04 13:28:51 +01:00 
			
		
		
		
	Fix wildcard domains in dnsmasq script
While #140 added support for round-robin DNS the script needs a slight modification to ensure that wildcard domains are still added with the old method due to dnsmasq limitations. This change will include all wildcard domains in the generated `lancache.conf` along with all the `addn-hosts=` entries.
This commit is contained in:
		
							parent
							
								
									354615d13c
								
							
						
					
					
						commit
						6c3b37c38b
					
				@ -44,9 +44,25 @@ while read -r entry; do
 | 
				
			|||||||
        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/hosts/')
 | 
					                        destfilename=$(echo $filename | sed -e 's/txt/hosts/')
 | 
				
			||||||
 | 
					                        lancacheconf=${outputdir}/lancache.conf
 | 
				
			||||||
                        outputfile=${outputdir}/${destfilename}
 | 
					                        outputfile=${outputdir}/${destfilename}
 | 
				
			||||||
                        echo "addn-hosts=/etc/dnsmasq.d/${destfilename}" >> ${outputdir}/lancache.conf
 | 
					                        echo "addn-hosts=/etc/dnsmasq.d/${destfilename}" >> ${lancacheconf}
 | 
				
			||||||
                        touch "$outputfile"
 | 
					                        touch "$outputfile"
 | 
				
			||||||
 | 
					                        # Wildcard entries
 | 
				
			||||||
 | 
					                        while read -r fileentry; do
 | 
				
			||||||
 | 
					                                # Ignore comments
 | 
				
			||||||
 | 
					                                if [[ $fileentry == \#* ]]; then
 | 
				
			||||||
 | 
					                                        continue
 | 
				
			||||||
 | 
					                                fi
 | 
				
			||||||
 | 
					                                wildcard=$(echo $fileentry | grep "*." | sed -e "s/^\*\.//")
 | 
				
			||||||
 | 
					                                if grep -q "$wildcard" "$lancacheconf"; then
 | 
				
			||||||
 | 
					                                        continue
 | 
				
			||||||
 | 
					                                fi
 | 
				
			||||||
 | 
					                                for i in ${cacheip}; do
 | 
				
			||||||
 | 
					                                        echo "address=/${wildcard}/${i}" >> "$lancacheconf"
 | 
				
			||||||
 | 
					                                done
 | 
				
			||||||
 | 
					                        done <<< $(cat ${basedir}/$filename);
 | 
				
			||||||
 | 
					                        # All other entries
 | 
				
			||||||
                        while read -r fileentry; do
 | 
					                        while read -r fileentry; do
 | 
				
			||||||
                                # Ignore comments
 | 
					                                # Ignore comments
 | 
				
			||||||
                                if [[ $fileentry == \#* ]]; then
 | 
					                                if [[ $fileentry == \#* ]]; then
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user