1.项目路径全部变量化,只需要修改脚本开头的clash目录即可适配任意目录位置
2,修复了redir模式tun网卡依然开启的bug
This commit is contained in:
@@ -6,8 +6,8 @@ USE_PROCD=1
|
||||
START=99
|
||||
|
||||
getconfig(){
|
||||
ccfg=/etc/clash/mark
|
||||
csh=/bin/clash
|
||||
cpath=/etc/clash
|
||||
ccfg=$cpath/mark
|
||||
if [ ! -f "$ccfg" ]; then
|
||||
echo mark文件不存在,默认以Redir模式运行!
|
||||
cat >$ccfg<<EOF
|
||||
@@ -37,7 +37,6 @@ start_redir(){
|
||||
iptables -t nat -A PREROUTING -p tcp -j clash
|
||||
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
ip6tables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
|
||||
}
|
||||
stop_redir(){
|
||||
#重置iptables规则
|
||||
@@ -45,12 +44,12 @@ stop_redir(){
|
||||
iptables -t nat -F clash > /dev/null 2>&1
|
||||
iptables -t nat -X clash > /dev/null 2>&1
|
||||
iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1
|
||||
ip6tables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1
|
||||
ip6tables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1
|
||||
}
|
||||
start_tun(){
|
||||
#修改iptables规则使流量进入clash
|
||||
iptables -I FORWARD -o utun -j ACCEPT
|
||||
iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
ip6tables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
}
|
||||
stop_tun(){
|
||||
@@ -58,15 +57,15 @@ stop_tun(){
|
||||
ip6tables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1
|
||||
}
|
||||
start_service() {
|
||||
getconfig
|
||||
#创建clash后台进程
|
||||
procd_open_instance
|
||||
procd_set_param respawn
|
||||
procd_set_param stderr 1
|
||||
procd_set_param stdout 1
|
||||
procd_set_param command /etc/clash/clash -d /etc/clash
|
||||
procd_set_param command $cpath/clash -d $cpath
|
||||
procd_close_instance
|
||||
#修改iptables规则使流量进入clash
|
||||
getconfig
|
||||
if [[ "$redir_mod" = "Tun模式" ]];then
|
||||
stop_tun
|
||||
start_tun
|
||||
|
||||
Reference in New Issue
Block a user