Merge pull request #22015 from stangri/master-https-dns-proxy
https-dns-proxy: fix dns resolution not working on boot
This commit is contained in:
commit
f25b34fce8
6 changed files with 35 additions and 26 deletions
|
@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=https-dns-proxy
|
PKG_NAME:=https-dns-proxy
|
||||||
PKG_VERSION:=2023-05-25
|
PKG_VERSION:=2023-05-25
|
||||||
PKG_RELEASE:=3
|
PKG_RELEASE:=4
|
||||||
|
|
||||||
PKG_SOURCE_PROTO:=git
|
PKG_SOURCE_PROTO:=git
|
||||||
PKG_SOURCE_URL:=https://github.com/aarond10/https_dns_proxy/
|
PKG_SOURCE_URL:=https://github.com/aarond10/https_dns_proxy/
|
||||||
|
@ -39,15 +39,16 @@ endef
|
||||||
|
|
||||||
define Package/https-dns-proxy/install
|
define Package/https-dns-proxy/install
|
||||||
$(INSTALL_DIR) $(1)/usr/sbin
|
$(INSTALL_DIR) $(1)/usr/sbin
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
|
||||||
$(INSTALL_DIR) $(1)/etc/config
|
|
||||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
|
||||||
$(INSTALL_DIR) $(1)/etc/uci-defaults/
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/https_dns_proxy $(1)/usr/sbin/https-dns-proxy
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/https_dns_proxy $(1)/usr/sbin/https-dns-proxy
|
||||||
$(INSTALL_BIN) ./files/https-dns-proxy.init $(1)/etc/init.d/https-dns-proxy
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) ./files/etc/init.d/https-dns-proxy $(1)/etc/init.d/https-dns-proxy
|
||||||
$(SED) "s|^\(readonly PKG_VERSION\).*|\1='$(PKG_VERSION)-$(PKG_RELEASE)'|" $(1)/etc/init.d/https-dns-proxy
|
$(SED) "s|^\(readonly PKG_VERSION\).*|\1='$(PKG_VERSION)-$(PKG_RELEASE)'|" $(1)/etc/init.d/https-dns-proxy
|
||||||
$(INSTALL_CONF) ./files/https-dns-proxy.config $(1)/etc/config/https-dns-proxy
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
$(INSTALL_BIN) ./files/https-dns-proxy.defaults $(1)/etc/uci-defaults/50-https-dns-proxy-migrate-options.sh
|
$(INSTALL_CONF) ./files/etc/config/https-dns-proxy $(1)/etc/config/https-dns-proxy
|
||||||
|
$(INSTALL_DIR) $(1)/etc/hotplug.d/online
|
||||||
|
$(INSTALL_DATA) ./files/etc/hotplug.d/online/30-https-dns-proxy $(1)/etc/hotplug.d/online/30-https-dns-proxy
|
||||||
|
$(INSTALL_DIR) $(1)/etc/uci-defaults/
|
||||||
|
$(INSTALL_BIN) ./files/etc/uci-defaults/50-https-dns-proxy-migrate-options.sh $(1)/etc/uci-defaults/50-https-dns-proxy-migrate-options.sh
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,https-dns-proxy))
|
$(eval $(call BuildPackage,https-dns-proxy))
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
/etc/init.d/https-dns-proxy start 'on_hotplug'
|
|
@ -1,9 +1,9 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright 2019-2022 Stan Grishin (stangri@melmac.ca)
|
# Copyright 2019-2023 Stan Grishin (stangri@melmac.ca)
|
||||||
# shellcheck disable=SC1091,SC3043,SC3060
|
# shellcheck disable=SC1091,SC3043,SC3060
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
START=95
|
START=90
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ dnsmasq_restart() { [ -x /etc/init.d/dnsmasq ] || return 1; /etc/init.d/dnsmasq
|
||||||
|
|
||||||
version() { echo "$PKG_VERSION"; }
|
version() { echo "$PKG_VERSION"; }
|
||||||
|
|
||||||
xappend() { param="$param $1"; }
|
xappend() { PROG_param="$PROG_param $1"; }
|
||||||
|
|
||||||
append_bool() {
|
append_bool() {
|
||||||
local section="$1"
|
local section="$1"
|
||||||
|
@ -127,13 +127,18 @@ append_bootstrap() {
|
||||||
[ "$ipv6_resolvers_only" -eq 0 ] && xappend '-4'
|
[ "$ipv6_resolvers_only" -eq 0 ] && xappend '-4'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolver_health_check() { resolveip -t 3 one.one.one.one >/dev/null 2>&1; }
|
||||||
|
|
||||||
boot() {
|
boot() {
|
||||||
ubus -t 30 wait_for network.interface 2>/dev/null
|
ubus -t 30 wait_for network.interface 2>/dev/null
|
||||||
rc_procd start_service 'on_boot'
|
rc_procd start_service 'on_boot'
|
||||||
|
resolver_health_check || rc_procd stop_service 'on_boot'
|
||||||
}
|
}
|
||||||
|
|
||||||
start_instance() {
|
start_instance() {
|
||||||
local cfg="$1" param listen_addr listen_port ipv6_resolvers_only p url iface
|
local cfg="$1" param="$2"
|
||||||
|
local PROG_param
|
||||||
|
local listen_addr listen_port ipv6_resolvers_only p url iface
|
||||||
|
|
||||||
config_get url "$cfg" 'resolver_url'
|
config_get url "$cfg" 'resolver_url'
|
||||||
config_get_bool ipv6_resolvers_only "$cfg" 'use_ipv6_resolvers_only' '0'
|
config_get_bool ipv6_resolvers_only "$cfg" 'use_ipv6_resolvers_only' '0'
|
||||||
|
@ -153,7 +158,7 @@ start_instance() {
|
||||||
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
procd_set_param command $PROG $param
|
procd_set_param command $PROG $PROG_param
|
||||||
procd_set_param stderr 1
|
procd_set_param stderr 1
|
||||||
procd_set_param stdout 1
|
procd_set_param stdout 1
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
|
@ -161,7 +166,6 @@ start_instance() {
|
||||||
json_add_object mdns
|
json_add_object mdns
|
||||||
procd_add_mdns_service "$packageName" 'udp' "$port" "DNS over HTTPS proxy"
|
procd_add_mdns_service "$packageName" 'udp' "$port" "DNS over HTTPS proxy"
|
||||||
json_close_object
|
json_close_object
|
||||||
json_add_string url "$url"
|
|
||||||
if [ "$force_dns" -ne 0 ]; then
|
if [ "$force_dns" -ne 0 ]; then
|
||||||
json_add_array firewall
|
json_add_array firewall
|
||||||
for iface in $procd_fw_src_interfaces; do
|
for iface in $procd_fw_src_interfaces; do
|
||||||
|
@ -218,12 +222,13 @@ start_instance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
|
local param="$1"
|
||||||
local canaryDomains canary_domains_icloud canary_domains_mozilla
|
local canaryDomains canary_domains_icloud canary_domains_mozilla
|
||||||
local dnsmasq_config_update force_dns force_dns_port
|
local dnsmasq_config_update force_dns force_dns_port
|
||||||
local procd_fw_src_interfaces
|
local procd_fw_src_interfaces
|
||||||
|
|
||||||
local port=5053
|
local port=5053
|
||||||
output "Starting $serviceName instances "
|
output "Starting $serviceName instances ${param:+$param }"
|
||||||
config_load "$packageName"
|
config_load "$packageName"
|
||||||
config_get_bool canary_domains_icloud 'config' 'canary_domains_icloud' '1'
|
config_get_bool canary_domains_icloud 'config' 'canary_domains_icloud' '1'
|
||||||
config_get_bool canary_domains_mozilla 'config' 'canary_domains_mozilla' '1'
|
config_get_bool canary_domains_mozilla 'config' 'canary_domains_mozilla' '1'
|
||||||
|
@ -239,7 +244,7 @@ start_service() {
|
||||||
fi
|
fi
|
||||||
dhcp_backup 'create'
|
dhcp_backup 'create'
|
||||||
config_load "$packageName"
|
config_load "$packageName"
|
||||||
config_foreach start_instance "$packageName"
|
config_foreach start_instance "$packageName" "$param"
|
||||||
output "\\n"
|
output "\\n"
|
||||||
if [ -n "$(uci_changes dhcp)" ]; then
|
if [ -n "$(uci_changes dhcp)" ]; then
|
||||||
output "Updating dnsmasq config "
|
output "Updating dnsmasq config "
|
||||||
|
@ -248,6 +253,10 @@ start_service() {
|
||||||
else
|
else
|
||||||
output_failn
|
output_failn
|
||||||
fi
|
fi
|
||||||
|
param='dnsmasq_restart'
|
||||||
|
fi
|
||||||
|
if [ "$param" = 'on_hotplug' ] || [ "$param" = 'on_boot' ] || \
|
||||||
|
[ "$param" = 'dnsmasq_restart' ] ; then
|
||||||
output "Restarting dnsmasq "
|
output "Restarting dnsmasq "
|
||||||
if dnsmasq_restart; then
|
if dnsmasq_restart; then
|
||||||
output_okn
|
output_okn
|
||||||
|
@ -258,10 +267,11 @@ start_service() {
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_service() {
|
stop_service() {
|
||||||
|
local param="$1"
|
||||||
local canaryDomains canary_domains_icloud canary_domains_mozilla
|
local canaryDomains canary_domains_icloud canary_domains_mozilla
|
||||||
local dnsmasq_config_update
|
local dnsmasq_config_update
|
||||||
local s=0
|
local s=0
|
||||||
output "Stopping $serviceName "
|
output "Stopping $serviceName ${param:+$param }"
|
||||||
config_load "$packageName"
|
config_load "$packageName"
|
||||||
config_get dnsmasq_config_update 'config' 'dnsmasq_config_update' '*'
|
config_get dnsmasq_config_update 'config' 'dnsmasq_config_update' '*'
|
||||||
config_get_bool canary_domains_icloud 'config' 'canary_domains_icloud' '1'
|
config_get_bool canary_domains_icloud 'config' 'canary_domains_icloud' '1'
|
||||||
|
@ -278,7 +288,7 @@ stop_service() {
|
||||||
dnsmasq_restart || s=1
|
dnsmasq_restart || s=1
|
||||||
fi
|
fi
|
||||||
# shellcheck disable=SC2015
|
# shellcheck disable=SC2015
|
||||||
[ "$s" -eq 0 ] && output_okn || output_failn
|
[ "$s" = '0' ] && output_okn || output_failn
|
||||||
}
|
}
|
||||||
|
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
|
@ -319,14 +329,16 @@ dnsmasq_doh_server() {
|
||||||
::) address='::1';;
|
::) address='::1';;
|
||||||
esac
|
esac
|
||||||
uci_add_list_if_new 'dhcp' "$cfg" 'server' "${address}#${port}"
|
uci_add_list_if_new 'dhcp' "$cfg" 'server' "${address}#${port}"
|
||||||
|
uci_add_list_if_new 'dhcp' "$cfg" 'doh_server' "${address}#${port}"
|
||||||
;;
|
;;
|
||||||
remove)
|
remove)
|
||||||
eval "$(ubus call service list "{ 'verbose': true, 'name': '$packageName' }" | jsonfilter -F '# ' -e 'TUPLES=@[*].instances[*].command[4,6]')"
|
for i in $(uci -q get "dhcp.$cfg.doh_server"); do
|
||||||
for i in $TUPLES; do
|
|
||||||
uci_remove_list 'dhcp' "$cfg" 'server' "$i"
|
uci_remove_list 'dhcp' "$cfg" 'server' "$i"
|
||||||
|
uci_remove_list 'dhcp' "$cfg" 'doh_server' "$i"
|
||||||
done
|
done
|
||||||
for i in $canaryDomains; do
|
for i in $canaryDomains; do
|
||||||
uci_remove_list 'dhcp' "$cfg" 'server' "/${i}/"
|
uci_remove_list 'dhcp' "$cfg" 'server' "/${i}/"
|
||||||
|
uci_remove_list 'dhcp' "$cfg" 'doh_server' "/${i}/"
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [ "$ACTION" = 'ifup' ] && [ "$INTERFACE" = 'wan' ] && /etc/init.d/https-dns-proxy enabled; then
|
|
||||||
logger -t "https-dns-proxy" "Restarting https-dns-proxy due to $ACTION of $INTERFACE"
|
|
||||||
/etc/init.d/https-dns-proxy restart
|
|
||||||
fi
|
|
Loading…
Reference in a new issue