Skip to content

Commit

Permalink
fix ping issue if dns forwarder is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
frainzy1477 committed Jan 17, 2020
1 parent 750e70d commit a77cd7c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-clash
PKG_VERSION:=1.4.7
PKG_VERSION:=1.4.8
PKG_MAINTAINER:=frainzy1477


Expand Down
6 changes: 5 additions & 1 deletion root/etc/init.d/clash
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CLASHT="/etc/clash/clashtun/clash"
CLASH_CONFIG="/etc/clash"
CRON_FILE="/etc/crontabs/root"
CONFIG_YAML="/etc/clash/config.yaml"
CONFIG_YAML_OLD="/etc/clash/config.yml"
CONFIG_YAML_OLD="/etc/clash/config.yml"

CONFIG_YAML_SUB="/usr/share/clash/config/sub/config.yaml"
CONFIG_YAML_UPL="/usr/share/clash/config/upload/config.yaml"
Expand Down Expand Up @@ -621,6 +621,9 @@ remove_mark(){
/etc/init.d/dnsmasq restart >/dev/null 2>&1
}

del_list() {
sh /usr/share/clash/del_servers.sh >/dev/null 2>&1
}

stop(){
#===========================================================================================================================
Expand Down Expand Up @@ -700,6 +703,7 @@ stop(){
elif [ "${lang}" == "zh_cn" ];then
echo "重启 Dnsmasq 程序" >$REAL_LOG
fi
del_list >/dev/null 2>&1
revert_dns >/dev/null 2>&1
sleep 1

Expand Down
19 changes: 19 additions & 0 deletions root/usr/share/clash/del_servers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh

del_address(){
countt=$(grep -c '' /usr/share/clashbackup/address.list)
count_nums=1
while [[ $count_nums -le $countt ]]
do
line=$(sed -n "$count_nums"p /usr/share/clashbackup/address.list)
check_addr=$(grep -F "$line" "/usr/share/clash/server.list")
line_no=$(grep -n "$check_addr" /usr/share/clash/server.list |awk -F ':' '{print $1}')
if [ ! -z $check_addr ];then
sed -i "${line_no}d" /usr/share/clash/server.list
fi
count_nums=$(( $count_nums + 1))
done
rm -rf /usr/share/clashbackup/address.list >/dev/null 2>&1
}
del_address >/dev/null 2>&1
38 changes: 37 additions & 1 deletion root/usr/share/clash/list.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
#!/bin/sh
#!/bin/bash /etc/rc.common
. /lib/functions.sh

dnsforwader=$(uci get clash.config.dnsforwader 2>/dev/null)

add_address(){
servers_get()
{
local section="$1"
config_get "server" "$section" "server" ""
echo "$server" >>/tmp/server.conf
}
config_load clash
config_foreach servers_get "servers"

count=$(grep -c '' /tmp/server.conf)
count_num=1
while [[ $count_num -le $count ]]
do
line=$(sed -n "$count_num"p /tmp/server.conf)
check_addr=$(grep -F "$line" "/usr/share/clash/server.list")
if [ -z $check_addr ];then
echo $line >>/usr/share/clashbackup/address.list
fi
count_num=$(( $count_num + 1))
done
cat /usr/share/clashbackup/address.list /usr/share/clash/server.list > /usr/share/clash/me.list
rm -rf /usr/share/clash/server.list
mv /usr/share/clash/me.list /usr/share/clash/server.list
chmod 755 /usr/share/clash/server.list
rm -rf /tmp/server.conf >/dev/null 2>&1
}
if [ "${dnsforwader}" -eq 1 ];then
add_address >/dev/null 2>&1
fi


enable_list=$(uci get clash.config.cus_list 2>/dev/null)
if [ $enable_list -eq 1 ];then

Expand Down
2 changes: 1 addition & 1 deletion root/usr/share/clash/luci_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.7
1.4.8

0 comments on commit a77cd7c

Please sign in to comment.