https-dns-proxy: bugfix: prevent crashes on IPv6 systems 22489/head
authorStan Grishin <stangri@melmac.ca>
Tue, 24 Oct 2023 02:14:08 +0000 (02:14 +0000)
committerStan Grishin <stangri@melmac.ca>
Tue, 24 Oct 2023 02:14:54 +0000 (02:14 +0000)
* update service triggers so that procd_add_raw_trigger is only
  executed on boot and not on other service actions
* remove outdated iface hotplug script

Signed-off-by: Stan Grishin <stangri@melmac.ca>
net/https-dns-proxy/Makefile
net/https-dns-proxy/files/etc/hotplug.d/iface/90-https-dns-proxy [deleted file]
net/https-dns-proxy/files/etc/init.d/https-dns-proxy

index 5c6912e2ea4b7ca6b2fa359210fa183de95a6c4d..e6008ac9fa94723e67fafd2308c2692706c55aa6 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=https-dns-proxy
 PKG_VERSION:=2023-05-25
-PKG_RELEASE:=7
+PKG_RELEASE:=8
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/aarond10/https_dns_proxy/
diff --git a/net/https-dns-proxy/files/etc/hotplug.d/iface/90-https-dns-proxy b/net/https-dns-proxy/files/etc/hotplug.d/iface/90-https-dns-proxy
deleted file mode 100644 (file)
index 5acf7b7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-# Copied from https://openwrt.org/docs/guide-user/advanced/hotplug_extras
-# shellcheck disable=SC1091
-. /lib/functions/network.sh
-network_flush_cache
-network_find_wan NET_IF
-network_find_wan6 NET_IF6
-[ "$INTERFACE" != "$NET_IF" ] && [ "$INTERFACE" != "$NET_IF6" ] && exit 0
-[ "$ACTION" != "ifup" ] && [ "$ACTION" != "ifupdate" ] && exit 0
-[ "$ACTION" = "ifupdate" ] && [ -z "$IFUPDATE_ADDRESSES" ] && \
-[ -z "$IFUPDATE_DATA" ] && exit 0
-
-sleep 10
-/etc/init.d/https-dns-proxy start 'on_hotplug'
index 58fd647c1516d9d967dac0c358339b2889b7d727..5679f6349890094e4709041008737cbe688cd487 100755 (executable)
@@ -28,6 +28,8 @@ readonly DEFAULT_BOOTSTRAP="${BOOTSTRAP_CF},${BOOTSTRAP_GOOGLE}"
 readonly canaryDomainsMozilla='use-application-dns.net'
 readonly canaryDomainsiCloud='mask.icloud.com mask-h2.icloud.com'
 
+on_boot_trigger=
+
 str_contains() { [ -n "$1" ] &&[ -n "$2" ] && [ "${1//$2}" != "$1" ]; }
 is_mac_address() { expr "$1" : '[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]$' >/dev/null; }
 is_ipv4() { expr "$1" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; }
@@ -133,7 +135,8 @@ resolver_health_check() { resolveip -t 3 one.one.one.one >/dev/null 2>&1; }
 
 boot() {
        ubus -t 30 wait_for network.interface 2>/dev/null
-       rc_procd start_service 'on_boot'
+       on_boot_trigger=1
+       rc_procd start_service 'on_boot' && rc_procd service_started 'on_boot'
        resolver_health_check || rc_procd stop_service 'on_boot'
 }
 
@@ -295,9 +298,28 @@ stop_service() {
 }
 
 service_triggers() {
-       procd_add_raw_trigger "interface.*.up" 3000 "/etc/init.d/${packageName}" restart 'on_interface_up'
+       local wan wan6 i
+       local procd_trigger_wan6
+       if [ "$on_boot_trigger" = '1' ]; then
+               procd_add_raw_trigger "interface.*.up" 3000 "/etc/init.d/${packageName}" restart 'on_interface_up'
+       else
+               config_load "$packageName"
+               config_get_bool procd_trigger_wan6 'config' 'procd_trigger_wan6' '0'
+               . /lib/functions/network.sh
+               network_flush_cache
+               network_find_wan wan
+               wan="${wan:-wan}"
+               if [ "$procd_trigger_wan6" -ne 0 ]; then
+                       network_find_wan6 wan6
+                       wan6="${wan6:-wan6}"
+               fi
+               for i in $wan $wan6; do
+                       procd_add_interface_trigger "interface.*" "$i" "/etc/init.d/${packageName}" restart 'on_interface_trigger'
+               done
+       fi
        procd_add_config_trigger "config.change" "$packageName" "/etc/init.d/${packageName}" reload 'on_config_change'
 }
+
 service_started() { procd_set_config_changed firewall; }
 service_stopped() { procd_set_config_changed firewall; }
 restart() { procd_send_signal "$packageName"; rc_procd start_service "$*"; }