Patch for unbound to enable domain names starting with 0

Started by DerJens, October 07, 2020, 11:22:17 AM

Previous topic - Next topic
To whom it may concern:

In Services > Unbound DNS > Overrides I tried to create a Host Override Alias for 0.xxx.pool.ntp.org. This is not possible, since "0" will be detected as an empty value an will be replaced by some other value.

I created two modifications to enable such hostnames by adding is_numeric().
See https://www.php.net/manual/en/function.empty.php#103756 for reference.

unbound.inc, line 605 (Creates a valid host_entries.conf)
'host' => !empty($alias['host']) || is_numeric($alias['host']) ? $alias['host'] : $aliases[0]['host'],

services_unbound_overrides.php, line 189 ("Cosmetic" change for browser display)
<td><?= strtolower(!empty($alias['host']) || is_numeric($alias['host']) ? $alias['host'] : $hostent['host']) ?></td>