mirror of
				https://github.com/uklans/cache-domains
				synced 2025-11-04 08:28:53 +01:00 
			
		
		
		
	Merge 55da2b5621 into 7fbb21e32c
				
					
				
			This commit is contained in:
		
						commit
						4575900c5b
					
				@ -13,6 +13,11 @@ if [ $out -gt 0 ] ; then
 | 
				
			|||||||
	exit 1
 | 
						exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					forward=false
 | 
				
			||||||
 | 
					if [ ${1} == --forward ]; then
 | 
				
			||||||
 | 
					  forward=true
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cachenamedefault="disabled"
 | 
					cachenamedefault="disabled"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while read line; do
 | 
					while read line; do
 | 
				
			||||||
@ -45,22 +50,47 @@ while read entry; do
 | 
				
			|||||||
			destfilename=$(echo $filename | sed -e 's/txt/conf/')
 | 
								destfilename=$(echo $filename | sed -e 's/txt/conf/')
 | 
				
			||||||
			outputfile=${outputdir}/${destfilename}
 | 
								outputfile=${outputdir}/${destfilename}
 | 
				
			||||||
			touch $outputfile
 | 
								touch $outputfile
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								if $forward; then
 | 
				
			||||||
 | 
									echo 'forward-zone:' > $outputfile
 | 
				
			||||||
 | 
									echo "  name: \"${key}.cache.lancache.net.\"" >> $outputfile
 | 
				
			||||||
 | 
									for i in ${cacheip}; do
 | 
				
			||||||
 | 
										echo "  forward-addr: \"${i}\"" >> $outputfile
 | 
				
			||||||
 | 
									done
 | 
				
			||||||
 | 
									echo "  forward-first: yes" >> $outputfile
 | 
				
			||||||
 | 
									echo "  forward-no-cache: yes" >> $outputfile
 | 
				
			||||||
 | 
								fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			while read fileentry; do
 | 
								while read fileentry; do
 | 
				
			||||||
				# Ignore comments and newlines
 | 
									# Ignore comments and newlines
 | 
				
			||||||
				if [[ $fileentry == \#* ]] || [[ -z $fileentry ]]; then
 | 
									if [[ $fileentry == \#* ]] || [[ -z $fileentry ]]; then
 | 
				
			||||||
					continue
 | 
										continue
 | 
				
			||||||
				fi
 | 
									fi
 | 
				
			||||||
				parsed=$(echo $fileentry | sed -e "s/^\*\.//")
 | 
									parsed=$(echo $fileentry | sed -e "s/^\*\.//")
 | 
				
			||||||
				if grep -qx "  local-zone: \"${parsed}\" redirect" $outputfile; then
 | 
					
 | 
				
			||||||
					continue
 | 
									if $forward; then
 | 
				
			||||||
 | 
										if grep -qx "  name: \"${parsed}\"" $outputfile; then
 | 
				
			||||||
 | 
											continue
 | 
				
			||||||
 | 
										fi
 | 
				
			||||||
 | 
										echo 'forward-zone:' >> $outputfile
 | 
				
			||||||
 | 
										echo "  name: \"${parsed}.\"" >> $outputfile
 | 
				
			||||||
 | 
										for i in ${cacheip}; do
 | 
				
			||||||
 | 
											echo "  forward-addr: \"${i}\"" >> $outputfile
 | 
				
			||||||
 | 
										done
 | 
				
			||||||
 | 
										echo "  forward-first: yes" >> $outputfile
 | 
				
			||||||
 | 
										echo "  forward-no-cache: yes" >> $outputfile
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
										if grep -qx "  local-zone: \"${parsed}\" redirect" $outputfile; then
 | 
				
			||||||
 | 
											continue
 | 
				
			||||||
 | 
										fi
 | 
				
			||||||
 | 
										if [[ $(head -n 1 $outputfile) != "server:" ]]; then
 | 
				
			||||||
 | 
										    echo "server:" >> $outputfile
 | 
				
			||||||
 | 
										fi
 | 
				
			||||||
 | 
										echo "  local-zone: \"${parsed}\" redirect" >> $outputfile
 | 
				
			||||||
 | 
										for i in ${cacheip}; do
 | 
				
			||||||
 | 
											echo "  local-data: \"${parsed} 30 IN A ${i}\"" >> $outputfile
 | 
				
			||||||
 | 
										done
 | 
				
			||||||
				fi
 | 
									fi
 | 
				
			||||||
        if [[ $(head -n 1 $outputfile) != "server:" ]]; then
 | 
					 | 
				
			||||||
            echo "server:" >> $outputfile
 | 
					 | 
				
			||||||
        fi
 | 
					 | 
				
			||||||
				echo "  local-zone: \"${parsed}\" redirect" >> $outputfile
 | 
					 | 
				
			||||||
				for i in ${cacheip}; do
 | 
					 | 
				
			||||||
					echo "  local-data: \"${parsed} 30 IN A ${i}\"" >> $outputfile
 | 
					 | 
				
			||||||
				done
 | 
					 | 
				
			||||||
			done <<< $(cat ${basedir}/$filename | sort);
 | 
								done <<< $(cat ${basedir}/$filename | sort);
 | 
				
			||||||
		done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path)
 | 
							done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path)
 | 
				
			||||||
	done <<< $(jq -r ".cache_domains[$entry].domain_files | to_entries[] | .key" $path)
 | 
						done <<< $(jq -r ".cache_domains[$entry].domain_files | to_entries[] | .key" $path)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user