luci app sfe: dnscache daemon by prcd

This commit is contained in:
coolsnowwolf 2018-12-21 00:55:05 +08:00
parent 2069e1736d
commit d8e7029381
3 changed files with 22 additions and 25 deletions

View File

@ -9,7 +9,7 @@ LUCI_TITLE:=LuCI support for Turbo ACC (SFE)
LUCI_DEPENDS:=+kmod-fast-classifier +pdnsd-alt +kmod-tcp-bbr @LINUX_4_9
LUCI_PKGARCH:=all
PKG_VERSION:=1.0
PKG_RELEASE:=11
PKG_RELEASE:=12
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -1,12 +1,15 @@
#!/bin/sh /etc/rc.common
# Copyright (c) 2011-2015 OpenWrt.org
# Copyright (C) 2007-2012 OpenWrt.org
START=30
START=90
USE_PROCD=1
PDNSD_BIN="/var/sbin/dnscache"
DNSMASQ_RESTART=N
DNS_SERVER="114.114.114.114,114.114.115.115"
start_pdnsd() {
pdnsd_genconfig() {
DNS_SERVER=$(uci get sfe.config.dns_server 2>/dev/null)
[ -d /var/etc ] || mkdir -p /var/etc
@ -125,13 +128,6 @@ EOF
[ -d /var/sbin ] || mkdir -p /var/sbin
[ -f /var/sbin/dnscache ] || cp -a /usr/sbin/pdnsd /var/sbin/dnscache
/var/sbin/dnscache -c /var/etc/dnscache.conf -d
echo "Start DNS Cache"
}
stop_pdnsd() {
kill $(pidof dnscache) >/dev/null 2>&1 || kill -9 $(ps | grep dnscache | grep -v grep | awk '{print $1}') >/dev/null 2>&1
echo "Stop DNS Cache"
}
change_dns() {
@ -149,14 +145,14 @@ revert_dns() {
uci commit dhcp
}
start(){
start_service() {
enable=$(uci get sfe.config.enabled 2>/dev/null)
wifi=$(uci get sfe.config.wifi)
ipv6=$(uci get sfe.config.ipv6)
dns=$(uci get sfe.config.dns 2>/dev/null)
bbr=$(uci get sfe.config.bbr 2>/dev/null)
if [ $enable -eq 1 ]; then
echo "enable"
if [ $enable -eq 1 ]; then
! (lsmod | grep fast_classifier >/dev/null) && (modprobe fast_classifier)
if [ $wifi -eq 1 ] ; then
echo 1 > /sys/fast_classifier/skip_to_bridge_ingress
@ -172,27 +168,33 @@ start(){
else
rmmod fast_classifier >/dev/null 2>&1
fi
if [ $dns -eq 1 ]; then
start_pdnsd
pdnsd_genconfig
procd_open_instance
procd_set_param command "$PDNSD_BIN" -c /var/etc/dnscache.conf
procd_set_param respawn
procd_set_param stderr 1
procd_close_instance
change_dns
fi
if [ $bbr -eq 1 ]; then
sysctl -w net.ipv4.tcp_congestion_control=bbr
else
sysctl -w net.ipv4.tcp_congestion_control=cubic
fi
if [ "$DNSMASQ_RESTART" = N ]; then
/etc/init.d/dnsmasq restart && echo "DNSMASQ change"
/etc/init.d/dnsmasq restart
fi
}
stop(){
stop_service(){
enable=$(uci get sfe.config.enabled 2>/dev/null)
[ $enable -ne 1 ] && rmmod fast_classifier >/dev/null 2>&1
stop_pdnsd
revert_dns
if [ "$DNSMASQ_RESTART" = N ]; then
/etc/init.d/dnsmasq restart && echo "DNSMASQ revert"
/etc/init.d/dnsmasq restart
fi
}
@ -201,6 +203,4 @@ restart(){
stop
start
/etc/init.d/dnsmasq restart && echo "DNSMASQ restart"
}
}

View File

@ -7,9 +7,6 @@ uci -q batch <<-EOF >/dev/null
commit ucitrack
EOF
sed -i '/dnscache-watchdog.sh/d' /etc/crontabs/root
echo '*/60 * * * * /usr/share/dnscache-watchdog.sh' >> /etc/crontabs/root
[ ! -f /usr/sbin/dnscache ] && ln /usr/sbin/pdnsd /usr/sbin/dnscache
/etc/init.d/sfe enable