mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 14:20:18 +00:00
Validate host/domain of Local DNS records as well
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
a872fabe7d
commit
596689b4c9
1 changed files with 23 additions and 11 deletions
|
@ -711,12 +711,18 @@ AddCustomDNSAddress() {
|
||||||
host="${args[3]}"
|
host="${args[3]}"
|
||||||
reload="${args[4]}"
|
reload="${args[4]}"
|
||||||
|
|
||||||
|
validHost="$(checkDomain "${host}")"
|
||||||
|
if [[ -n "${validHost}" ]]; then
|
||||||
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
||||||
echo "${ip} ${host}" >> "${dnscustomfile}"
|
echo "${ip} ${validHost}" >> "${dnscustomfile}"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} Invalid IP has been passed"
|
echo -e " ${CROSS} Invalid IP has been passed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo " ${CROSS} Invalid Domain passed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Restart dnsmasq to load new custom DNS entries only if $reload not false
|
# Restart dnsmasq to load new custom DNS entries only if $reload not false
|
||||||
if [[ ! $reload == "false" ]]; then
|
if [[ ! $reload == "false" ]]; then
|
||||||
|
@ -731,12 +737,18 @@ RemoveCustomDNSAddress() {
|
||||||
host="${args[3]}"
|
host="${args[3]}"
|
||||||
reload="${args[4]}"
|
reload="${args[4]}"
|
||||||
|
|
||||||
|
validHost="$(checkDomain "${host}")"
|
||||||
|
if [[ -n "${validHost}" ]]; then
|
||||||
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
||||||
sed -i "/^${ip} ${host}$/d" "${dnscustomfile}"
|
sed -i "/^${ip} ${validHost}$/d" "${dnscustomfile}"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} Invalid IP has been passed"
|
echo -e " ${CROSS} Invalid IP has been passed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo " ${CROSS} Invalid Domain passed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Restart dnsmasq to load new custom DNS entries only if reload is not false
|
# Restart dnsmasq to load new custom DNS entries only if reload is not false
|
||||||
if [[ ! $reload == "false" ]]; then
|
if [[ ! $reload == "false" ]]; then
|
||||||
|
|
Loading…
Reference in a new issue