v0.8.0更新
~大幅度优化脚本UI及层级 ~增加在线更新脚本功能 ~增加在线更新、替换clash核心功能 ~内置dns增加redir-host支持,解决了部分应用无法连接的bug ~优化了配置文件修饰途径,现在支持通过scp上传任意yaml配置文件 ~增加了直接导入完整订阅链接的选项(待测试) ~增加了更多的订阅后端服务器
This commit is contained in:
Binary file not shown.
@@ -29,11 +29,12 @@ fi
|
|||||||
modifyyaml(){
|
modifyyaml(){
|
||||||
##########需要变更的配置###########
|
##########需要变更的配置###########
|
||||||
redir='redir-port: 7892'
|
redir='redir-port: 7892'
|
||||||
|
ipv6='ipv6: true'
|
||||||
external='external-controller: 0.0.0.0:9999'
|
external='external-controller: 0.0.0.0:9999'
|
||||||
if [ "$dns_mod" = "fake-ip" ];then
|
if [ "$dns_mod" = "fake-ip" ];then
|
||||||
dns='dns: {enable: true, listen: 0.0.0.0:1053, fake-ip-range: 198.18.0.1/16, enhanced-mode: fake-ip, nameserver: [114.114.114.114, 127.0.0.1:53], fallback: [tcp://1.0.0.1, 8.8.4.4]}'
|
dns='dns: {enable: true, listen: 0.0.0.0:1053, fake-ip-range: 198.18.0.1/16, enhanced-mode: fake-ip, nameserver: [114.114.114.114, 127.0.0.1:53], fallback: [tcp://1.0.0.1, 8.8.4.4]}'
|
||||||
else
|
else
|
||||||
dns='dns: {enable: true, listen: 0.0.0.0:1053, enhanced-mode: redir-host, nameserver: [114.114.114.114, 127.0.0.1:53], fallback: [1.0.0.1, 8.8.4.4]}'
|
dns='dns: {enable: true, ipv6: true, listen: 0.0.0.0:1053, enhanced-mode: redir-host, nameserver: [114.114.114.114, 127.0.0.1:53], fallback: [1.0.0.1, 8.8.4.4]}'
|
||||||
fi
|
fi
|
||||||
if [ "$redir_mod" = "Tun模式" ];then
|
if [ "$redir_mod" = "Tun模式" ];then
|
||||||
tun='tun: {enable: true, stack: system}'
|
tun='tun: {enable: true, stack: system}'
|
||||||
@@ -44,12 +45,14 @@ exper='experimental: {ignore-resolve-fail: true, interface-name: en0}'
|
|||||||
###################################
|
###################################
|
||||||
#预删除需要添加的项目
|
#预删除需要添加的项目
|
||||||
sed -i '/^redir-port:*/'d $clashdir/config.yaml
|
sed -i '/^redir-port:*/'d $clashdir/config.yaml
|
||||||
|
sed -i '/^ipv6: true:*/'d $clashdir/config.yaml
|
||||||
sed -i '/^external-controller:*/'d $clashdir/config.yaml
|
sed -i '/^external-controller:*/'d $clashdir/config.yaml
|
||||||
sed -i '/^dns:*/'d $clashdir/config.yaml
|
sed -i '/^dns:*/'d $clashdir/config.yaml
|
||||||
sed -i '/^tun:*/'d $clashdir/config.yaml
|
sed -i '/^tun:*/'d $clashdir/config.yaml
|
||||||
sed -i '/^experimental:*/'d $clashdir/config.yaml
|
sed -i '/^experimental:*/'d $clashdir/config.yaml
|
||||||
#添加配置
|
#添加配置
|
||||||
sed -i "2a$redir" $clashdir/config.yaml
|
sed -i "2a$redir" $clashdir/config.yaml
|
||||||
|
sed -i "5a$ipv6" $clashdir/config.yaml
|
||||||
sed -i "6a$external" $clashdir/config.yaml
|
sed -i "6a$external" $clashdir/config.yaml
|
||||||
sed -i "7a$dns" $clashdir/config.yaml
|
sed -i "7a$dns" $clashdir/config.yaml
|
||||||
sed -i "8a$tun" $clashdir/config.yaml
|
sed -i "8a$tun" $clashdir/config.yaml
|
||||||
@@ -78,6 +81,7 @@ start_redir(){
|
|||||||
iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN
|
iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN
|
||||||
iptables -t nat -A clash -p tcp $ports-j REDIRECT --to-ports 7892
|
iptables -t nat -A clash -p tcp $ports-j REDIRECT --to-ports 7892
|
||||||
iptables -t nat -A PREROUTING -p tcp -j clash
|
iptables -t nat -A PREROUTING -p tcp -j clash
|
||||||
|
#ip6tables -t nat -A PREROUTING -p tcp $ports-j REDIRECT --to-ports 7892
|
||||||
iptables -t nat -A 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
|
ip6tables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||||
}
|
}
|
||||||
@@ -87,17 +91,12 @@ stop_redir(){
|
|||||||
iptables -t nat -F clash > /dev/null 2>&1
|
iptables -t nat -F clash > /dev/null 2>&1
|
||||||
iptables -t nat -X 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
|
iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1
|
||||||
|
#ip6tables -t nat -A PREROUTING -p tcp $ports-j REDIRECT --to-ports 7892 > /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(){
|
start_tun(){
|
||||||
#修改iptables规则使流量进入clash
|
#允许tun网卡接受流量
|
||||||
iptables -I FORWARD -o utun -j ACCEPT
|
iptables -I FORWARD -o utun -j ACCEPT
|
||||||
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(){
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
start_service() {
|
start_service() {
|
||||||
getconfig
|
getconfig
|
||||||
@@ -110,21 +109,11 @@ start_service() {
|
|||||||
procd_set_param command $clashdir/clash -d $clashdir
|
procd_set_param command $clashdir/clash -d $clashdir
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
#修改iptables规则使流量进入clash
|
#修改iptables规则使流量进入clash
|
||||||
if [[ "$redir_mod" = "Tun模式" ]];then
|
|
||||||
stop_tun
|
|
||||||
start_tun
|
|
||||||
mark_time
|
|
||||||
else
|
|
||||||
stop_redir
|
stop_redir
|
||||||
|
start_tun
|
||||||
start_redir
|
start_redir
|
||||||
mark_time
|
mark_time
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
stop_service() {
|
stop_service() {
|
||||||
getconfig
|
|
||||||
if [[ "$redir_mod" = "Tun模式" ]];then
|
|
||||||
stop_tun
|
|
||||||
else
|
|
||||||
stop_redir
|
stop_redir
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,8 @@ https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_On
|
|||||||
EOF`
|
EOF`
|
||||||
#如果传来的是Url链接则合成Https链接,否则直接使用Https链接
|
#如果传来的是Url链接则合成Https链接,否则直接使用Https链接
|
||||||
if [ -z $Https ];then
|
if [ -z $Https ];then
|
||||||
Https="https://$Server/sub?target=clashr&new_name=true&url=$Url&insert=false&config=$Config"
|
Https="https://$Server/sub?target=clashr&new_name=true&url=$Url&insert=false&config=$Config"
|
||||||
|
markhttp=1
|
||||||
fi
|
fi
|
||||||
#
|
#
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
@@ -39,11 +40,14 @@ yamlnew=$yaml.new
|
|||||||
rm -rf $yamlnew > /dev/null 2>&1
|
rm -rf $yamlnew > /dev/null 2>&1
|
||||||
result=$(curl -w %{http_code} -kLo $yamlnew $Https)
|
result=$(curl -w %{http_code} -kLo $yamlnew $Https)
|
||||||
if [ "$result" != "200" ];then
|
if [ "$result" != "200" ];then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[31m配置文件获取失败!\033[0m"
|
echo -e "\033[31m配置文件获取失败!\033[0m"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo
|
echo
|
||||||
read -p "是否更换后端地址后重试?[1/0] > " res
|
if [ -z $markhttp ];then
|
||||||
|
exit;
|
||||||
|
else
|
||||||
|
read -p "是否更换后端地址后重试?[1/0] > " res
|
||||||
if [ "$res" = '1' ]; then
|
if [ "$res" = '1' ]; then
|
||||||
sed -i '/server_link=*/'d $ccfg
|
sed -i '/server_link=*/'d $ccfg
|
||||||
if [ "$server_link" = '7' ]; then
|
if [ "$server_link" = '7' ]; then
|
||||||
@@ -54,7 +58,8 @@ read -p "是否更换后端地址后重试?[1/0] > " res
|
|||||||
sed -i "1i\server_link=$server_link" $ccfg
|
sed -i "1i\server_link=$server_link" $ccfg
|
||||||
getyaml
|
getyaml
|
||||||
fi
|
fi
|
||||||
exit;
|
exit;
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if cat $yamlnew | grep ', server:' >/dev/null;then
|
if cat $yamlnew | grep ', server:' >/dev/null;then
|
||||||
#替换文件
|
#替换文件
|
||||||
@@ -183,7 +188,7 @@ echo -----------------------------------------------
|
|||||||
read -p "请输入完整链接 > " Https
|
read -p "请输入完整链接 > " Https
|
||||||
test=$(echo $Https | grep "://")
|
test=$(echo $Https | grep "://")
|
||||||
Https=`echo ${Https/\ \(*\)/''}` #删除恶心的超链接内容
|
Https=`echo ${Https/\ \(*\)/''}` #删除恶心的超链接内容
|
||||||
Https=`echo ${Https//\&/\%26}` #将分隔符 & 替换成Httpscode:%26
|
#Https=`echo ${Https//\&/\%26}` #将分隔符 & 替换成Httpscode:%26
|
||||||
if [ -n $Https ];then
|
if [ -n $Https ];then
|
||||||
if [ -n $test ];then
|
if [ -n $test ];then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
@@ -263,7 +268,7 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cpucore=armv5
|
cpucore=armv7
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "当前clash核心:\033[47;30m $clashcore \033[46;30m$version\033[0m"
|
echo -e "当前clash核心:\033[47;30m $clashcore \033[46;30m$version\033[0m"
|
||||||
echo -e "\033[32m请选择需要下载的核心版本!\033[0m"
|
echo -e "\033[32m请选择需要下载的核心版本!\033[0m"
|
||||||
|
|||||||
Reference in New Issue
Block a user