diff --git a/install.sh b/install.sh index a23c295..8849776 100644 --- a/install.sh +++ b/install.sh @@ -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 diff --git a/scripts/clash.sh b/scripts/clash.sh index 9072893..c452dab 100644 --- a/scripts/clash.sh +++ b/scripts/clash.sh @@ -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" diff --git a/scripts/getdate.sh b/scripts/getdate.sh index f6ebb85..bdfb011 100644 --- a/scripts/getdate.sh +++ b/scripts/getdate.sh @@ -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 diff --git a/scripts/start.sh b/scripts/start.sh index 3cde9ef..03bccb7 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -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"< /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