mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Validate on removal as well
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
bc21a7155d
commit
a872fabe7d
1 changed files with 19 additions and 2 deletions
|
@ -731,7 +731,12 @@ RemoveCustomDNSAddress() {
|
|||
host="${args[3]}"
|
||||
reload="${args[4]}"
|
||||
|
||||
sed -i "/^${ip} ${host}$/d" "${dnscustomfile}"
|
||||
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
||||
sed -i "/^${ip} ${host}$/d" "${dnscustomfile}"
|
||||
else
|
||||
echo -e " ${CROSS} Invalid IP has been passed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Restart dnsmasq to load new custom DNS entries only if reload is not false
|
||||
if [[ ! $reload == "false" ]]; then
|
||||
|
@ -772,7 +777,19 @@ RemoveCustomCNAMERecord() {
|
|||
target="${args[3]}"
|
||||
reload="${args[4]}"
|
||||
|
||||
sed -i "/cname=${domain},${target}$/d" "${dnscustomcnamefile}"
|
||||
validDomain="$(checkDomain "${domain}")"
|
||||
if [[ -n "${validDomain}" ]]; then
|
||||
validTarget="$(checkDomain "${target}")"
|
||||
if [[ -n "${validTarget}" ]]; then
|
||||
sed -i "/cname=${validDomain},${validTarget}$/d" "${dnscustomcnamefile}"
|
||||
else
|
||||
echo " ${CROSS} Invalid Target Passed!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo " ${CROSS} Invalid Domain passed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Restart dnsmasq to update removed custom CNAME records only if $reload not false
|
||||
if [[ ! $reload == "false" ]]; then
|
||||
|
|
Loading…
Reference in a new issue