mirror of
https://github.com/pi-hole/pi-hole
synced 2025-07-18 04:58:20 +00:00
Add 'edit' option to custom DNS and CNAME
Signed-off-by: Martin Butt <git@martinbutt.com>
This commit is contained in:
parent
fed58f03bf
commit
4968e0d57a
@ -692,6 +692,33 @@ AddCustomDNSAddress() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditCustomDNSAddress() {
|
||||||
|
echo -e " ${TICK} Editing custom DNS entry..."
|
||||||
|
|
||||||
|
ip="${args[2]}"
|
||||||
|
host="${args[3]}"
|
||||||
|
reload="${args[4]}"
|
||||||
|
|
||||||
|
validHost="$(checkDomain "${host}")"
|
||||||
|
if [[ -n "${validHost}" ]]; then
|
||||||
|
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
||||||
|
sed -i "/\s\+${validHost}$/Id" "${dnscustomfile}"
|
||||||
|
echo "${ip} ${validHost}" >> "${dnscustomfile}"
|
||||||
|
else
|
||||||
|
echo -e " ${CROSS} Invalid IP has been passed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " ${CROSS} Invalid Domain passed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restart dnsmasq to load new custom DNS entries only if reload is not false
|
||||||
|
if [[ ! $reload == "false" ]]; then
|
||||||
|
RestartDNS
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
RemoveCustomDNSAddress() {
|
RemoveCustomDNSAddress() {
|
||||||
echo -e " ${TICK} Removing custom DNS entry..."
|
echo -e " ${TICK} Removing custom DNS entry..."
|
||||||
|
|
||||||
@ -744,6 +771,34 @@ AddCustomCNAMERecord() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditCustomCNAMERecord() {
|
||||||
|
echo -e " ${TICK} Editing custom CNAME record..."
|
||||||
|
|
||||||
|
domain="${args[2]}"
|
||||||
|
target="${args[3]}"
|
||||||
|
reload="${args[4]}"
|
||||||
|
|
||||||
|
validDomain="$(checkDomain "${domain}")"
|
||||||
|
if [[ -n "${validDomain}" ]]; then
|
||||||
|
validTarget="$(checkDomain "${target}")"
|
||||||
|
if [[ -n "${validTarget}" ]]; then
|
||||||
|
sed -i "/cname=${validDomain},/Id" "${dnscustomcnamefile}"
|
||||||
|
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 update removed custom CNAME records only if $reload not false
|
||||||
|
if [[ ! $reload == "false" ]]; then
|
||||||
|
RestartDNS
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
RemoveCustomCNAMERecord() {
|
RemoveCustomCNAMERecord() {
|
||||||
echo -e " ${TICK} Removing custom CNAME record..."
|
echo -e " ${TICK} Removing custom CNAME record..."
|
||||||
|
|
||||||
@ -817,8 +872,10 @@ main() {
|
|||||||
"clearaudit" ) clearAudit;;
|
"clearaudit" ) clearAudit;;
|
||||||
"-l" | "privacylevel" ) SetPrivacyLevel;;
|
"-l" | "privacylevel" ) SetPrivacyLevel;;
|
||||||
"addcustomdns" ) AddCustomDNSAddress;;
|
"addcustomdns" ) AddCustomDNSAddress;;
|
||||||
|
"editcustomdns" ) EditCustomDNSAddress;;
|
||||||
"removecustomdns" ) RemoveCustomDNSAddress;;
|
"removecustomdns" ) RemoveCustomDNSAddress;;
|
||||||
"addcustomcname" ) AddCustomCNAMERecord;;
|
"addcustomcname" ) AddCustomCNAMERecord;;
|
||||||
|
"editcustomcname" ) EditCustomCNAMERecord;;
|
||||||
"removecustomcname" ) RemoveCustomCNAMERecord;;
|
"removecustomcname" ) RemoveCustomCNAMERecord;;
|
||||||
"ratelimit" ) SetRateLimit;;
|
"ratelimit" ) SetRateLimit;;
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
|
Loading…
Reference in New Issue
Block a user