From caed68b6db4986ed2dc526a15d4f47d3eb340dc4 Mon Sep 17 00:00:00 2001 From: shioeri Date: Sat, 8 Jul 2023 22:55:34 +0700 Subject: [PATCH] default use `clash.premium` minor fix --- box/clash/config.yaml | 60 +++++++++++++++++------------------ box/clash/note.txt | 4 +-- box/scripts/box.service | 11 ++++--- box/scripts/box.tool | 69 ++++++++++++++++++++--------------------- 4 files changed, 70 insertions(+), 74 deletions(-) diff --git a/box/clash/config.yaml b/box/clash/config.yaml index 28c3700..051e8f4 100755 --- a/box/clash/config.yaml +++ b/box/clash/config.yaml @@ -10,7 +10,7 @@ tproxy-port: 9898 # 此项拥有默认值,默认为规则模式 mode: rule allow-lan: true -unified-delay: true +# unified-delay: true bind-address: '*' # silent 静默,不输出 @@ -22,12 +22,12 @@ log-level: silent ipv6: false # 更改geoip使用文件,mmdb或者dat,true为dat -geodata-mode: true +# geodata-mode: true # 可选的加载模式如下 # standard:标准加载器 # memconservative:专为内存受限(小内存)设备优化的加载器(默认值) -geodata-loader: memconservative +# geodata-loader: memconservative external-controller: 0.0.0.0:9090 # secret: "123456" @@ -55,7 +55,7 @@ external-ui: /data/adb/box/clash/dashboard # always 开启,强制匹配所有进程 # strict 默认,由 Clash 判断是否开启 # off 不匹配进程,推荐在路由器上使用此模式 -find-process-mode: strict +# find-process-mode: strict profile: store-selected: true @@ -63,27 +63,27 @@ profile: store-fake-ip: false # 储存 fakeip 映射表,域名再次发生连接时,使用原有映射地址 -sniffer: #【Meta专属】sniffer域名嗅探器 - enable: false # 嗅探器开关 +# sniffer: #【Meta专属】sniffer域名嗅探器 + # enable: false # 嗅探器开关 - # 开启后对 redir-host 类型识别的流量进行强制嗅探 - # 包含 Tun、Redir 和 TProxy 或 DNS 为 redir-host - # force-dns-mapping: false - # parse-pure-ip: false # 对所有未获取到域名的流量进行强制嗅探 + # # 开启后对 redir-host 类型识别的流量进行强制嗅探 + # # 包含 Tun、Redir 和 TProxy 或 DNS 为 redir-host + # # force-dns-mapping: false + # # parse-pure-ip: false # 对所有未获取到域名的流量进行强制嗅探 - override-destination: false # 是否使用嗅探结果作为实际访问,默认 true - # 全局配置,优先级低于 sniffer.sniff 实际配置 - sniff: # TLS 默认如果不配置 ports 默认嗅探 443 - TLS: - ports: [443, 8443] - HTTP: # 需要嗅探的端口, 默认嗅探 80 - ports: [80, 8080-8880] - override-destination: true # 可覆盖 sniffer.override-destination - force-domain: - - +.v2ex.com - # 白名单,跳过嗅探结果 - skip-domain: - - Mijia Cloud + # override-destination: false # 是否使用嗅探结果作为实际访问,默认 true + # # 全局配置,优先级低于 sniffer.sniff 实际配置 + # sniff: # TLS 默认如果不配置 ports 默认嗅探 443 + # TLS: + # ports: [443, 8443] + # HTTP: # 需要嗅探的端口, 默认嗅探 80 + # ports: [80, 8080-8880] + # override-destination: true # 可覆盖 sniffer.override-destination + # force-domain: + # - +.v2ex.com + # # 白名单,跳过嗅探结果 + # skip-domain: + # - Mijia Cloud tun: enable: false @@ -95,8 +95,6 @@ tun: - tcp://any:53 auto-route: true auto-detect-interface: true - inet4-address: 172.19.0.1/30 - inet6-address: [fdfe:dcba:9876::1/126] # include_android_user: # - 0 # - 10 @@ -113,7 +111,7 @@ dns: # 可选值 true/false # 是否开启 DOH 的 http/3 - prefer-h3: false + # prefer-h3: false # 默认 dns, 用于解析 DNS 服务器 的域名 # 必须为 ip, 可为加密 dns @@ -284,11 +282,11 @@ rules: # - AND,((NETWORK,udp),(OR,((DST-PORT,443/80),(GEOSITE,youtube)))),REJECT # - AND,((NETWORK,udp),(GEOSITE,youtube)),REJECT - # fix dnsleak - - IP-CIDR,127.0.0.1/32,REJECT,no-resolve - - IP-CIDR,198.18.0.1/16,REJECT,no-resolve - - IP-CIDR,28.0.0.1/8,REJECT,no-resolve - - IP-CIDR6,::1/128,REJECT,no-resolve + # # fix dnsleak + # - IP-CIDR,127.0.0.1/32,REJECT,no-resolve + # - IP-CIDR,198.18.0.1/16,REJECT,no-resolve + # - IP-CIDR,28.0.0.1/8,REJECT,no-resolve + # - IP-CIDR6,::1/128,REJECT,no-resolve ## rules telegram # - GEOIP,telegram,PROXY diff --git a/box/clash/note.txt b/box/clash/note.txt index 6acd5c6..bbc2cd3 100644 --- a/box/clash/note.txt +++ b/box/clash/note.txt @@ -3,5 +3,5 @@ # example configuration and wiki # ######################## -# http://dreamacro.github.io/clash/ -# http://https://wiki.metacubex.one/ \ No newline at end of file +# http://dreamacro.github.io/clash/ >> wiki clash premium +# http://https://wiki.metacubex.one/ >> wiki clash meta \ No newline at end of file diff --git a/box/scripts/box.service b/box/scripts/box.service index 425a18e..613ff42 100755 --- a/box/scripts/box.service +++ b/box/scripts/box.service @@ -289,9 +289,10 @@ prepare_clash() { }}' "$clash_config" log Debug "enhanced-mode: fake-ip add success" fi + if [ "${proxy_mode}" != "tun" ]; then - if [ -n "${packages_list}" ] && [ "${clash_enhanced_mode}" = "fake-ip" ]; then - log Debug "${proxy_mode} only works in enhanced-mode: redir-host(clash.meta)" + if [ -n "${packages_list[*]}" ] && [ "${clash_enhanced_mode}" = "fake-ip" ]; then + log Debug "${proxy_mode} only works in enhanced-mode: redir-host (clash.meta)" log Debug"auto replace fake-ip > redir-host" sed -i "s/enhanced-mode:.*/enhanced-mode: redir-host/g" "${clash_config}" fi @@ -299,7 +300,7 @@ prepare_clash() { } temp_clash_config_file() { - clash_template="/data/adb/box/clash/template" + clash_template="${box_dir}/clash/template" temp_clash_config_file="${clash_config}" if [ -f "${clash_template}" ]; then @@ -437,8 +438,8 @@ box_bin_status() { return 1 fi - log Info "${bin_name}($PID) service is running." - log Info "proxy_mode: ${proxy_mode}, $(if [ "${proxy_mode}" != "tun" ]; then echo network_mode: ${network_mode}; fi)" + log Info "${bin_name} service is running." + log Info "ProxyMode: ${proxy_mode}, $(if [ "${proxy_mode}" != "tun" ]; then echo NetworkMode: ${network_mode}; fi)" # Get the memory usage of the binary rss=$(grep VmRSS /proc/$PID/status | busybox awk '{ print $2 }') diff --git a/box/scripts/box.tool b/box/scripts/box.tool index 4f63313..9e71a2a 100755 --- a/box/scripts/box.tool +++ b/box/scripts/box.tool @@ -7,7 +7,7 @@ source /data/adb/box/settings.ini # user agent user_agent="box_for_root" # option to download Clash kernel clash-premium{false} or clash-meta{true} -meta="true" +meta="false" # for clash-premium dev=false # option to download Singbox kernel beta or release @@ -203,21 +203,21 @@ update_subs() { # remove outbound with type: direct/block/dns/selector/urltest "${yq_cmd}" 'del(.outbounds[] | select(.type == "direct" or .type == "block" or .type == "dns" or .type == "selector" or .type == "urltest"))' -i --output-format=json "${sing_provide_config}" - # create new outbounds with type: selector, tag: ❀✿❀ in ${sing_provide_config} - "${yq_cmd}" '.outbounds += [{"tag": "❀✿❀", "type": "selector", "outbounds": [.outbounds[].tag]}]' -i --output-format=json "${sing_provide_config}" + # create new outbounds with type: selector, tag: singbox in ${sing_provide_config} + "${yq_cmd}" '.outbounds += [{"tag": "singbox", "type": "selector", "outbounds": [.outbounds[].tag]}]' -i --output-format=json "${sing_provide_config}" - # create new outbounds with type: urltest, tag: ❀✿❀[urltest] in ${sing_provide_config} - "${yq_cmd}" '.outbounds += [{"tag": "❀✿❀[urltest]", "type": "urltest", "url": "https://www.gstatic.com/generate_204", "interval": "3m", "outbounds": [.outbounds[].tag]}]' -i --output-format=json "${sing_provide_config}" + # create new outbounds with type: urltest, tag: singbox[urltest] in ${sing_provide_config} + "${yq_cmd}" '.outbounds += [{"tag": "singbox[urltest]", "type": "urltest", "url": "https://www.gstatic.com/generate_204", "interval": "3m", "outbounds": [.outbounds[].tag]}]' -i --output-format=json "${sing_provide_config}" - # renew outbounds with tag: ❀✿❀ in main ${sing_config} dan ${sing_provide_config} - "${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "❀✿❀"))' -i --output-format=json "${sing_provide_config}" - "${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "❀✿❀"))' -i --output-format=json "${sing_config}" - "${yq_cmd}" '.outbounds[0].outbounds += ["❀✿❀"]' -i --output-format=json "${sing_config}" + # renew outbounds with tag: singbox in main ${sing_config} dan ${sing_provide_config} + "${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "singbox"))' -i --output-format=json "${sing_provide_config}" + "${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "singbox"))' -i --output-format=json "${sing_config}" + "${yq_cmd}" '.outbounds[0].outbounds += ["singbox"]' -i --output-format=json "${sing_config}" - # renew outbounds with tag: ❀✿❀[urltest] in main ${sing_config} dan ${sing_provide_config} - "${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "❀✿❀[urltest]"))' -i --output-format=json "${sing_provide_config}" - "${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "❀✿❀[urltest]"))' -i --output-format=json "${sing_config}" - "${yq_cmd}" '.outbounds[0].outbounds += ["❀✿❀[urltest]"]' -i --output-format=json "${sing_config}" + # renew outbounds with tag: singbox[urltest] in main ${sing_config} dan ${sing_provide_config} + "${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "singbox[urltest]"))' -i --output-format=json "${sing_provide_config}" + "${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "singbox[urltest]"))' -i --output-format=json "${sing_config}" + "${yq_cmd}" '.outbounds[0].outbounds += ["singbox[urltest]"]' -i --output-format=json "${sing_config}" log Info "subscription success" log Info "Update subscription $(date +"%F %R")" @@ -520,31 +520,28 @@ cgroup_limit() { } # Check config -rconf() { +reload_config() { # su -c /data/adb/box/scripts/box.tool rconf case "${bin_name}" in sing-box) - if ${bin_path} check -D "${box_dir}/${bin_name}" --config-directory "${box_dir}/sing-box" > "${box_run}/${bin_name}.err.log" 2>&1; then + if ${bin_path} check -D "${box_dir}/${bin_name}" --config-directory "${box_dir}/sing-box" > "${box_run}/${bin_name}_report.log" 2>&1; then log Info "${sing_config} passed" - reload else log Debug "${sing_config}" - log Error "$(<"${box_run}/${bin_name}.err.log")" >&2 - exit 1 + log Error "$(<"${box_run}/${bin_name}_report.log")" >&2 fi ;; clash) - if ${bin_path} -t -d "${box_dir}/clash" -f "${clash_config}" > "${box_run}/${bin_name}.err.log" 2>&1; then + if ${bin_path} -t -d "${box_dir}/clash" -f "${clash_config}" > "${box_run}/${bin_name}_report.log" 2>&1; then log Info "${clash_config} passed" - if [ -t 1 ] && [ "${meta}" = "true" ]; then - reload - fi else - info debug "${clash_config}" - log Error "$(<"${box_run}/${bin_name}.err.log")" >&2 - exit 1 + log debug "${clash_config}" + log Error "$(<"${box_run}/${bin_name}_report.log")" >&2 fi ;; + xray|v2fly) + true + ;; *) log Error "<${bin_name}> unknown binary." exit 1 @@ -553,12 +550,12 @@ rconf() { } # reload bin -reload() { - # su -c /data/adb/box/scripts/box.tool reload +reload_bin() { + # su -c /data/adb/box/scripts/box.tool rbin case "${bin_name}" in sing-box) if kill -SIGHUP "$(busybox pidof sing-box)" >/dev/null 2>&1; then - log Debug "Restart with -SIGHUP done" + log Debug "RESTART with -SIGHUP done" return 0 else flag=true @@ -569,7 +566,7 @@ reload() { ip_port=$(busybox awk '/external-controller:/ {print $2}' "${clash_config}") >/dev/null 2>&1 secret=$(busybox awk '/secret:/ {print $2}' "${clash_config}") >/dev/null 2>&1 if busybox wget --header="Authorization: Bearer ${secret}" --post-data "" -O /dev/null "http://${ip_port}/restart" >/dev/null 2>&1; then - log Debug "Restart with clash.meta api done" + log Debug "RESTART with clash-meta API done" return 0 else flag=true @@ -602,13 +599,13 @@ case "$1" in port_detection ;; rconf) - rconf + reload_config ;; - reload) - reload + rbin) + reload_bin ;; geox) - if update_geox && ! reload; then + if update_geox && ! reload_bin; then if [ -f "${box_pid}" ] && [ "${flag}" = "true" ]; then restart_box fi @@ -616,7 +613,7 @@ case "$1" in busybox pidof "${bin_name}" >/dev/null 2>&1 && open_yacd ;; subs) - if update_subs && ! reload; then + if update_subs && ! reload_bin; then if [ -f "${box_pid}" ] && [ "${flag}" = "true" ]; then restart_box fi @@ -626,7 +623,7 @@ case "$1" in geosub) update_geox update_subs - if ! reload; then + if ! reload_bin; then if [ -f "${box_pid}" ] && [ "${bin_name}" != "clash" ] && [ "${flag}" = "true" ]; then restart_box fi @@ -643,6 +640,6 @@ case "$1" in ;; *) echo "${red}$0 $1 no found${normal}" - echo "${yellow}usage${normal}: ${green}$0${normal} {${yellow}rconf|reload|upyacd|upcore|upyq|cgroup|port|geox|subs|geosub|all${normal}}" + echo "${yellow}usage${normal}: ${green}$0${normal} {${yellow}rconf|rbin|upyacd|upcore|upyq|cgroup|port|geox|subs|geosub|all${normal}}" ;; esac \ No newline at end of file