~Tun网卡Redir-host支持
~日志推送适配PashDeer
~ipv6出口屏蔽本机WAN网卡
This commit is contained in:
juewuy
2022-12-09 22:40:11 +08:00
parent cc38eeeb47
commit a6f60e64a8
3 changed files with 54 additions and 6 deletions

View File

@@ -135,13 +135,15 @@ checkrestart(){
#功能相关
log_pusher(){
[ -n "$push_TG" ] && stat_TG=32m已启用 || stat_TG=33m未启用
[ -n "$push_Deer" ] && stat_Deer=32m已启用 || stat_Deer=33m未启用
[ -n "$push_bark" ] && stat_bark=32m已启用 || stat_bark=33m未启用
[ -n "$push_Po" ] && stat_Po=32m已启用 || stat_Po=33m未启用
echo -----------------------------------------------
echo -e " 1 查看\033[36m运行日志\033[0m"
echo -e " 2 Telegram推送 ——\033[$stat_TG\033[0m"
echo -e " 3 Bark推送-IOS ——\033[$stat_bark\033[0m"
echo -e " 4 Passover推送 ——\033[$stat_Po\033[0m"
echo -e " 3 PushDeer推送 ——\033[$stat_Deer\033[0m"
echo -e " 4 Bark推送-IOS ——\033[$stat_bark\033[0m"
echo -e " 5 Passover推送 ——\033[$stat_Po\033[0m"
echo -----------------------------------------------
read -p "请输入对应数字 > " num
case $num in
@@ -193,6 +195,33 @@ log_pusher(){
log_pusher
;;
3)
echo -----------------------------------------------
if [ -n "$push_Deer" ];then
read -p "确认关闭PushDeer日志推送(1/0) > " res
[ "$res" = 1 ] && {
push_Deer=
setconfig push_Deer
}
else
#echo -e "\033[33m详细设置指南请参考 https://juewuy.github.io/ \033[0m"
echo -e "请先前往 \033[32;4mhttp://www.pushdeer.com/official.html\033[0m 扫码安装快应用或下载APP"
echo -e "打开快应用/APP并完成登陆"
echo -e "\033[33m切换到「设备」标签页点击右上角的加号注册当前设备\033[0m"
echo -e "\033[36m切换到「秘钥」标签页点击右上角的加号创建一个秘钥并复制\033[0m"
echo -----------------------------------------------
read -p "请输入你复制的秘钥 > " url
if [ -n "$url" ];then
push_Deer=$url
setconfig push_Deer $url
$clashdir/start.sh logger "已完成PushDeer日志推送设置" 32
else
echo -e "\033[31m输入错误请重新输入\033[0m"
fi
sleep 1
fi
log_pusher
;;
4)
echo -----------------------------------------------
if [ -n "$push_bark" ];then
read -p "确认关闭Bark日志推送(1/0) > " res
@@ -217,7 +246,7 @@ log_pusher(){
fi
log_pusher
;;
4)
5)
echo -----------------------------------------------
if [ -n "$push_Po" ];then
read -p "确认关闭Pushover日志推送(1/0) > " res

View File

@@ -256,10 +256,16 @@ clashlink(){
elif [ "$num" = 2 ];then
echo -----------------------------------------------
echo -e "\033[33m此功能可能会导致严重bug仅限熟练了解clash运行机制的用户使用\033[0m"
echo -e "如你不熟悉clash机制或者使用此功能出现bug请使用\033[32m在线生成配置文件功能\033[0m"
echo -e "\033[33m此功能可能会导致严重bug\033[0m"
sleep 1
echo -----------------------------------------------
read -p "是否继续?[1/0] > " res
echo -e "强烈建议你使用\033[32m在线生成配置文件功能\033[0m"
sleep 1
echo -----------------------------------------------
echo -e "\033[33m继续后如出现任何问题请务必自行解决一切提问恕不受理\033[0m"
echo -----------------------------------------------
sleep 2
read -p "我确认遇到问题可以自行解决[1/0] > " res
if [ "$res" = '1' ]; then
getlink2
else

View File

@@ -74,6 +74,14 @@ logger(){
wget -Y on -q --timeout=3 -t 1 "$url"
fi
}
[ -n "$push_Deer" ] && {
url=https://api2.pushdeer.com/message/push?pushkey=${push_Deer}
if curl --version &> /dev/null;then
curl -kfsSl --connect-timeout 3 "$url"\&text="$log_text" &>/dev/null
else
wget -Y on -q --timeout=3 -t 1 "$url"\&text="$log_text"
fi
}
[ -n "$push_Po" ] && {
url=https://api.pushover.net/1/messages.json
curl -kfsSl --connect-timeout 3 --form-string "token=$push_Po" --form-string "user=$push_Po_key" --form-string "message=$log_text" "$url" &>/dev/null
@@ -474,6 +482,7 @@ start_redir(){
iptables -t nat -A PREROUTING -p tcp $ports -j clash
#设置ipv6转发
if [ "$ipv6_redir" = "已开启" -a -n "$(lsmod | grep 'ip6table_nat')" ];then
ip6tables -t nat -N clashv6
ip6tables -t nat -A clashv6 -d ::1/128 -j RETURN
ip6tables -t nat -A clashv6 -d fc00::/7 -j RETURN
@@ -488,6 +497,7 @@ start_redir(){
for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clashv6 -m mac --mac-source $mac -j RETURN
done
[ -n "$wan_mac" ] && ip6tables -t nat -A clashv6 -m mac --mac-source $wan_mac -j RETURN #屏蔽本机出口网卡
ip6tables -t nat -A clashv6 -p tcp $ports -j REDIRECT --to-ports $redir_port
fi
ip6tables -t nat -A PREROUTING -p tcp -j clashv6
@@ -602,6 +612,7 @@ start_tproxy(){
for mac in $(cat $clashdir/mac); do
ip6tables -t mangle -A clashv6 -m mac --mac-source $mac -j RETURN
done
[ -n "$wan_mac" ] && ip6tables -t mangle -A clashv6 -m mac --mac-source $wan_mac -j RETURN #屏蔽本机出口网卡
ip6tables -t mangle -A clashv6 -p $1 -j TPROXY --on-port $tproxy_port --tproxy-mark 1
fi
ip6tables -t mangle -A PREROUTING -p $1 $ports -j clashv6
@@ -765,6 +776,7 @@ start_nft(){
ip -6 rule add fwmark 1 table 101 2> /dev/null
ip -6 route add local ::/0 dev lo table 101 2> /dev/null
nft add rule inet shellclash prerouting ip6 daddr {${RESERVED_IP6}} return
[ -n "$wan_mac" ] && nft add rule inet shellclash prerouting ether saddr {${wan_mac}} return #屏蔽本机出口网卡
else
nft add rule inet shellclash prerouting meta nfproto ipv6 return
fi
@@ -1130,6 +1142,7 @@ afstart(){
fi
}
#设置路由规则
wan_mac=$(ifconfig wan | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}')
[ "$redir_mod" = "Redir模式" ] && start_dns && start_redir
[ "$redir_mod" = "混合模式" ] && start_dns && start_redir && start_tun udp
[ "$redir_mod" = "Tproxy混合" ] && start_dns && start_redir && start_tproxy udp