dnsproxy: new features 22598/head
authorAnya Lin <hukk1996@gmail.com>
Sat, 4 Nov 2023 04:19:06 +0000 (12:19 +0800)
committerAnya Lin <hukk1996@gmail.com>
Sun, 5 Nov 2023 07:00:22 +0000 (15:00 +0800)
1. Add new options:
  --http3    Enable HTTP/3 support (H3 first)
  --timeout  Timeout for outbound DNS queries to remote upstream servers in a human-readable form (default: 10s)

2. Allows listen on multiple interfaces and ports

Signed-off-by: Anya Lin <hukk1996@gmail.com>
(cherry picked from commit 47b4ebc5cb5d3bf24c8a15a8f5cb9a99faed5e1a)
Signed-off-by: Anya Lin <hukk1996@gmail.com>
net/dnsproxy/Makefile
net/dnsproxy/files/dnsproxy.config
net/dnsproxy/files/dnsproxy.defaults [new file with mode: 0644]
net/dnsproxy/files/dnsproxy.init

index 95c0dcc6c68d94a1ca6807187cfb29c7f44c26aa..69ef545830e13f73bb65932eceea9bd1815e7612 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=dnsproxy
 PKG_VERSION:=0.52.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/AdguardTeam/dnsproxy/tar.gz/v$(PKG_VERSION)?
@@ -49,6 +49,8 @@ define Package/dnsproxy/install
        $(INSTALL_CONF) $(CURDIR)/files/dnsproxy.config $(1)/etc/config/dnsproxy
        $(INSTALL_DIR) $(1)/etc/init.d/
        $(INSTALL_BIN) $(CURDIR)/files/dnsproxy.init $(1)/etc/init.d/dnsproxy
+       $(INSTALL_DIR) $(1)/etc/uci-defaults/
+       $(INSTALL_BIN) $(CURDIR)/files/dnsproxy.defaults $(1)/etc/uci-defaults/80-dnsproxy-migration
 endef
 
 define Package/dnsproxy/conffiles
index a9fa020280804e2432b7983aadadd061fde4a292..90feb94d468b5904bd8949523828cf666d1c9ed3 100644 (file)
@@ -3,13 +3,16 @@
 
 config dnsproxy 'global'
        option enabled '0'
-       option listen_addr '127.0.0.1'
-       option listen_port '5353'
+       list listen_addr '127.0.0.1'
+       list listen_addr '::1'
+       list listen_port '5353'
        option log_file ''
        option all_servers '0'
        option fastest_addr '0'
+       option http3 '0'
        option insecure '0'
        option ipv6_disabled '0'
+       option timeout ''
        option max_go_routines ''
        option rate_limit ''
        option refuse_any '0'
diff --git a/net/dnsproxy/files/dnsproxy.defaults b/net/dnsproxy/files/dnsproxy.defaults
new file mode 100644 (file)
index 0000000..7ce089f
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+[ -s "/etc/config/dnsproxy" ] || exit 0
+
+#Migrate options 'listen_addr' 'listen_port' to list type
+sed -i -e "s,option listen_addr,list listen_addr,g" \
+       -e "s,option listen_port,list listen_port,g" "/etc/config/dnsproxy"
+exit 0
index 1514ee152630b558ec470e66460597ebffda0da0..fc04ac9a6828ca29e50944d6a14a6bfcdeb59b64 100644 (file)
@@ -44,6 +44,7 @@ append_param_bool() {
 load_config_arg() {
        append_param_bool "$1" "all_servers"
        append_param_bool "$1" "fastest_addr"
+       append_param_bool "$1" "http3"
        append_param_bool "$1" "insecure"
        append_param_bool "$1" "ipv6_disabled"
        append_param_bool "$1" "refuse_any"
@@ -51,6 +52,18 @@ load_config_arg() {
 }
 
 load_config_list() {
+       if is_empty "global" "listen_addr"; then
+               append_param "--listen" "127.0.0.1"
+       else 
+               config_list_foreach "global" "listen_addr" "append_param '--listen'"
+       fi
+
+       if is_empty "global" "listen_port"; then
+               append_param "--port" "5353"
+       else 
+               config_list_foreach "global" "listen_port" "append_param '--port'"
+       fi
+
        is_empty "bogus_nxdomain" "ip_addr" || config_list_foreach "bogus_nxdomain" "ip_addr" "append_param '--bogus-nxdomain'"
 
        for i in "bootstrap" "fallback" "upstream"; do
@@ -59,9 +72,8 @@ load_config_list() {
 }
 
 load_config_param() {
-       append_param_arg "global" "listen_addr" "--listen" "127.0.0.1"
-       append_param_arg "global" "listen_port" "--port" "5353"
        append_param_arg "global" "log_file" "--output"
+       append_param_arg "global" "timeout" "--timeout"
        append_param_arg "global" "max_go_routines" "--max-go-routines"
        append_param_arg "global" "rate_limit" "--ratelimit"
        append_param_arg "global" "udp_buf_size" "--udp-buf-size"