mydnshost / mydnshost-api

API Backend for mydnshost
Other
2 stars 1 forks source link

Fix SOA record parsing when missing trailing '.'. #129

Closed csmith closed 3 years ago

csmith commented 3 years ago

Cloudflare exports don't have a trailing '.' on the name of the SOA record, e.g.:

domain.tld SOA domain.tld admin.domain.tld 2038080112 7200 3600 86400 3600

This check was added in b257d8014305b9bc4085a7268a46bb20a7367184 to work around that, but it doesn't work with recent exports.

I think cloudflare used to have an $origin directive, but my exports no longer have that. $origin defaults to domain + '.', which means the check ends up evaluating to something like:

if ($name == "domain.tld.") { $name = "domain.tld."; }

... which is obviously a little dumb. There might be a more elegant way of solving this, but adding an extra check with a period appended seems like a definite fix that would still cope with custom $origins and whatnot.

ShaneMcC commented 3 years ago

I don't think this will break things, but if ever there was a class that needed tests in this project... :D

ShaneMcC commented 3 years ago

Turns out this didn't fix the issue - but I've decided that SOA records should always have the current-domain as the name (this is probably right) and removed the if-statement entirely and deployed that change in: https://github.com/mydnshost/mydnshost-api/commit/f0d1fd333fc9227d61ddc4c52fbf9b9703f0f99d