uklans/cache-domains

Generation of unbound rules creates invalid entries due to multiple empty lines in steam.txt, xboxlive.txt and twitch.txt

Closed this issue · 3 comments

Describe the issue you are having

Generation of unbound rules creates invalid entries due to multiple empty lines in steam.txt, xboxlive.txt and twitch.txt

Describe your setup?

Not of importance here

Are you running sniproxy

Not of importance here

DNS Configuration

Not of importance here

Sniproxy output

Not of importance here

Way to reproduce:
Checkout 019ec04 and add a scripts/config.json with the following content to the repo

{
	"ips": {
		"default":		["1.2.3.4"]
	},
	"cache_domains": {
		"steam": 		"default",
		"twitch": 		"default",
		"xboxlive": 	"default"
	}
}

Now run scripts/create.unbound.sh

The content of the generated files now have an invalid entry at the beginning which will prevent unbound from starting

server:
  local-zone: "" redirect
  local-data: " 30 IN A 1.2.3.4"
  local-zone: "lancache.steamcontent.com" redirect
  local-data: "lancache.steamcontent.com 30 IN A 1.2.3.4"
server:
  local-zone: "" redirect
  local-data: " 30 IN A 1.2.3.4"
server:
  local-zone: "" redirect
  local-data: " 30 IN A 1.2.3.4"
  local-zone: "assets1.xboxlive.com" redirect
  local-data: "assets1.xboxlive.com 30 IN A 1.2.3.4"
  local-zone: "assets1.xboxlive.com.nsatc.net" redirect
  local-data: "assets1.xboxlive.com.nsatc.net 30 IN A 1.2.3.4"
  local-zone: "assets2.xboxlive.com" redirect
  local-data: "assets2.xboxlive.com 30 IN A 1.2.3.4"
  local-zone: "d1.xboxlive.com" redirect
  local-data: "d1.xboxlive.com 30 IN A 1.2.3.4"
  local-zone: "dlassets.xboxlive.com" redirect
  local-data: "dlassets.xboxlive.com 30 IN A 1.2.3.4"
  local-zone: "xbox-mbr.xboxlive.com" redirect
  local-data: "xbox-mbr.xboxlive.com 30 IN A 1.2.3.4"
  local-zone: "xboxone.loris.llnwd.net" redirect
  local-data: "xboxone.loris.llnwd.net 30 IN A 1.2.3.4"
  local-zone: "xboxone.loris.llnwd.net" redirect
  local-data: "xboxone.loris.llnwd.net 30 IN A 1.2.3.4"
  local-zone: "xboxone.vo.llnwd.net" redirect
  local-data: "xboxone.vo.llnwd.net 30 IN A 1.2.3.4"
  local-zone: "xvcf1.xboxlive.com" redirect
  local-data: "xvcf1.xboxlive.com 30 IN A 1.2.3.4"

This behaviour can be mitigated by removing the (multiple) empty lines in steam.txt, twitch.txt and xboxlive.txt. While having one empty line at the end of steam.txt and xboxlive.txt seems to be ok, having two will make the script fail.

A totally empty file (twitch.txt for example) will nontheless create these invalid entries.

The fix would be to check for empty lines in scripts/create-unbound.sh and ignoring them.

Edit
Added a PR to address this issue: #158

This affects dnsmasq generated files too but I'm not sure if it actually causes an issue in dnsmasq itself. Obviously a workaround is to remove empty lines from the *.txt files locally before running the scripts but your fix is a great idea.

Yes, the autogenerated files for dnsmasq are affected too. My PR #158 fixes both scripts. It will not generate invalid or empty entries and for unbound, it will also delete files with empty rules. For dnsmasq, I did not add anything for deleting empty files, since they might not hurt.

I suggest to use this patch #158 (review) rather my PR.