luci app sfe: dnscache daemon by prcd
This commit is contained in:
parent
2069e1736d
commit
d8e7029381
@ -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_DEPENDS:=+kmod-fast-classifier +pdnsd-alt +kmod-tcp-bbr @LINUX_4_9
|
||||||
LUCI_PKGARCH:=all
|
LUCI_PKGARCH:=all
|
||||||
PKG_VERSION:=1.0
|
PKG_VERSION:=1.0
|
||||||
PKG_RELEASE:=11
|
PKG_RELEASE:=12
|
||||||
|
|
||||||
include $(TOPDIR)/feeds/luci/luci.mk
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/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
|
DNSMASQ_RESTART=N
|
||||||
DNS_SERVER="114.114.114.114,114.114.115.115"
|
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)
|
DNS_SERVER=$(uci get sfe.config.dns_server 2>/dev/null)
|
||||||
|
|
||||||
[ -d /var/etc ] || mkdir -p /var/etc
|
[ -d /var/etc ] || mkdir -p /var/etc
|
||||||
@ -125,13 +128,6 @@ EOF
|
|||||||
|
|
||||||
[ -d /var/sbin ] || mkdir -p /var/sbin
|
[ -d /var/sbin ] || mkdir -p /var/sbin
|
||||||
[ -f /var/sbin/dnscache ] || cp -a /usr/sbin/pdnsd /var/sbin/dnscache
|
[ -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() {
|
change_dns() {
|
||||||
@ -149,14 +145,14 @@ revert_dns() {
|
|||||||
uci commit dhcp
|
uci commit dhcp
|
||||||
}
|
}
|
||||||
|
|
||||||
start(){
|
start_service() {
|
||||||
enable=$(uci get sfe.config.enabled 2>/dev/null)
|
enable=$(uci get sfe.config.enabled 2>/dev/null)
|
||||||
wifi=$(uci get sfe.config.wifi)
|
wifi=$(uci get sfe.config.wifi)
|
||||||
ipv6=$(uci get sfe.config.ipv6)
|
ipv6=$(uci get sfe.config.ipv6)
|
||||||
dns=$(uci get sfe.config.dns 2>/dev/null)
|
dns=$(uci get sfe.config.dns 2>/dev/null)
|
||||||
bbr=$(uci get sfe.config.bbr 2>/dev/null)
|
bbr=$(uci get sfe.config.bbr 2>/dev/null)
|
||||||
|
|
||||||
if [ $enable -eq 1 ]; then
|
if [ $enable -eq 1 ]; then
|
||||||
echo "enable"
|
|
||||||
! (lsmod | grep fast_classifier >/dev/null) && (modprobe fast_classifier)
|
! (lsmod | grep fast_classifier >/dev/null) && (modprobe fast_classifier)
|
||||||
if [ $wifi -eq 1 ] ; then
|
if [ $wifi -eq 1 ] ; then
|
||||||
echo 1 > /sys/fast_classifier/skip_to_bridge_ingress
|
echo 1 > /sys/fast_classifier/skip_to_bridge_ingress
|
||||||
@ -172,27 +168,33 @@ start(){
|
|||||||
else
|
else
|
||||||
rmmod fast_classifier >/dev/null 2>&1
|
rmmod fast_classifier >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $dns -eq 1 ]; then
|
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
|
change_dns
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $bbr -eq 1 ]; then
|
if [ $bbr -eq 1 ]; then
|
||||||
sysctl -w net.ipv4.tcp_congestion_control=bbr
|
sysctl -w net.ipv4.tcp_congestion_control=bbr
|
||||||
else
|
else
|
||||||
sysctl -w net.ipv4.tcp_congestion_control=cubic
|
sysctl -w net.ipv4.tcp_congestion_control=cubic
|
||||||
fi
|
fi
|
||||||
if [ "$DNSMASQ_RESTART" = N ]; then
|
if [ "$DNSMASQ_RESTART" = N ]; then
|
||||||
/etc/init.d/dnsmasq restart && echo "DNSMASQ change"
|
/etc/init.d/dnsmasq restart
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stop(){
|
stop_service(){
|
||||||
enable=$(uci get sfe.config.enabled 2>/dev/null)
|
enable=$(uci get sfe.config.enabled 2>/dev/null)
|
||||||
[ $enable -ne 1 ] && rmmod fast_classifier >/dev/null 2>&1
|
[ $enable -ne 1 ] && rmmod fast_classifier >/dev/null 2>&1
|
||||||
stop_pdnsd
|
|
||||||
revert_dns
|
revert_dns
|
||||||
if [ "$DNSMASQ_RESTART" = N ]; then
|
if [ "$DNSMASQ_RESTART" = N ]; then
|
||||||
/etc/init.d/dnsmasq restart && echo "DNSMASQ revert"
|
/etc/init.d/dnsmasq restart
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,5 +204,3 @@ restart(){
|
|||||||
start
|
start
|
||||||
/etc/init.d/dnsmasq restart && echo "DNSMASQ restart"
|
/etc/init.d/dnsmasq restart && echo "DNSMASQ restart"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,9 +7,6 @@ uci -q batch <<-EOF >/dev/null
|
|||||||
commit ucitrack
|
commit ucitrack
|
||||||
EOF
|
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
|
[ ! -f /usr/sbin/dnscache ] && ln /usr/sbin/pdnsd /usr/sbin/dnscache
|
||||||
/etc/init.d/sfe enable
|
/etc/init.d/sfe enable
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user