https-dns-proxy: only restart firewall when needed 22874/head
authorStan Grishin <stangri@melmac.ca>
Mon, 11 Dec 2023 13:18:21 +0000 (13:18 +0000)
committerStan Grishin <stangri@melmac.ca>
Mon, 11 Dec 2023 13:19:27 +0000 (13:19 +0000)
* only restart firewall when needed

Signed-off-by: Stan Grishin <stangri@melmac.ca>
(cherry picked from commit 8b6635bae9717babbc3dcf1347cf4727fc15f9bd)

net/https-dns-proxy/Makefile
net/https-dns-proxy/files/etc/init.d/https-dns-proxy
net/https-dns-proxy/patches/020-src-options.c-add-version.patch

index 69b6bbe8783e3e2faf9c5106543d82260862518e..d290ef7b5f5fb42757f96aa8a185373abcd640d9 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=https-dns-proxy
 PKG_VERSION:=2023-10-25
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/aarond10/https_dns_proxy/
index c9e38cca9ae7def6f7bcdde77f03730a6c6034f3..0a11111c5705a8b58d2af04dc2703230a15d04a5 100755 (executable)
@@ -31,6 +31,7 @@ readonly canaryDomainsiCloud='mask.icloud.com mask-h2.icloud.com'
 on_boot_trigger=
 
 dnsmasq_restart() { [ -x /etc/init.d/dnsmasq ] || return 1; /etc/init.d/dnsmasq restart >/dev/null 2>&1; }
+is_fw4_restart_needed() { [ "$(uci_get "$packageName" 'config' 'force_dns' '1')" = '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; }
 is_ipv6() { ! is_mac_address "$1" && str_contains "$1" ":"; }
@@ -168,7 +169,7 @@ start_instance() {
        json_add_object mdns
                procd_add_mdns_service "$packageName" 'udp' "$port" "DNS over HTTPS proxy"
        json_close_object
-       if [ "$force_dns" -ne 0 ]; then
+       if [ "$force_dns" -ne '0' ]; then
                json_add_array firewall
                for iface in $procd_fw_src_interfaces; do
                        for p in $force_dns_port; do
@@ -218,7 +219,7 @@ start_instance() {
                fi
                output_ok
                port="$((port+1))"
-               force_dns=0
+               force_dns='0'
        else
                output_fail
        fi
@@ -318,8 +319,8 @@ service_triggers() {
        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; }
+service_started() { is_fw4_restart_needed && procd_set_config_changed firewall; }
+service_stopped() { is_fw4_restart_needed && procd_set_config_changed firewall; }
 restart() { procd_send_signal "$packageName"; rc_procd start_service "$*"; }
 
 dnsmasq_doh_server() {
@@ -339,7 +340,7 @@ dnsmasq_doh_server() {
                        uci_add_list_if_new 'dhcp' "$cfg" 'doh_server' "${address}#${port}"
                ;;
                remove)
-                       for i in $(uci -q get "dhcp.$cfg.doh_server"); do
+                       for i in $(uci_get 'dhcp' "$cfg" 'doh_server'); do
                                uci_remove_list 'dhcp' "$cfg" 'server' "$i"
                                uci_remove_list 'dhcp' "$cfg" 'doh_server' "$i"
                        done
index 8f3b9dfa24e0ab441db6b75468802d1fd1e96c5f..993a9b8d32dc2d5dc859a28d66d2ce0f7a3597c5 100644 (file)
@@ -5,7 +5,7 @@
    return SW_VERSION;
  #else
 -  return "2023.10.10-atLeast";  // update date sometimes, like 1-2 times a year
-+  return "2023-10-25-4";  // update date sometimes, like 1-2 times a year
++  return "2023-10-25-5";  // update date sometimes, like 1-2 times a year
  #endif
  }