v1.7.5b
~优化:fake-ip模式下的常用端口过滤不再包含域名类规则 ~修复了部分情况下不显示启动报错的bug
This commit is contained in:
@@ -1276,7 +1276,9 @@ clashcfg(){
|
|||||||
set_common_ports(){
|
set_common_ports(){
|
||||||
if [ "$common_ports" = "未开启" ]; then
|
if [ "$common_ports" = "未开启" ]; then
|
||||||
echo -e "\033[33m已设为仅代理【$multiport】等常用端口!!\033[0m"
|
echo -e "\033[33m已设为仅代理【$multiport】等常用端口!!\033[0m"
|
||||||
|
echo -e "\033[31m注意,fake-ip模式下,非常用端口的域名连接将不受影响!!\033[0m"
|
||||||
common_ports=已开启
|
common_ports=已开启
|
||||||
|
sleep 1
|
||||||
else
|
else
|
||||||
echo -e "\033[33m已设为代理全部端口!!\033[0m"
|
echo -e "\033[33m已设为代理全部端口!!\033[0m"
|
||||||
common_ports=未开启
|
common_ports=未开启
|
||||||
|
|||||||
@@ -447,12 +447,12 @@ setcustcore(){
|
|||||||
case "$num" in
|
case "$num" in
|
||||||
1)
|
1)
|
||||||
clashcore=clashpre
|
clashcore=clashpre
|
||||||
custcorelink=https://gh.shellclash.workers.dev/https://github.com/juewuy/ShellClash/releases/download/clash.premium.latest/clash-linux-$cpucore
|
custcorelink=https://github.com/juewuy/ShellClash/releases/download/clash.premium.latest/clash-linux-$cpucore
|
||||||
getcore
|
getcore
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
clashcore=clash.meta
|
clashcore=clash.meta
|
||||||
custcorelink=https://gh.shellclash.workers.dev/https://github.com/juewuy/ShellClash/releases/download/clash.meta.alpha/clash-linux-$cpucore
|
custcorelink=https://github.com/juewuy/ShellClash/releases/download/clash.meta.alpha/clash-linux-$cpucore
|
||||||
getcore
|
getcore
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
|
|||||||
@@ -409,7 +409,7 @@ EOF
|
|||||||
#测试自定义配置文件
|
#测试自定义配置文件
|
||||||
$bindir/clash -t -d $bindir -f $tmpdir/config.yaml >/dev/null
|
$bindir/clash -t -d $bindir -f $tmpdir/config.yaml >/dev/null
|
||||||
if [ "$?" != 0 ];then
|
if [ "$?" != 0 ];then
|
||||||
logger "$($bindir/clash -t -d $bindir -f $tmpdir/config.yaml | grep -Eo 'error=.*')" 31
|
logger "$($bindir/clash -t -d $bindir -f $tmpdir/config.yaml | grep -Eo 'error.*=.*')" 31
|
||||||
logger "自定义配置文件校验失败!将使用基础配置文件启动!" 33
|
logger "自定义配置文件校验失败!将使用基础配置文件启动!" 33
|
||||||
sed -i "/#自定义/d" $tmpdir/config.yaml
|
sed -i "/#自定义/d" $tmpdir/config.yaml
|
||||||
fi
|
fi
|
||||||
@@ -517,6 +517,7 @@ start_redir(){
|
|||||||
fi
|
fi
|
||||||
#将PREROUTING链指向clash链
|
#将PREROUTING链指向clash链
|
||||||
iptables -t nat -A PREROUTING -p tcp $ports -j clash
|
iptables -t nat -A PREROUTING -p tcp $ports -j clash
|
||||||
|
[ "$dns_mod" = "fake-ip" -a "$common_ports" = "已开启" ] && iptables -t nat -A PREROUTING -p tcp -d 198.18.0.0/16 -j clash
|
||||||
#设置ipv6转发
|
#设置ipv6转发
|
||||||
if [ "$ipv6_redir" = "已开启" -a -n "$(lsmod | grep 'ip6table_nat')" ];then
|
if [ "$ipv6_redir" = "已开启" -a -n "$(lsmod | grep 'ip6table_nat')" ];then
|
||||||
ip6tables -t nat -N clashv6
|
ip6tables -t nat -N clashv6
|
||||||
@@ -612,6 +613,7 @@ start_tproxy(){
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
iptables -t mangle -A PREROUTING -p $1 $ports -j clash
|
iptables -t mangle -A PREROUTING -p $1 $ports -j clash
|
||||||
|
[ "$dns_mod" = "fake-ip" -a "$common_ports" = "已开启" ] && iptables -t mangle -A PREROUTING -p $1 -d 198.18.0.0/16 -j clash
|
||||||
}
|
}
|
||||||
[ "$1" = "all" ] && tproxy_set tcp
|
[ "$1" = "all" ] && tproxy_set tcp
|
||||||
tproxy_set udp
|
tproxy_set udp
|
||||||
@@ -807,7 +809,7 @@ start_nft(){
|
|||||||
[ -n "$CN_IP" ] && nft add rule inet shellclash prerouting ip daddr {$CN_IP} return
|
[ -n "$CN_IP" ] && nft add rule inet shellclash prerouting ip daddr {$CN_IP} return
|
||||||
}
|
}
|
||||||
#过滤常用端口
|
#过滤常用端口
|
||||||
[ -n "$PORTS" ] && nft add rule inet shellclash prerouting tcp dport != {$PORTS} return
|
[ -n "$PORTS" ] && nft add rule inet shellclash prerouting tcp dport != {$PORTS} ip daddr != {198.18.0.0/16} return
|
||||||
#ipv6支持
|
#ipv6支持
|
||||||
if [ "$ipv6_redir" = "已开启" ];then
|
if [ "$ipv6_redir" = "已开启" ];then
|
||||||
RESERVED_IP6="$(echo "$reserve_ipv6 $host_ipv6" | sed 's/ /, /g')"
|
RESERVED_IP6="$(echo "$reserve_ipv6 $host_ipv6" | sed 's/ /, /g')"
|
||||||
@@ -903,6 +905,7 @@ stop_firewall(){
|
|||||||
ckcmd iptables && {
|
ckcmd iptables && {
|
||||||
#redir
|
#redir
|
||||||
iptables -t nat -D PREROUTING -p tcp $ports -j clash 2> /dev/null
|
iptables -t nat -D PREROUTING -p tcp $ports -j clash 2> /dev/null
|
||||||
|
iptables -t nat -D PREROUTING -p tcp -d 198.18.0.0/16 -j clash 2> /dev/null
|
||||||
iptables -t nat -F clash 2> /dev/null
|
iptables -t nat -F clash 2> /dev/null
|
||||||
iptables -t nat -X clash 2> /dev/null
|
iptables -t nat -X clash 2> /dev/null
|
||||||
#dns
|
#dns
|
||||||
@@ -931,6 +934,8 @@ stop_firewall(){
|
|||||||
#TPROXY&tun
|
#TPROXY&tun
|
||||||
iptables -t mangle -D PREROUTING -p tcp $ports -j clash 2> /dev/null
|
iptables -t mangle -D PREROUTING -p tcp $ports -j clash 2> /dev/null
|
||||||
iptables -t mangle -D PREROUTING -p udp $ports -j clash 2> /dev/null
|
iptables -t mangle -D PREROUTING -p udp $ports -j clash 2> /dev/null
|
||||||
|
iptables -t mangle -D PREROUTING -p tcp -d 198.18.0.0/16 -j clash 2> /dev/null
|
||||||
|
iptables -t mangle -D PREROUTING -p udp -d 198.18.0.0/16 -j clash 2> /dev/null
|
||||||
iptables -t mangle -F clash 2> /dev/null
|
iptables -t mangle -F clash 2> /dev/null
|
||||||
iptables -t mangle -X clash 2> /dev/null
|
iptables -t mangle -X clash 2> /dev/null
|
||||||
#公网访问
|
#公网访问
|
||||||
@@ -1252,7 +1257,7 @@ afstart(){
|
|||||||
{ sleep 30;logger Clash服务已启动!;} &
|
{ sleep 30;logger Clash服务已启动!;} &
|
||||||
else
|
else
|
||||||
logger "Clash服务启动失败!请查看报错信息!" 33
|
logger "Clash服务启动失败!请查看报错信息!" 33
|
||||||
logger "$($bindir/clash -t -d $bindir | grep -Eo 'error=.*')" 31
|
logger "$($bindir/clash -t -d $bindir | grep -Eo 'error.*=.*')" 31
|
||||||
$0 stop
|
$0 stop
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user