Skip to content

Commit

Permalink
dnsproxy: fix set hosts options
Browse files Browse the repository at this point in the history
1. Mount hosts files since the daemon is in ujail
2. Set hosts options at last as all other options set after it will
   be ignored

Drop redundant reload_service func while at it.

Fixes: ecdf987 ("dnsproxy: add hosts configurations")
Signed-off-by: Tianling Shen <[email protected]>
  • Loading branch information
1715173329 committed Sep 23, 2024
1 parent 446c9dd commit 999507b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion net/dnsproxy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=dnsproxy
PKG_VERSION:=0.73.2
PKG_RELEASE:=2
PKG_RELEASE:=3

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/AdguardTeam/dnsproxy/tar.gz/v$(PKG_VERSION)?
Expand Down
19 changes: 8 additions & 11 deletions net/dnsproxy/files/dnsproxy.init
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ load_config_list() {

is_empty "bogus_nxdomain" "ip_addr" || config_list_foreach "bogus_nxdomain" "ip_addr" "append_param '--bogus-nxdomain'"

is_enabled "hosts" "enabled" && {
config_list_foreach "hosts" "hosts_files" "append_param '--hosts-files'"
}

is_enabled "private_rdns" "enabled" && {
append_param "--use-private-rdns"
config_list_foreach "private_rdns" "upstream" "append_param '--private-rdns-upstream'"
Expand All @@ -86,8 +82,6 @@ load_config_param() {
append_param_arg "global" "udp_buf_size" "--udp-buf-size"
append_param_arg "global" "upstream_mode" "--upstream-mode"

append_param_arg "hosts" "enabled" "--hosts-file-enabled" "0"

is_enabled "cache" "enabled" && {
append_param "--cache"
append_param_bool "cache" "cache_optimistic"
Expand Down Expand Up @@ -132,26 +126,29 @@ start_service() {
load_config_list
load_config_param

# This must be set at last, all other options set after this will be ignored
is_enabled "hosts" "enabled" && {
append_param "--hosts-file-enabled" "true"
config_list_foreach "hosts" "hosts_files" "append_param '--hosts-files'"
} || append_param "--hosts-file-enabled" "false"

procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param user dnsproxy

procd_add_jail dnsproxy ronly log
procd_set_param capabilities "/etc/capabilities/dnsproxy.json"
procd_add_jail_mount "/etc/hosts"
procd_add_jail_mount "/etc/ssl/certs/ca-certificates.crt"
[ -z "$log_file" ] || procd_add_jail_mount_rw "$log_file"
[ -z "$tls_crt" ] || procd_add_jail_mount "$tls_crt"
[ -z "$tls_key" ] || procd_add_jail_mount "$tls_key"
is_enabled "hosts" "enabled" && config_list_foreach "hosts" "hosts_files" "procd_add_jail_mount"

procd_close_instance
}

reload_service() {
stop
start
}

service_triggers() {
procd_add_reload_trigger "$CONF"
}

0 comments on commit 999507b

Please sign in to comment.