mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-03 12:40:56 +00:00
Convert CONDITIONAL_FORWARDING to REV_SERVER settings. Try to detect intended CIDR range automatically.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
1632632668
commit
90a5a13197
@ -210,8 +210,42 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${CONDITIONAL_FORWARDING}" == true ]]; then
|
if [[ "${CONDITIONAL_FORWARDING}" == true ]]; then
|
||||||
add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_DOMAIN}/${CONDITIONAL_FORWARDING_IP}"
|
# Convert legacy "conditional forwarding" to rev-server configuration
|
||||||
add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_REVERSE}/${CONDITIONAL_FORWARDING_IP}"
|
REV_SERVER=true
|
||||||
|
add_setting "REV_SERVER" "true"
|
||||||
|
|
||||||
|
REV_SERVER_DOMAIN="${CONDITIONAL_FORWARDING_DOMAIN}"
|
||||||
|
add_setting "REV_SERVER_DOMAIN" "${REV_SERVER_DOMAIN}"
|
||||||
|
|
||||||
|
REV_SERVER_TARGET="${CONDITIONAL_FORWARDING_IP}"
|
||||||
|
add_setting "REV_SERVER_TARGET" "${REV_SERVER_TARGET}"
|
||||||
|
|
||||||
|
# Remove obsolete settings from setupVars.conf
|
||||||
|
delete_setting "CONDITIONAL_FORWARDING"
|
||||||
|
delete_setting "CONDITIONAL_FORWARDING_REVERSE"
|
||||||
|
delete_setting "CONDITIONAL_FORWARDING_DOMAIN"
|
||||||
|
delete_setting "CONDITIONAL_FORWARDING_IP"
|
||||||
|
|
||||||
|
# Try to detect intended CIDR by analyzing the target
|
||||||
|
if [[ "${REV_SERVER_TARGET}" =~ 10\..* ]]; then
|
||||||
|
# Private network, Class A (RFC 1597 + RFC 1918)
|
||||||
|
REV_SERVER_CIDR="10.0.0.0/8"
|
||||||
|
elif [[ "${REV_SERVER_TARGET}" =~ 192\.168\..* ]]; then
|
||||||
|
# Private network, Class C (RFC 1597 + RFC 1918)
|
||||||
|
REV_SERVER_CIDR="192.168.0.0/16"
|
||||||
|
else
|
||||||
|
# Something else. The user will have to adapt this
|
||||||
|
# as we cannot know how large their subnet is
|
||||||
|
REV_SERVER_CIDR="${REV_SERVER_TARGET}/32"
|
||||||
|
fi
|
||||||
|
add_setting "REV_SERVER_CIDR" "${REV_SERVER_CIDR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${REV_SERVER}" == true ]]; then
|
||||||
|
add_dnsmasq_setting "rev-server=${REV_SERVER_CIDR},${REV_SERVER_TARGET}"
|
||||||
|
if [ -n "${REV_SERVER_DOMAIN}" ]; then
|
||||||
|
add_dnsmasq_setting "server=/${REV_SERVER_DOMAIN}/${REV_SERVER_TARGET}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prevent Firefox from automatically switching over to DNS-over-HTTPS
|
# Prevent Firefox from automatically switching over to DNS-over-HTTPS
|
||||||
@ -247,16 +281,16 @@ SetDNSServers() {
|
|||||||
change_setting "DNSSEC" "false"
|
change_setting "DNSSEC" "false"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${args[6]}" == "conditional_forwarding" ]]; then
|
if [[ "${args[6]}" == "rev-server" ]]; then
|
||||||
change_setting "CONDITIONAL_FORWARDING" "true"
|
change_setting "REV_SERVER" "true"
|
||||||
change_setting "CONDITIONAL_FORWARDING_IP" "${args[7]}"
|
change_setting "REV_SERVER_CIDR" "${args[7]}"
|
||||||
change_setting "CONDITIONAL_FORWARDING_DOMAIN" "${args[8]}"
|
change_setting "REV_SERVER_TARGET" "${args[8]}"
|
||||||
change_setting "CONDITIONAL_FORWARDING_REVERSE" "${args[9]}"
|
change_setting "REV_SERVER_DOMAIN" "${args[9]}"
|
||||||
else
|
else
|
||||||
change_setting "CONDITIONAL_FORWARDING" "false"
|
change_setting "REV_SERVER" "false"
|
||||||
delete_setting "CONDITIONAL_FORWARDING_IP"
|
delete_setting "REV_SERVER_CIDR"
|
||||||
delete_setting "CONDITIONAL_FORWARDING_DOMAIN"
|
delete_setting "REV_SERVER_TARGET"
|
||||||
delete_setting "CONDITIONAL_FORWARDING_REVERSE"
|
delete_setting "REV_SERVER_DOMAIN"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ProcessDNSSettings
|
ProcessDNSSettings
|
||||||
|
Loading…
Reference in New Issue
Block a user