mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Validate when adding not when removing
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
04f9e92bff
commit
b7bba6a689
1 changed files with 22 additions and 22 deletions
|
@ -709,7 +709,13 @@ AddCustomDNSAddress() {
|
||||||
|
|
||||||
ip="${args[2]}"
|
ip="${args[2]}"
|
||||||
host="${args[3]}"
|
host="${args[3]}"
|
||||||
echo "${ip} ${host}" >> "${dnscustomfile}"
|
|
||||||
|
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
||||||
|
echo "${ip} ${host}" >> "${dnscustomfile}"
|
||||||
|
else
|
||||||
|
echo -e " ${CROSS} Invalid IP has been passed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Restart dnsmasq to load new custom DNS entries
|
# Restart dnsmasq to load new custom DNS entries
|
||||||
RestartDNS
|
RestartDNS
|
||||||
|
@ -721,12 +727,7 @@ RemoveCustomDNSAddress() {
|
||||||
ip="${args[2]}"
|
ip="${args[2]}"
|
||||||
host="${args[3]}"
|
host="${args[3]}"
|
||||||
|
|
||||||
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
sed -i "/^${ip} ${host}$/d" "${dnscustomfile}"
|
||||||
sed -i "/^${ip} ${host}$/d" "${dnscustomfile}"
|
|
||||||
else
|
|
||||||
echo -e " ${CROSS} Invalid IP has been passed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restart dnsmasq to update removed custom DNS entries
|
# Restart dnsmasq to update removed custom DNS entries
|
||||||
RestartDNS
|
RestartDNS
|
||||||
|
@ -738,8 +739,19 @@ AddCustomCNAMERecord() {
|
||||||
domain="${args[2]}"
|
domain="${args[2]}"
|
||||||
target="${args[3]}"
|
target="${args[3]}"
|
||||||
|
|
||||||
echo "cname=${domain},${target}" >> "${dnscustomcnamefile}"
|
validDomain="$(checkDomain "${domain}")"
|
||||||
|
if [[ -n "${validDomain}" ]]; then
|
||||||
|
validTarget="$(checkDomain "${target}")"
|
||||||
|
if [[ -n "${validTarget}" ]]; then
|
||||||
|
echo "cname=${validDomain},${validTarget}" >> "${dnscustomcnamefile}"
|
||||||
|
else
|
||||||
|
echo " ${CROSS} Invalid Target Passed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " ${CROSS} Invalid Domain passed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
# Restart dnsmasq to load new custom CNAME records
|
# Restart dnsmasq to load new custom CNAME records
|
||||||
RestartDNS
|
RestartDNS
|
||||||
}
|
}
|
||||||
|
@ -750,19 +762,7 @@ RemoveCustomCNAMERecord() {
|
||||||
domain="${args[2]}"
|
domain="${args[2]}"
|
||||||
target="${args[3]}"
|
target="${args[3]}"
|
||||||
|
|
||||||
validDomain="$(checkDomain "${domain}")"
|
sed -i "/cname=${domain},${target}$/d" "${dnscustomcnamefile}"
|
||||||
if [[ -n "${validDomain}" ]]; then
|
|
||||||
validTarget="$(checkDomain "${target}")"
|
|
||||||
if [[ -n "${validDomain}" ]]; 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
|
# Restart dnsmasq to update removed custom CNAME records
|
||||||
RestartDNS
|
RestartDNS
|
||||||
|
|
Loading…
Reference in a new issue