1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-26 09:37:44 +02:00

dnscrypt-proxy: start from procd interface trigger, not in init

* Start dnscrypt-proxy from procd interface trigger rather than
immediately in init, to fix a possible race condition during boot and
get rid of rc.local restarts. You can restrict trigger interface(s) by
'procd_trigger' in new global config section.

* tab/whitespace cosmetics

Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
Dirk Brenken 2017-07-27 12:44:43 +02:00
parent 5a58466cac
commit f5d5f5f176
3 changed files with 36 additions and 8 deletions

View File

@ -11,7 +11,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dnscrypt-proxy
PKG_VERSION:=1.9.5
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://download.dnscrypt.org/dnscrypt-proxy \

View File

@ -1,3 +1,9 @@
config global
# start dnscrypt-proxy from procd interface trigger rather than immediately in init
# if needed you can restrict trigger to certain interface(s)
# list procd_trigger 'wan'
# list procd_trigger 'wan6'
config dnscrypt-proxy ns1
option address '127.0.0.1'
option port '5353'

View File

@ -6,6 +6,11 @@ PROG=/usr/sbin/dnscrypt-proxy
CONFIG_DIR=/var/etc
USER=nobody
boot() {
dnscrypt_boot=1
rc_procd start_service
}
dnscrypt_instance() {
local config_path="$CONFIG_DIR/dnscrypt-proxy-$1.conf"
create_config_file $1 "$config_path"
@ -133,10 +138,27 @@ append_blacklists() {
}
start_service() {
if [ -n "${dnscrypt_boot}" ]
then
return 0
fi
config_load dnscrypt-proxy
config_foreach dnscrypt_instance dnscrypt-proxy
}
service_triggers() {
local trigger
local triggerlist="$(uci_get dnscrypt-proxy.@global[0].procd_trigger)"
PROCD_RELOAD_DELAY=2000
if [ -n "${triggerlist}" ]
then
for trigger in ${triggerlist}
do
procd_add_interface_trigger "interface.*.up" "${trigger}" /etc/init.d/dnscrypt-proxy reload
done
else
procd_add_raw_trigger "interface.*.up" 2000 /etc/init.d/dnscrypt-proxy reload
fi
procd_add_reload_trigger 'dnscrypt-proxy'
}