~适配更多华硕设备(待测试)
~增加Openwrt系统使用Dnsmasq转发DNS的设置(7-6,未测试)
~替换部分在线生成服务器地址
~部分内容文字描述调整
This commit is contained in:
juewuy
2021-12-18 20:14:03 +08:00
parent 8b241be6c1
commit b315dee718
4 changed files with 45 additions and 16 deletions

View File

@@ -11,6 +11,7 @@ echo "** by Juewuy **"
echo "***********************************************"
[ -f "/etc/storage/started_script.sh" ] && systype=Padavan && initdir='/etc/storage/started_script.sh'
[ -d "/jffs/" ] && systype=asusrouter && initdir='/jffs/init-start'
[ -f "/jffs/.asusrouter" ] && systype=asusrouter && initdir='/jffs/.asusrouter'
#检查root权限
if [ "$USER" != "root" -a -z "$systype" ];then

View File

@@ -139,11 +139,11 @@ setport(){
[ -z "$secret" ] && secret=未设置
[ -z "$authentication" ] && authentication=未设置
inputport(){
read -p "请输入端口号(1000-65535) > " portx
read -p "请输入端口号(1-65535) > " portx
if [ -z "$portx" ]; then
setport
elif [ $portx -gt 65535 -o $portx -le 999 ]; then
echo -e "\033[31m输入错误请输入正确的数值(1000-65535)\033[0m"
elif [ $portx -gt 65535 -o $portx -le 1 ]; then
echo -e "\033[31m输入错误请输入正确的数值(1-65535)\033[0m"
inputport
elif [ -n "$(echo $mix_port$redir_port$dns_port$db_port|grep $portx)" ]; then
echo -e "\033[31m输入错误请不要输入重复的端口\033[0m"
@@ -270,6 +270,7 @@ setdns(){
echo -e " 3 \033[33m重置\033[0mDNS配置"
echo -e " 4 禁用内置DNS(慎用)"
echo -e " 5 使用\033[32m加密DNS\033[0m"
echo -e " 6 使用\033[32mdnsmasq转发DNS\033[0m"
echo -e " 0 返回上级菜单"
echo -----------------------------------------------
read -p "请输入对应数字 > " num
@@ -326,11 +327,19 @@ setdns(){
rm -rf /tmp/ssl_test
sleep 1
setdns
elif [ "$num" = 6 ]; then
echo -----------------------------------------------
echo -e "\033[31m将使用OpenWrt中Dnsmasq插件自带的DNS转发功能转发DNS请求至clash内核\033[0m"
echo -e "\033[32m启用后将禁用本插件自带的iptables转发功能\033[0m"
dns_redir=已开启
setconfig dns_redir $dns_redir
echo -e "\033[33m已启用Dnsmasq转发DNS功能\033[0m"
setdns
fi
}
checkport(){
for portx in $dns_port $mix_port $redir_port $db_port ;do
if [ -n "$(netstat -ntul 2>&1 |grep :$portx)" ];then
if [ -n "$(netstat -ntul 2>&1 |grep \:$portx\ )" ];then
echo -----------------------------------------------
echo -e "检测到端口【$portx】被以下进程占用clash可能无法正常启动\033[33m"
echo $(netstat -ntulp | grep :$portx | head -n 1)
@@ -1320,6 +1329,10 @@ case "$1" in
echo " -h 帮助列表"
echo " -u 卸载脚本"
echo -----------------------------------------
echo " $clashdir/start.sh start 启动服务"
echo " $clashdir/start.sh stop 停止服务"
echo " $clashdir/start.sh init 写入服务"
echo -----------------------------------------
echo "在线求助t.me/clashfm"
echo "官方博客juewuy.github.io"
echo "发布页面github.com/juewuy/ShellClash"

View File

@@ -503,9 +503,9 @@ setgeo(){
[ -n "$geo_type" ] && echo -e "当前使用的是\033[47;30m$geo_type数据库\033[0m"
echo -e "\033[36m请选择需要更新/切换的GeoIP/CN_IP数据库\033[0m"
echo -----------------------------------------------
echo -e " 1 由\033[32malecthw\033[0m提供的全球版GeoIP数据库(约4mb)"
echo -e " 2 由\033[32mHackl0us\033[0m提供的精简版CN-IP数据库(约0.1mb)"
echo -e " 3 由\033[32m17mon\033[0m提供的CN-IP文件(需启用CN_IP绕过内核功能约0.1mb)"
echo -e " 1 由\033[32malecthw\033[0m提供的全球版GeoIP数据库(约6mb)"
echo -e " 2 由\033[32mHackl0us\033[0m提供的精简版CN-IP数据库(约0.2mb)"
echo -e " 3 由\033[32m17mon\033[0m提供的CN-IP文件(需启用CN_IP绕过内核功能约0.2mb)"
echo " 0 返回上级菜单"
echo -----------------------------------------------
read -p "请输入对应数字 > " num

View File

@@ -26,6 +26,7 @@ getconfig(){
[ -z "$redir_port" ] && redir_port=7892
[ -z "$db_port" ] && db_port=9999
[ -z "$dns_port" ] && dns_port=1053
[ -z "$dns_redir" ] && dns_redir=未开启
[ -z "$cn_ip_route" ] && cn_ip_route=未开启
[ -z "$public_support" ] && public_support=未开启
[ -z "$dns_nameserver" ] && dns_nameserver='114.114.114.114, 223.5.5.5'
@@ -95,8 +96,8 @@ getyaml(){
subcon.dlj.tf
api.dler.io
api.wcc.best
api2.tsutsu.cc
api.v1.mk
sub.lpy.pw
sub.id9.cc
EOF`
Config=`sed -n ""$rule_link"p"<<EOF
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_NoReject.ini
@@ -232,7 +233,7 @@ modify_yaml(){
if [ "$dns_mod" = "fake-ip" ];then
dns='dns: {enable: true, listen: 0.0.0.0:'$dns_port', use-hosts: true, fake-ip-range: 198.18.0.1/16, enhanced-mode: fake-ip, fake-ip-filter: ["*.lan", "time.windows.com", "time.nist.gov", "time.apple.com", "time.asia.apple.com", "*.ntp.org.cn", "*.openwrt.pool.ntp.org", "time1.cloud.tencent.com", "time.ustc.edu.cn", "pool.ntp.org", "ntp.ubuntu.com", "ntp.aliyun.com", "ntp1.aliyun.com", "ntp2.aliyun.com", "ntp3.aliyun.com", "ntp4.aliyun.com", "ntp5.aliyun.com", "ntp6.aliyun.com", "ntp7.aliyun.com", "time1.aliyun.com", "time2.aliyun.com", "time3.aliyun.com", "time4.aliyun.com", "time5.aliyun.com", "time6.aliyun.com", "time7.aliyun.com", "*.time.edu.cn", "time1.apple.com", "time2.apple.com", "time3.apple.com", "time4.apple.com", "time5.apple.com", "time6.apple.com", "time7.apple.com", "time1.google.com", "time2.google.com", "time3.google.com", "time4.google.com", "music.163.com", "*.music.163.com", "*.126.net", "musicapi.taihe.com", "music.taihe.com", "songsearch.kugou.com", "trackercdn.kugou.com", "*.kuwo.cn", "api-jooxtt.sanook.com", "api.joox.com", "joox.com", "y.qq.com", "*.y.qq.com", "streamoc.music.tc.qq.com", "mobileoc.music.tc.qq.com", "isure.stream.qqmusic.qq.com", "dl.stream.qqmusic.qq.com", "aqqmusic.tc.qq.com", "amobile.music.tc.qq.com", "*.xiami.com", "*.music.migu.cn", "music.migu.cn", "*.msftconnecttest.com", "*.msftncsi.com", "localhost.ptlogin2.qq.com", "*.*.*.srv.nintendo.net", "*.*.stun.playstation.net", "xbox.*.*.microsoft.com", "*.*.xboxlive.com", "proxy.golang.org","*.sgcc.com.cn","*.alicdn.com","*.aliyuncs.com"], nameserver: ['$dns_nameserver', 127.0.0.1:53], fallback: ['$dns_fallback'], fallback-filter: {geoip: true}}'
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}}'
dns='dns: {enable: true, '$ipv6', 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
@@ -309,6 +310,11 @@ cn_ip_route(){
fi
}
start_redir(){
#允许tun网卡接受流量
if [ "$redir_mod" = "Tun模式" -o "$redir_mod" = "混合模式" ];then
iptables -I FORWARD -o utun -j ACCEPT
[ "$ipv6_support" = "已开启" ] && ip6tables -I FORWARD -o utun -j ACCEPT > /dev/null 2>&1
fi
#获取本地局域网地址段
gethost
#流量过滤规则
@@ -364,11 +370,6 @@ start_redir(){
fi
}
start_dns(){
#允许tun网卡接受流量
if [ "$redir_mod" = "Tun模式" -o "$redir_mod" = "混合模式" ];then
iptables -I FORWARD -o utun -j ACCEPT
[ "$ipv6_support" = "已开启" ] && ip6tables -I FORWARD -o utun -j ACCEPT > /dev/null 2>&1
fi
#设置dns转发
iptables -t nat -N clash_dns
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
@@ -521,6 +522,10 @@ stop_iptables(){
ip6tables -D FORWARD -o utun -j ACCEPT 2> /dev/null
#清理ipset规则
ipset destroy cn_ip >/dev/null 2>&1
#移除dnsmasq转发规则
uci del dhcp.@dnsmasq[-1].server >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].cachesize >/dev/null 2>&1
/etc/init.d/dnsmasq restart >/dev/null 2>&1
}
#面板配置保存相关
web_save(){
@@ -677,7 +682,17 @@ afstart(){
if [ "$?" = 0 ];then
#设置iptables转发规则
[ "$dns_mod" = "redir_host" ] && [ "$cn_ip_route" = "已开启" ] && cn_ip_route
[ "$redir_mod" != "纯净模式" ] && [ "$dns_no" != "已禁用" ] && start_dns
if [ "$redir_mod" != "纯净模式" ] && [ "$dns_no" != "已禁用" ];then
if [ "$dns_redir" != "已开启" ];then
start_dns
else
#openwrt使用dnsmasq转发
uci del dhcp.@dnsmasq[-1].server >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].resolvfile 2>/dev/null
uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#$dns_port > /dev/null 2>&1
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi
fi
[ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir
[ "$redir_mod" = "Redir模式" ] && [ "$tproxy_mod" = "已开启" ] && start_udp
[ "$local_proxy" = "已开启" ] && [ "$local_type" = "iptables增强模式" ] && start_output