diff --git a/bin/clashfm.tar.gz b/bin/clashfm.tar.gz index a0f0395..c6c16e7 100644 Binary files a/bin/clashfm.tar.gz and b/bin/clashfm.tar.gz differ diff --git a/scripts/clashservice b/scripts/clashservice index 51f2a5c..dd735de 100644 --- a/scripts/clashservice +++ b/scripts/clashservice @@ -29,11 +29,12 @@ fi modifyyaml(){ ##########需要变更的配置########### redir='redir-port: 7892' +ipv6='ipv6: true' external='external-controller: 0.0.0.0:9999' 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]}' 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 if [ "$redir_mod" = "Tun模式" ];then 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 '/^ipv6: true:*/'d $clashdir/config.yaml sed -i '/^external-controller:*/'d $clashdir/config.yaml sed -i '/^dns:*/'d $clashdir/config.yaml sed -i '/^tun:*/'d $clashdir/config.yaml sed -i '/^experimental:*/'d $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 "7a$dns" $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 -p tcp $ports-j REDIRECT --to-ports 7892 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 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 -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 -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 } start_tun(){ - #修改iptables规则使流量进入clash + #允许tun网卡接受流量 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() { getconfig @@ -110,21 +109,11 @@ start_service() { procd_set_param command $clashdir/clash -d $clashdir procd_close_instance #修改iptables规则使流量进入clash - if [[ "$redir_mod" = "Tun模式" ]];then - stop_tun - start_tun - mark_time - else - stop_redir - start_redir - mark_time - fi + stop_redir + start_tun + start_redir + mark_time } stop_service() { - getconfig - if [[ "$redir_mod" = "Tun模式" ]];then - stop_tun - else - stop_redir - fi + stop_redir } \ No newline at end of file diff --git a/scripts/getdate.sh b/scripts/getdate.sh index 3c3f56b..46b168a 100644 --- a/scripts/getdate.sh +++ b/scripts/getdate.sh @@ -22,7 +22,8 @@ https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_On EOF` #如果传来的是Url链接则合成Https链接,否则直接使用Https链接 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 # echo ----------------------------------------------- @@ -39,64 +40,68 @@ yamlnew=$yaml.new rm -rf $yamlnew > /dev/null 2>&1 result=$(curl -w %{http_code} -kLo $yamlnew $Https) if [ "$result" != "200" ];then -echo ----------------------------------------------- -echo -e "\033[31m配置文件获取失败!\033[0m" -echo ----------------------------------------------- -echo -read -p "是否更换后端地址后重试?[1/0] > " res - if [ "$res" = '1' ]; then - sed -i '/server_link=*/'d $ccfg - if [ "$server_link" = '7' ]; then - server_link=0 + echo ----------------------------------------------- + echo -e "\033[31m配置文件获取失败!\033[0m" + echo ----------------------------------------------- + echo + if [ -z $markhttp ];then + exit; + else + read -p "是否更换后端地址后重试?[1/0] > " res + if [ "$res" = '1' ]; then + sed -i '/server_link=*/'d $ccfg + if [ "$server_link" = '7' ]; then + server_link=0 + fi + server_link=$(($server_link + 1)) + #echo $server_link + sed -i "1i\server_link=$server_link" $ccfg + getyaml + fi + exit; fi - server_link=$(($server_link + 1)) - #echo $server_link - sed -i "1i\server_link=$server_link" $ccfg - getyaml - fi -exit; else - if cat $yamlnew | grep ', server:' >/dev/null;then - #替换文件 - mv $yaml $yaml.bak - mv $yamlnew $yaml - echo 配置文件已生成!正在重启clash使其生效! - #重启clash服务 - /etc/init.d/clash restart - sleep 1 - status=`ps |grep -w 'clash -d'|grep -v grep|wc -l` + if cat $yamlnew | grep ', server:' >/dev/null;then + #替换文件 + mv $yaml $yaml.bak + mv $yamlnew $yaml + echo 配置文件已生成!正在重启clash使其生效! + #重启clash服务 + /etc/init.d/clash restart + sleep 1 + status=`ps |grep -w 'clash -d'|grep -v grep|wc -l` if [[ $status -gt 0 ]];then - echo ----------------------------------------------- - echo -e "\033[32mclash服务已启动!\033[0m" - echo -e "可以使用\033[30;47m http://clash.razord.top \033[0m管理clash内置规则" - host=$(ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';) - echo -e "Host地址:\033[30;46m $host \033[0m;端口:\033[30;46m 9999 \033[0m" - #将用户链接写入mark - sed -i '/Https=*/'d $ccfg - sed -i "7i\Https=\'$Https\'" $ccfg - clashsh + echo ----------------------------------------------- + echo -e "\033[32mclash服务已启动!\033[0m" + echo -e "可以使用\033[30;47m http://clash.razord.top \033[0m管理clash内置规则" + host=$(ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';) + echo -e "Host地址:\033[30;46m $host \033[0m;端口:\033[30;46m 9999 \033[0m" + #将用户链接写入mark + sed -i '/Https=*/'d $ccfg + sed -i "7i\Https=\'$Https\'" $ccfg + clashsh else - echo ----------------------------------------------- + echo ----------------------------------------------- if [ -f $yaml.bak ];then - echo -e "\033[31mclash服务启动失败!已还原配置文件并重启clash!\033[0m" - mv $yaml.bak $yaml - /etc/init.d/clash start - clashsh + echo -e "\033[31mclash服务启动失败!已还原配置文件并重启clash!\033[0m" + mv $yaml.bak $yaml + /etc/init.d/clash start + clashsh else - echo -e "\033[31mclash服务启动失败!请利用测试菜单排查问题!\033[0m" - clashsh + echo -e "\033[31mclash服务启动失败!请利用测试菜单排查问题!\033[0m" + clashsh fi fi - else - echo ----------------------------------------------- - echo -e "\033[33m获取到了配置文件,但格式似乎不对!\033[0m" - echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - sed -n '1,20p' $yamlnew - echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - echo -e "\033[33m请检查如上配置文件信息:\033[0m" - echo ----------------------------------------------- - fi - exit; + else + echo ----------------------------------------------- + echo -e "\033[33m获取到了配置文件,但格式似乎不对!\033[0m" + echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + sed -n '1,20p' $yamlnew + echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + echo -e "\033[33m请检查如上配置文件信息:\033[0m" + echo ----------------------------------------------- + fi + exit; fi exit } @@ -181,31 +186,31 @@ echo -e "\033[31m注意如节点使用了chacha20加密协议,需将核心更 echo -e "\033[33m0 返回上级目录!\033[0m" echo ----------------------------------------------- read -p "请输入完整链接 > " Https - test=$(echo $Https | grep "://") - Https=`echo ${Https/\ \(*\)/''}` #删除恶心的超链接内容 - Https=`echo ${Https//\&/\%26}` #将分隔符 & 替换成Httpscode:%26 - if [ -n $Https ];then - if [ -n $test ];then - echo ----------------------------------------------- - echo -e 请检查输入的链接是否正确: - echo -e "\033[4m$Https\033[0m" - read -p "确认导入配置文件?原配置文件将被更名为config.yaml.bak![1/0] > " res - if [ "$res" = '1' ]; then - #将用户链接写入mark - sed -i '/Url=*/'d $ccfg - sed -i '/Https=*/'d $ccfg - sed -i "6i\Https=\'$Https\'" $ccfg - #获取在线yaml文件 - getyaml - fi + test=$(echo $Https | grep "://") + Https=`echo ${Https/\ \(*\)/''}` #删除恶心的超链接内容 + #Https=`echo ${Https//\&/\%26}` #将分隔符 & 替换成Httpscode:%26 + if [ -n $Https ];then + if [ -n $test ];then + echo ----------------------------------------------- + echo -e 请检查输入的链接是否正确: + echo -e "\033[4m$Https\033[0m" + read -p "确认导入配置文件?原配置文件将被更名为config.yaml.bak![1/0] > " res + if [ "$res" = '1' ]; then + #将用户链接写入mark + sed -i '/Url=*/'d $ccfg + sed -i '/Https=*/'d $ccfg + sed -i "6i\Https=\'$Https\'" $ccfg + #获取在线yaml文件 + getyaml + fi + clashlink + fi + elif [[ $Https == 0 ]];then clashlink - fi - elif [[ $Https == 0 ]];then - clashlink - else - echo ----------------------------------------------- - echo -e "\033[31m请输入正确的链接地址!!!\033[0m" - fi + else + echo ----------------------------------------------- + echo -e "\033[31m请输入正确的链接地址!!!\033[0m" + fi } getsh(){ echo ----------------------------------------------- @@ -263,7 +268,7 @@ else fi fi -cpucore=armv5 +cpucore=armv7 echo ----------------------------------------------- echo -e "当前clash核心:\033[47;30m $clashcore \033[46;30m$version\033[0m" echo -e "\033[32m请选择需要下载的核心版本!\033[0m" @@ -306,21 +311,21 @@ echo -e "-----------------------------------------------\033[0m" #获取在线clash核心文件 result=$(curl -w %{http_code} -kLo /tmp/clash.new $corelink) if [ "$result" != "200" ];then - echo ----------------------------------------------- - echo -e "\033[31m核心文件下载失败!\033[0m" - echo ----------------------------------------------- - getcore + echo ----------------------------------------------- + echo -e "\033[31m核心文件下载失败!\033[0m" + echo ----------------------------------------------- + getcore else - echo -e "\033[32m$clashcore核心下载成功,正在替换!\033[0m" - mv /tmp/clash.new $clashdir/clash - chmod 777 $clashdir/clash #授予权限 - sed -i '/clashcore*/'d $ccfg - sed -i "1i\clashcore=$clashcore" $ccfg - #sed -i '/version*/'d $ccfg - #sed -i "1i\version=$version" $ccfg - echo ----------------------------------------------- - echo -e "\033[32m$clashcore核心替换成功,请手动启动clash服务!\033[0m" - clashsh + echo -e "\033[32m$clashcore核心下载成功,正在替换!\033[0m" + mv /tmp/clash.new $clashdir/clash + chmod 777 $clashdir/clash #授予权限 + sed -i '/clashcore*/'d $ccfg + sed -i "1i\clashcore=$clashcore" $ccfg + #sed -i '/version*/'d $ccfg + #sed -i "1i\version=$version" $ccfg + echo ----------------------------------------------- + echo -e "\033[32m$clashcore核心替换成功,请手动启动clash服务!\033[0m" + clashsh fi }