mirror of
https://github.com/juewuy/ShellCrash.git
synced 2024-11-16 03:32:34 +08:00
v1.0.0beta16.7
~增加tproxy——udp模式对黑白名单mac过滤的适配 ~优化导入自定义配置文件功能 ~修复ip6tables在不可用时仍旧强行使用导致报错的bug ~修复ipv6dns导致污染的bug
This commit is contained in:
parent
d0ecb222ab
commit
6957d57f1f
|
@ -670,6 +670,7 @@ clashadv(){
|
|||
echo -e " 4 启用小闪存模式: \033[36m$mini_clash\033[0m ————启动时方下载核心及数据库文件"
|
||||
echo -e " 5 配置内置DNS服务: \033[36m$dns_no\033[0m"
|
||||
echo -e " 6 手动指定clash运行端口及秘钥"
|
||||
echo -e " 7 使用自定义配置"
|
||||
echo -----------------------------------------------
|
||||
echo -e " 8 \033[31m重置\033[0m配置文件"
|
||||
echo -e " 9 \033[32m重启\033[0mclash服务"
|
||||
|
@ -770,7 +771,34 @@ clashadv(){
|
|||
elif [ "$num" = 6 ]; then
|
||||
setport
|
||||
clashadv
|
||||
|
||||
|
||||
elif [ "$num" = 7 ]; then
|
||||
[ ! -f $clashdir/user.yaml ] && cat > $clashdir/user.yaml <<EOF
|
||||
#用于编写自定义设定(可参考https://lancellc.gitbook.io/clash),例如
|
||||
#port: 7890
|
||||
#hosts:
|
||||
# '*.clash.dev': 127.0.0.1
|
||||
# 'alpha.clash.dev': ::1
|
||||
EOF
|
||||
[ ! -f $clashdir/rules.yaml ] && cat > $clashdir/rules.yaml <<EOF
|
||||
#用于编写自定义规则(此处规则将优先生效),(可参考https://lancellc.gitbook.io/clash/clash-config-file/rules):
|
||||
#例如“🚀 节点选择”、“🎯 全球直连”这样的自定义规则组必须与config.yaml中的代理规则组相匹配,否则将无法运行!
|
||||
# - DOMAIN-SUFFIX,google.com,🚀 节点选择
|
||||
# - DOMAIN-KEYWORD,baidu,🎯 全球直连
|
||||
# - DOMAIN,ad.com,REJECT
|
||||
# - SRC-IP-CIDR,192.168.1.201/32,DIRECT
|
||||
# - IP-CIDR,127.0.0.0/8,DIRECT
|
||||
# - IP-CIDR6,2620:0:2d0:200::7/32,🚀 节点选择
|
||||
# - DST-PORT,80,DIRECT
|
||||
# - SRC-PORT,7777,DIRECT
|
||||
EOF
|
||||
echo -e "\033[32m已经启用自定义配置功能!\033[0m"
|
||||
echo -e "Shell下(部分旧设备可能不显示中文)可\n使用【\033[36mvi $clashdir/user.yaml\033[0m】编辑自定义设定文件;\n使用【\033[36mvi $clashdir/rules.yaml\033[0m】编辑自定义规则文件。"
|
||||
echo -e "Windows下请\n使用\033[33mwinscp软件\033[0m进入$clashdir目录后手动编辑!\033[0m"
|
||||
echo -e "其他设备请\n使用\033[32mscp命令\033[0m下载文件编辑后上传到$clashdir目录!\033[0m"
|
||||
sleep 3
|
||||
clashadv
|
||||
|
||||
elif [ "$num" = 8 ]; then
|
||||
read -p "确认重置配置文件?(1/0) > " res
|
||||
if [ "$res" = "1" ];then
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#用于编写自定义规则(此处规则将优先生效),(可参考https://lancellc.gitbook.io/clash/clash-config-file/rules):
|
||||
#例如“🚀 节点选择”、“🎯 全球直连”这样的自定义规则组必须与config.yaml中的代理规则组相匹配,否则将无法运行!
|
||||
# - DOMAIN-SUFFIX,google.com,🚀 节点选择
|
||||
# - DOMAIN-KEYWORD,baidu,🎯 全球直连
|
||||
# - DOMAIN,ad.com,REJECT
|
||||
# - SRC-IP-CIDR,192.168.1.201/32,DIRECT
|
||||
# - IP-CIDR,127.0.0.0/8,DIRECT
|
||||
# - IP-CIDR6,2620:0:2d0:200::7/32,🚀 节点选择
|
||||
# - DST-PORT,80,DIRECT
|
||||
# - SRC-PORT,7777,DIRECT
|
||||
|
|
@ -208,7 +208,6 @@ modify_yaml(){
|
|||
else
|
||||
dns='dns: {enable: true, ipv6: true, listen: 0.0.0.0:'$dns_port', use-hosts: true, enhanced-mode: redir-host, nameserver: ['$dns_nameserver$dns_local'], fallback: ['$dns_fallback'], fallback-filter: {geoip: true}}'
|
||||
fi
|
||||
###################################
|
||||
#设置目录
|
||||
yaml=$clashdir/config.yaml
|
||||
tmpdir=/tmp/clash_$USER
|
||||
|
@ -221,6 +220,7 @@ modify_yaml(){
|
|||
#跳过本地tls证书验证
|
||||
[ "$skip_cert" = "已开启" ] && sed -i '10,99s/skip-cert-verify: false/skip-cert-verify: true/' $tmpdir/proxy.yaml
|
||||
#添加配置
|
||||
###################################
|
||||
cat > $tmpdir/set.yaml <<EOF
|
||||
mixed-port: $mix_port
|
||||
redir-port: $redir_port
|
||||
|
@ -236,6 +236,7 @@ $tun
|
|||
$exper
|
||||
$dns
|
||||
EOF
|
||||
###################################
|
||||
[ -f $clashdir/user.yaml ] && yaml_user=$clashdir/user.yaml
|
||||
#合并文件
|
||||
sed -i "/^prox/i" $tmpdir/proxy.yaml #防止缺少换行符导致的报错
|
||||
|
@ -243,7 +244,7 @@ EOF
|
|||
#插入自定义规则
|
||||
if [ -f $clashdir/rules.yaml ];then
|
||||
while read line;do
|
||||
sed -i "/^rules:/a\ $line" $tmpdir/config.yaml
|
||||
[ -z "$(echo "$line" | grep '#')" ] && [ -n "$(echo "$line" | grep '\-\ ')" ] && sed -i "/^rules:/a\ $line" $tmpdir/config.yaml
|
||||
done < $clashdir/rules.yaml
|
||||
fi
|
||||
#如果没有使用小闪存模式
|
||||
|
@ -281,8 +282,8 @@ start_redir(){
|
|||
#转发设置
|
||||
iptables -t nat -A PREROUTING -p tcp -j clash
|
||||
#设置ipv6转发
|
||||
ip6_nat=$(ip6tables -t nat -L 2>&1|grep -o 'Chain')
|
||||
if [ -n "ip6_nat" -a "$ipv6_support" = "已开启" ];then
|
||||
ip6_nat=$(ip6tables -t nat -L 2>&1 | grep -o 'Chain')
|
||||
if [ -n "$ip6_nat" -a "$ipv6_support" = "已开启" ];then
|
||||
ip6tables -t nat -N clashv6
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
|
@ -326,8 +327,8 @@ start_dns(){
|
|||
iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j clash_dns
|
||||
iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j clash_dns
|
||||
#ipv6DNS
|
||||
ip6_nat=$(ip6tables -t nat -L 2>&1|grep -o 'Chain')
|
||||
if [ -n "ip6_nat" ];then
|
||||
ip6_nat=$(ip6tables -t nat -L 2>&1 | grep -o 'Chain')
|
||||
if [ -n "$ip6_nat" ];then
|
||||
ip6tables -t nat -N clashv6_dns > /dev/null 2>&1
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
|
@ -361,7 +362,18 @@ start_udp(){
|
|||
iptables -t mangle -A clash -d 192.168.0.0/16 -j RETURN
|
||||
iptables -t mangle -A clash -d 224.0.0.0/4 -j RETURN
|
||||
iptables -t mangle -A clash -d 240.0.0.0/4 -j RETURN
|
||||
iptables -t mangle -A clash -p udp -j TPROXY --on-port $redir_port --tproxy-mark 1
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t mangle -A clash -p udp -m mac --mac-source $mac -j TPROXY --on-port $redir_port --tproxy-mark 1
|
||||
done
|
||||
else
|
||||
#mac黑名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t mangle -A clash -m mac --mac-source $mac -j RETURN
|
||||
done
|
||||
iptables -t mangle -A clash -p udp -j TPROXY --on-port $redir_port --tproxy-mark 1
|
||||
fi
|
||||
iptables -t mangle -A PREROUTING -p udp -j clash
|
||||
}
|
||||
stop_iptables(){
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
#用于编写自定义设定(可参考https://lancellc.gitbook.io/clash),例如
|
||||
#port: 7890
|
||||
#hosts:
|
||||
# '*.clash.dev': 127.0.0.1
|
||||
# 'alpha.clash.dev': ::1
|
Loading…
Reference in New Issue
Block a user