From 32bf0c33ed820c7b6a1ed48217a645ebe7241162 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Mon, 11 Nov 2024 15:15:33 +0800 Subject: [PATCH 01/53] #4168 --- .../root/usr/share/openclash/res/rule_providers.list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list b/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list index 70843c637d..58dbbb1a5d 100644 --- a/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list +++ b/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list @@ -9,6 +9,7 @@ ABC,lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,ABC.yaml Abema TV,lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,Abema TV.yaml AbemaTV(By ACL4SSR),ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,AbemaTV.yaml,AbemaTV-ACL4SSR.yaml Adobe,ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,Adobe.yaml +AI Suite,lhie1,classical,dler-io/Rules/master/Clash/Provider/,AI Suite.yaml Amazon(By ACL4SSR),ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,Amazon.yaml,Amazon-ACL4SSR.yaml Amazon,lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,Amazon.yaml AmazonIp,ACL4SSR,ipcidr,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,AmazonIp.yaml @@ -28,7 +29,6 @@ Bilibili(By ACL4SSR),ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ru Bilibili,lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,Bilibili.yaml BilibiliHMT,ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,BilibiliHMT.yaml Blizzard,ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,Blizzard.yaml -ChatGPT,lhie1,classical,dler-io/Rules/master/Clash/Provider/,ChatGPT.yaml ChinaCompanyIp,ACL4SSR,ipcidr,ACL4SSR/ACL4SSR/master/Clash/Providers/,ChinaCompanyIp.yaml ChinaDomain,ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/,ChinaDomain.yaml ChinaIp(By ACL4SSR),ACL4SSR,ipcidr,ACL4SSR/ACL4SSR/master/Clash/Providers/,ChinaIp.yaml,ChinaIp-ACL4SSR.yaml From 7b91dce94f6fb3a18c979716a21e9ceee0e53a77 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:46:20 +0800 Subject: [PATCH 02/53] fix typo --- luci-app-openclash/luasrc/view/openclash/status.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/luasrc/view/openclash/status.htm b/luci-app-openclash/luasrc/view/openclash/status.htm index 07fad12567..b874a36056 100644 --- a/luci-app-openclash/luasrc/view/openclash/status.htm +++ b/luci-app-openclash/luasrc/view/openclash/status.htm @@ -678,7 +678,7 @@ function ws_mmessage(event) { var data = JSON.parse(event.data) if (data.inuse) { - document.getElementById("mem_t").innerHTML = ""+bytesToSize(data.inuse)+"/S"; + document.getElementById("mem_t").innerHTML = ""+bytesToSize(data.inuse)+""; } else { document.getElementById("mem_t").innerHTML = "0 KB"; From 4078fa0c065c5a05517f833f97a40ed8e36c6719 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:11:03 +0800 Subject: [PATCH 03/53] fix typo --- luci-app-openclash/root/usr/share/openclash/openclash_debug.sh | 2 +- .../root/usr/share/openclash/openclash_history_get.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh index f5d9a31503..3f46783d5f 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh @@ -46,7 +46,7 @@ lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo "0") if [ "$lan_interface_name" = "0" ]; then lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) else - lan_ip=$(ip address show $(uci -q -p $lan_interface_name) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') + lan_ip=$(ip address show $lan_interface_name | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') fi dnsmasq_default_resolvfile=$(uci -q get openclash.config.default_resolvfile) diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh index 44efafded0..9ec358dd8e 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh @@ -18,7 +18,7 @@ close_all_conection() { if [ "$lan_interface_name" = "0" ]; then LAN_IP=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) else - LAN_IP=$(ip address show $(uci -q -p $lan_interface_name) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') + LAN_IP=$(ip address show $lan_interface_name | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') fi PORT=$(uci -q get openclash.config.cn_port) curl -m 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X DELETE http://"$LAN_IP":"$PORT"/connections >/dev/null 2>&1 From 6d0fb713cbe7de1e607277a8661ae09c04c4452b Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Fri, 15 Nov 2024 08:44:44 +0800 Subject: [PATCH 04/53] fix #4179 --- luci-app-openclash/root/etc/init.d/openclash | 2 +- luci-app-openclash/root/usr/share/openclash/yml_change.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index ce30ed738b..5504238787 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -2943,7 +2943,7 @@ start() if ! $quick_start; then LOG_OUT "Step 3: Modify The Config File..." config_check - /usr/share/openclash/yml_change.sh 2>/dev/null "$en_mode" "$da_password" "$cn_port" "$proxy_port" "$TMP_CONFIG_FILE" "$ipv6_enable" "$http_port" "$socks_port" "$log_level" "$proxy_mode" "$en_mode_tun" "$stack_type" "$dns_port" "$mixed_port" "$tproxy_port" "$ipv6_dns" "$store_fakeip" "$enable_meta_sniffer" "$enable_geoip_dat" "$geodata_loader" "$enable_meta_sniffer_custom" "$interface_name" "$enable_tcp_concurrent" "$core_type" "$append_default_dns" "$enable_meta_sniffer_pure_ip" "$find_process_mode" "$fakeip_range" "$global_client_fingerprint" "$ipv6_mode" "$stack_type_v6" "$enable_unified_delay" "$enable_respect_rules" "$custom_fakeip_filter_mode" + /usr/share/openclash/yml_change.sh 2>/dev/null "$en_mode" "$da_password" "$cn_port" "$proxy_port" "$TMP_CONFIG_FILE" "$ipv6_enable" "$http_port" "$socks_port" "$log_level" "$proxy_mode" "$en_mode_tun" "$stack_type" "$dns_port" "$mixed_port" "$tproxy_port" "$ipv6_dns" "$store_fakeip" "$enable_meta_sniffer" "$enable_geoip_dat" "$geodata_loader" "$enable_meta_sniffer_custom" "$interface_name" "$enable_tcp_concurrent" "$core_type" "$append_default_dns" "$enable_meta_sniffer_pure_ip" "$find_process_mode" "$fakeip_range" "$global_client_fingerprint" "$ipv6_mode" "$stack_type_v6" "$enable_unified_delay" "$enable_respect_rules" "$custom_fakeip_filter_mode" "$iptables_compat" /usr/share/openclash/yml_rules_change.sh 2>/dev/null "$rule_source" "$enable_custom_clash_rules" "$TMP_CONFIG_FILE" "$enable_rule_proxy" "$CONFIG_NAME" "$router_self_proxy" "$lan_ip" "$proxy_port" "$tproxy_port" "$enable_redirect_dns" "$fakeip_range" "$en_mode" #Custom overwrite if [ -f "/etc/openclash/custom/openclash_custom_overwrite.sh" ]; then diff --git a/luci-app-openclash/root/usr/share/openclash/yml_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_change.sh index 4bca0bef28..a09f0ef098 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_change.sh @@ -452,7 +452,7 @@ threads << Thread.new { Value.delete('ebpf'); end; - if '${37}' == '0' then + if '${35}' == '0' then Value['routing-mark']=6666; else if Value.key?('routing-mark') then From 23744bad0c587068dc556b065a735f641934aba4 Mon Sep 17 00:00:00 2001 From: zxl hhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Fri, 15 Nov 2024 08:52:57 +0800 Subject: [PATCH 05/53] luci-app-openclash: adapt to openwrt official dnsmasq modifiy. (#4140) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、官方dnsmasq路径已变更为:/tmp/dnsmasq.cfgxxxxx.d(xxxxx为dnsmasq生成的配置ID),而目前openclash默认dnsmasq的路径为:/tmp/dnsmasq.d,如不做修改,会导致dns无法解析引起插件可正常运行但节点连接失败。 2、lede等旧版本的dnsmasq的路径仍为:/tmp/dnsmasq.d,考虑到此情况,本次修改自动判断官方和lede等新旧版本的dnsmasq路径,以便正确实现dns解析,并使节点正常链接。 --- luci-app-openclash/root/etc/init.d/openclash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index 5504238787..e88a3d2b44 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -14,7 +14,13 @@ BACKUP_FILE="/etc/openclash/backup/$(uci -q get openclash.config.config_path |aw CONFIG_FILE="/etc/openclash/$(uci -q get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)" TMP_CONFIG_FILE="/tmp/yaml_config_tmp_$(uci -q get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)" FW4=$(command -v fw4) -DNSMASQ_CONF_DIR=$(uci -q get dhcp.@dnsmasq[0].confdir || echo '/tmp/dnsmasq.d') +# Get the default DNSMasq config ID from the UCI configuration +DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | awk -F '=' '{print $1}' | head -1) +# Locate the dnsmasq.conf file that contains the conf-dir option +DNSMASQ_CONF_PATH=$(grep -l "^conf-dir=" "/tmp/etc/dnsmasq.conf.${DEFAULT_DNSMASQ_CFGID}") +# Extract the directory path from the conf-dir line +DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) +# Check if a conf-dir value was found and set variables accordingly DNSMASQ_CONF_DIR=${DNSMASQ_CONF_DIR%*/} } CLASH="/etc/openclash/clash" From d16c6d0e490c990a68a7c4c4ca8eb3f1b6ef20a5 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:59:57 +0800 Subject: [PATCH 06/53] chore: refine --- .../usr/share/openclash/openclash_custom_domain_dns.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh b/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh index 59073ede69..c3962e1647 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh @@ -13,7 +13,13 @@ del_lock() { set_lock -DNSMASQ_CONF_DIR=$(uci -q get dhcp.@dnsmasq[0].confdir || echo '/tmp/dnsmasq.d') +# Get the default DNSMasq config ID from the UCI configuration +DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | awk -F '=' '{print $1}' | head -1) +# Locate the dnsmasq.conf file that contains the conf-dir option +DNSMASQ_CONF_PATH=$(grep -l "^conf-dir=" "/tmp/etc/dnsmasq.conf.${DEFAULT_DNSMASQ_CFGID}") +# Extract the directory path from the conf-dir line +DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) +# Check if a conf-dir value was found and set variables accordingly DNSMASQ_CONF_DIR=${DNSMASQ_CONF_DIR%*/} rm -rf ${DNSMASQ_CONF_DIR}/dnsmasq_openclash_custom_domain.conf >/dev/null 2>&1 if [ "$(uci get openclash.config.enable_custom_domain_dns_server 2>/dev/null)" = "1" ] && [ "$(uci get openclash.config.enable_redirect_dns 2>/dev/null)" = "1" ]; then From e75180cce2cd8ad51fd6ceb8d5191ee82d7d4351 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 20 Nov 2024 05:46:10 +0800 Subject: [PATCH 07/53] chore: apk compatiable --- .github/workflows/compile_new_ipk.yml | 50 +++++--- .github/workflows/master_release_sync.yml | 2 +- luci-app-openclash/Makefile | 15 +-- .../luasrc/controller/openclash.lua | 14 ++- .../po/zh-cn/openclash.zh-cn.po | 3 + luci-app-openclash/root/etc/init.d/openclash | 2 +- .../usr/share/openclash/openclash_debug.sh | 65 ++++++----- .../share/openclash/openclash_history_get.sh | 2 +- .../usr/share/openclash/openclash_update.sh | 109 +++++++++++++----- .../usr/share/openclash/openclash_version.sh | 8 +- .../resources/openclash/img/version.svg | 2 +- 11 files changed, 187 insertions(+), 85 deletions(-) diff --git a/.github/workflows/compile_new_ipk.yml b/.github/workflows/compile_new_ipk.yml index e2842bad6f..d75b9cef3e 100644 --- a/.github/workflows/compile_new_ipk.yml +++ b/.github/workflows/compile_new_ipk.yml @@ -35,8 +35,8 @@ jobs: - name: Current Version id: current_version run: | - echo "version=$(sed -n 1p ./${{ github.ref_name }}/version |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}')" >> $GITHUB_OUTPUT - echo "Current Version: $(sed -n 1p ./${{ github.ref_name }}/version |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}')" + echo "version=$(sed -n 1p ./${{ github.ref_name }}/version |awk -F 'v' '{print $2}')" >> $GITHUB_OUTPUT + echo "Current Version: $(sed -n 1p ./${{ github.ref_name }}/version |awk -F 'v' '{print $2}')" Compile: runs-on: ubuntu-latest @@ -53,7 +53,7 @@ jobs: DEBIAN_FRONTEND: noninteractive run: | sudo apt-get update - sudo apt-get -y install curl git tar + sudo apt-get -y install curl git tar zstd - name: Install OpenWrt SDK run: | @@ -63,12 +63,23 @@ jobs: cd \tmp tar xjf SDK.tar.bz2 mv "OpenWrt-SDK-15.05.1-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64" "SDK" + + - name: Install OpenWrt SNAPSHPT SDK + run: | + cd .. + curl -SLk --connect-timeout 30 --retry 2 "https://downloads.openwrt.org/snapshots/targets/x86/64/openwrt-sdk-x86-64_gcc-13.3.0_musl.Linux-x86_64.tar.zst" -o "./tmp/SNAPSDK.tar.zst" + cd \tmp + zstd -d SNAPSDK.tar.zst + tar xf SNAPSDK.tar + mv "openwrt-sdk-x86-64_gcc-13.3.0_musl.Linux-x86_64" "SNAPSDK" - name: Copy OpenClash Source Codes run: | cd .. - mkdir tmp/SDK/package/luci-app-openclash + mkdir -p tmp/SDK/package/luci-app-openclash + mkdir -p tmp/SNAPSDK/package/luci-app-openclash cp -rf "./OpenClash/luci-app-openclash/." "./tmp/SDK/package/luci-app-openclash/" + cp -rf "./OpenClash/luci-app-openclash/." "./tmp/SNAPSDK/package/luci-app-openclash/" - name: Compile po2lmo run: | @@ -77,12 +88,24 @@ jobs: pushd luci-app-openclash/tools/po2lmo make && sudo make install popd + cd ../../.. + cd tmp/SNAPSDK/package/ + pushd luci-app-openclash/tools/po2lmo + make && sudo make install + popd - name: Compile OpenClash IPK run: | cd .. cd tmp/SDK make package/luci-app-openclash/compile V=99 + + - name: Compile OpenClash APK + run: | + cd .. + cd tmp/SNAPSDK + make defconfig + make package/luci-app-openclash/compile V=99 - name: Switch OpenClash Repository to Package uses: actions/checkout@v4 @@ -91,18 +114,19 @@ jobs: - name: Commit and Push New Version run: | - rm -rf ./${{ github.ref_name }}/luci-app-openclash_* - echo "v${{ needs.Get-Version.outputs.version }}-beta" > ./${{ github.ref_name }}/version - echo "https://img.shields.io/badge/New Release-v${{ needs.Get-Version.outputs.version }}--beta-orange.svg" >> ./${{ github.ref_name }}/version + rm -rf ./${{ github.ref_name }}/luci-app-openclash* + echo "v${{ needs.Get-Version.outputs.version }}" > ./${{ github.ref_name }}/version + echo "https://img.shields.io/badge/New Release-v${{ needs.Get-Version.outputs.version }}-orange.svg" >> ./${{ github.ref_name }}/version cd .. - cp "./tmp/SDK/bin/ar71xx/packages/base/luci-app-openclash_${{ needs.Get-Version.outputs.version }}-beta_all.ipk" "./OpenClash/${{ github.ref_name }}/luci-app-openclash_${{ needs.Get-Version.outputs.version }}-beta_all.ipk" - sed -i -E "s/OpenClash\/tree\/v(.*)-beta/OpenClash\/tree\/v${{ needs.Get-Version.outputs.version }}-beta/g" ./OpenClash/${{ github.ref_name }}/README.md - sed -i -E "s/OpenClash\/releases\/tag\/v(.*)-beta/OpenClash\/releases\/tag\/v${{ needs.Get-Version.outputs.version }}-beta/g" ./OpenClash/${{ github.ref_name }}/README.md - sed -i -E "s/source code-v(.*)--beta-green/source code-v${{ needs.Get-Version.outputs.version }}--beta-green/g" ./OpenClash/${{ github.ref_name }}/README.md - sed -i -E "s/New Release-v(.*)--beta-orange/New Release-v${{ needs.Get-Version.outputs.version }}--beta-orange/g" ./OpenClash/${{ github.ref_name }}/README.md + cp "./tmp/SDK/bin/ar71xx/packages/base/luci-app-openclash_${{ needs.Get-Version.outputs.version }}_all.ipk" "./OpenClash/${{ github.ref_name }}/luci-app-openclash_${{ needs.Get-Version.outputs.version }}_all.ipk" + cp "./tmp/SNAPSDK/bin/packages/x86_64/base/luci-app-openclash-${{ needs.Get-Version.outputs.version }}.apk" "./OpenClash/${{ github.ref_name }}/luci-app-openclash-${{ needs.Get-Version.outputs.version }}.apk" + sed -i -E "s/OpenClash\/tree\/v(.*)/OpenClash\/tree\/v${{ needs.Get-Version.outputs.version }}/g" ./OpenClash/${{ github.ref_name }}/README.md + sed -i -E "s/OpenClash\/releases\/tag\/v(.*)/OpenClash\/releases\/tag\/v${{ needs.Get-Version.outputs.version }}/g" ./OpenClash/${{ github.ref_name }}/README.md + sed -i -E "s/source code-v(.*)-green/source code-v${{ needs.Get-Version.outputs.version }}-green/g" ./OpenClash/${{ github.ref_name }}/README.md + sed -i -E "s/New Release-v(.*)-orange/New Release-v${{ needs.Get-Version.outputs.version }}-orange/g" ./OpenClash/${{ github.ref_name }}/README.md cd \OpenClash git config user.name 'github-actions[bot]' git config user.email 'github-actions[bot]@users.noreply.github.com' git add . - git commit -m "Auto Release: v${{ needs.Get-Version.outputs.version }}-beta" + git commit -m "Auto Release: v${{ needs.Get-Version.outputs.version }}" git push diff --git a/.github/workflows/master_release_sync.yml b/.github/workflows/master_release_sync.yml index 115bd8ac74..1d4f7dc1d6 100644 --- a/.github/workflows/master_release_sync.yml +++ b/.github/workflows/master_release_sync.yml @@ -47,7 +47,7 @@ jobs: run: | if [ -n "$(diff -r ./master/ ./dev/)" ]; then rm -rf ./master/README.md - rm -rf ./master/luci-app-openclash_* + rm -rf ./master/luci-app-openclash* rm -rf ./master/version cp -rf "./dev/." "./master/" git config user.name 'github-actions[bot]' diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 1eb71bcd1d..ff104cd5e3 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -2,7 +2,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash PKG_VERSION:=0.46.050 -PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) @@ -105,7 +104,7 @@ endef define Package/$(PKG_NAME)/postinst #!/bin/sh - sed -i "s/v0.00.00-beta/v$(PKG_VERSION)-beta/g" /www/luci-static/resources/openclash/img/version.svg >/dev/null 2>&1 + sed -i "s/v0.00.00/v$(PKG_VERSION)/g" /www/luci-static/resources/openclash/img/version.svg >/dev/null 2>&1 exit 0 endef @@ -122,8 +121,10 @@ endef define Package/$(PKG_NAME)/postrm #!/bin/sh - dnsmasqconfdir="$(uci -q get dhcp.@dnsmasq[0].confdir || echo '/tmp/dnsmasq.d')" - dnsmasqconfdir="${dnsmasqconfdir%*/}" + DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | awk -F '=' '{print $1}' | head -1) + DNSMASQ_CONF_PATH=$(grep -l "^conf-dir=" "/tmp/etc/dnsmasq.conf.${DEFAULT_DNSMASQ_CFGID}") + DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) + DNSMASQ_CONF_DIR=${DNSMASQ_CONF_DIR%*/} rm -rf /etc/openclash >/dev/null 2>&1 rm -rf /tmp/openclash.log >/dev/null 2>&1 rm -rf /tmp/openclash_start.log >/dev/null 2>&1 @@ -135,9 +136,9 @@ define Package/$(PKG_NAME)/postrm rm -rf /tmp/rule_providers_name >/dev/null 2>&1 rm -rf /tmp/clash_last_version >/dev/null 2>&1 rm -rf /usr/share/openclash/backup >/dev/null 2>&1 - rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_custom_domain.conf >/dev/null 2>&1 - rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_chnroute_pass.conf >/dev/null 2>&1 - rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_chnroute6_pass.conf >/dev/null 2>&1 + rm -rf ${DNSMASQ_CONF_DIR}/dnsmasq_openclash_custom_domain.conf >/dev/null 2>&1 + rm -rf ${DNSMASQ_CONF_DIR}/dnsmasq_openclash_chnroute_pass.conf >/dev/null 2>&1 + rm -rf ${DNSMASQ_CONF_DIR}/dnsmasq_openclash_chnroute6_pass.conf >/dev/null 2>&1 rm -rf /tmp/dler* >/dev/null 2>&1 rm -rf /tmp/etc/openclash >/dev/null 2>&1 rm -rf /tmp/openclash_edit_file_name >/dev/null 2>&1 diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index d65ad4a439..7411895996 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -104,6 +104,8 @@ local device_arh = luci.sys.exec("uname -m |tr -d '\n'") if pcall(require, "luci.model.ipkg") then opkg = require "luci.model.ipkg" +else + opkg = nil end local core_path_mode = uci:get("openclash", "config", "small_flash_memory") @@ -216,7 +218,11 @@ local function coremodel() if opkg and opkg.info("libc") and opkg.info("libc")["libc"] then return opkg.info("libc")["libc"]["Architecture"] else - return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null") + if fs.access("/bin/opkg") then + return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null") + elseif fs.access("/usr/bin/apk") then + return luci.sys.exec("apk list libc |awk '{print $2}'") + end end end @@ -246,7 +252,11 @@ local function opcv() if opkg and opkg.info("luci-app-openclash") and opkg.info("luci-app-openclash")["luci-app-openclash"] then return "v" .. opkg.info("luci-app-openclash")["luci-app-openclash"]["Version"] else - return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print \"v\"$2}'") + if fs.access("/bin/opkg") then + return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print \"v\"$2}'") + elseif fs.access("/usr/bin/apk") then + return "v" .. luci.sys.exec("apk list luci-app-openclash |grep 'installed' | grep -oE '\\d+(\\.\\d+)*' | head -1") + end end end diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index d3fcca9444..8550816e81 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -1620,6 +1620,9 @@ msgstr "OpenClash 更新成功,即将进行重启!" msgid "OpenClash Update Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" msgstr "OpenClash 更新失败,文件保存在 /tmp/openclash.ipk,请尝试手动更新!" +msgid "OpenClash Update Failed, The File is Saved in /tmp/openclash.apk, Please Try to Update Manually!" +msgstr "OpenClash 更新失败,文件保存在 /tmp/openclash.apk,请尝试手动更新!" + msgid "Download Failed, Please Check The Network or Try Again Later!" msgstr "下载失败,请检查网络或稍后再试!" diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index e88a3d2b44..24a0931ff6 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -466,7 +466,7 @@ do_run_file() #Some MIPS devices file system cound not use db source "/etc/openwrt_release" - [ "$small_flash_memory" == "1" ] || [ -n "$(echo $core_version |grep mips)" ] || [ -n "$(echo $DISTRIB_ARCH |grep mips)" ] || [ -n "$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' |grep mips)" ] && mkdir -p /tmp/etc/openclash && CACHE_PATH="/tmp/etc/openclash/cache.db" + [ "$small_flash_memory" == "1" ] || [ -n "$(echo $core_version |grep mips)" ] || [ -n "$(echo $DISTRIB_ARCH |grep mips)" ] || [ -n "$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' |grep mips)" ] || [ -n "$(apk list libc 2>/dev/null |grep mips)" ] && mkdir -p /tmp/etc/openclash && CACHE_PATH="/tmp/etc/openclash/cache.db" [ -f "/etc/openclash/geosite.dat" ] && { mv "/etc/openclash/geosite.dat" "/etc/openclash/GeoSite.dat" 2>/dev/null diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh index 3f46783d5f..4d25dd939a 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh @@ -31,11 +31,11 @@ en_mode=$(uci -q get openclash.config.en_mode) RAW_CONFIG_FILE=$(uci -q get openclash.config.config_path) CONFIG_FILE="/etc/openclash/$(uci -q get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)" core_model=$(uci -q get openclash.config.core_version) -cpu_model=$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null) +cpu_model=$(ipk_v libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null) core_meta_version=$(/etc/openclash/core/clash_meta -v 2>/dev/null |awk -F ' ' '{print $3}' |head -1 2>/dev/null) servers_update=$(uci -q get openclash.config.servers_update) mix_proxies=$(uci -q get openclash.config.mix_proxies) -op_version=$(opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print "v"$2}') +op_version=$(ipk_v luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print "v"$2}') china_ip_route=$(uci -q get openclash.config.china_ip_route) common_ports=$(uci -q get openclash.config.common_ports) router_self_proxy=$(uci -q get openclash.config.router_self_proxy) @@ -80,6 +80,15 @@ ts_re() fi } +ipk_v() +{ + if [ -x "/bin/opkg" ]; then + echo $(opkg status "$1" 2>/dev/null |grep 'Version' |awk -F ': ' '{print $2}' 2>/dev/null) + elif [ -x "/usr/bin/apk" ]; then + echo $(apk list "$1" |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) + fi +} + dns_re() { if [ "$1" = "1" ]; then @@ -107,7 +116,7 @@ cat >> "$DEBUG_LOG" <<-EOF 主机型号: $(cat /tmp/sysinfo/model 2>/dev/null) 固件版本: $(cat /usr/lib/os-release 2>/dev/null |grep OPENWRT_RELEASE 2>/dev/null |awk -F '"' '{print $2}' 2>/dev/null) -LuCI版本: $(opkg status luci 2>/dev/null |grep 'Version' |awk -F ': ' '{print $2}' 2>/dev/null) +LuCI版本: $(ipk_v "luci") 内核版本: $(uname -r 2>/dev/null) 处理器架构: $cpu_model @@ -123,36 +132,38 @@ cat >> "$DEBUG_LOG" <<-EOF #===================== 依赖检查 =====================# -dnsmasq-full: $(ts_re "$(opkg status dnsmasq-full 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -coreutils: $(ts_re "$(opkg status coreutils 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -coreutils-nohup: $(ts_re "$(opkg status coreutils-nohup 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -bash: $(ts_re "$(opkg status bash 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -curl: $(ts_re "$(opkg status curl 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ca-certificates: $(ts_re "$(opkg status ca-certificates 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ipset: $(ts_re "$(opkg status ipset 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ip-full: $(ts_re "$(opkg status ip-full 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -libcap: $(ts_re "$(opkg status libcap 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -libcap-bin: $(ts_re "$(opkg status libcap-bin 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ruby: $(ts_re "$(opkg status ruby 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ruby-yaml: $(ts_re "$(opkg status ruby-yaml 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ruby-psych: $(ts_re "$(opkg status ruby-psych 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ruby-pstore: $(ts_re "$(opkg status ruby-pstore 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-tun(TUN模式): $(ts_re "$(opkg status kmod-tun 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -luci-compat(Luci >= 19.07): $(ts_re "$(opkg status luci-compat 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-inet-diag(PROCESS-NAME): $(ts_re "$(opkg status kmod-inet-diag 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -unzip: $(ts_re "$(opkg status unzip 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") +dnsmasq-full: $(ts_re "$(ipk_v "dnsmasq-full")") +dnsmasq-full(ipset): $(ts_re "$(dnsmasq --version |grep -v no-ipset |grep ipset)") +dnsmasq-full(nftset): $(ts_re "$(dnsmasq --version |grep nftset)") +coreutils: $(ts_re "$(ipk_v "coreutils")") +coreutils-nohup: $(ts_re "$(ipk_v "coreutils-nohup")") +bash: $(ts_re "$(ipk_v "bash")") +curl: $(ts_re "$(ipk_v "curl")") +ca-certificates: $(ts_re "$(ipk_v "ca-certificates")") +ipset: $(ts_re "$(ipk_v "ipset")") +ip-full: $(ts_re "$(ipk_v "ip-full")") +libcap: $(ts_re "$(ipk_v "libcap")") +libcap-bin: $(ts_re "$(ipk_v "libcap-bin")") +ruby: $(ts_re "$(ipk_v "ruby")") +ruby-yaml: $(ts_re "$(ipk_v "ruby-yaml")") +ruby-psych: $(ts_re "$(ipk_v "ruby-psych")") +ruby-pstore: $(ts_re "$(ipk_v "ruby-pstore")") +kmod-tun(TUN模式): $(ts_re "$(ipk_v "kmod-tun")") +luci-compat(Luci >= 19.07): $(ts_re "$(ipk_v "luci-compat")") +kmod-inet-diag(PROCESS-NAME): $(ts_re "$(ipk_v "kmod-inet-diag")") +unzip: $(ts_re "$(ipk_v "unzip")") EOF if [ -n "$(command -v fw4)" ]; then cat >> "$DEBUG_LOG" <<-EOF -kmod-nft-tproxy: $(ts_re "$(opkg status kmod-nft-tproxy 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") +kmod-nft-tproxy: $(ts_re "$(ipk_v kmod-nft-tproxy)") EOF else cat >> "$DEBUG_LOG" <<-EOF -iptables-mod-tproxy: $(ts_re "$(opkg status iptables-mod-tproxy 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-ipt-tproxy: $(ts_re "$(opkg status kmod-ipt-tproxy 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -iptables-mod-extra: $(ts_re "$(opkg status iptables-mod-extra 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-ipt-extra: $(ts_re "$(opkg status kmod-ipt-extra 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-ipt-nat: $(ts_re "$(opkg status kmod-ipt-nat 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") +iptables-mod-tproxy: $(ts_re "$(ipk_v "iptables-mod-tproxy")") +kmod-ipt-tproxy: $(ts_re "$(ipk_v "kmod-ipt-tproxy")") +iptables-mod-extra: $(ts_re "$(ipk_v "iptables-mod-extra")") +kmod-ipt-extra: $(ts_re "$(ipk_v "kmod-ipt-extra")") +kmod-ipt-nat: $(ts_re "$(ipk_v "kmod-ipt-nat")") EOF fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh index 9ec358dd8e..04e11731b6 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh @@ -48,7 +48,7 @@ if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then fi if [ -n "$(pidof clash)" ] && [ -f "$CONFIG_FILE" ]; then - if [ "$small_flash_memory" == "1" ] || [ -n "$(echo $core_version |grep mips)" ] || [ -n "$(echo $DISTRIB_ARCH |grep mips)" ] || [ -n "$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' |grep mips)" ]; then + if [ "$small_flash_memory" == "1" ] || [ -n "$(echo $core_version |grep mips)" ] || [ -n "$(echo $DISTRIB_ARCH |grep mips)" ] || [ -n "$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' |grep mips)" ] || [ -n "$(apk list libc 2>/dev/null |grep mips)" ]; then CACHE_PATH="/tmp/etc/openclash/cache.db" if [ -f "$CACHE_PATH" ]; then cmp -s "$CACHE_PATH" "$HISTORY_PATH" diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index 2300f51295..16496085ee 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -27,8 +27,12 @@ fi LAST_OPVER="/tmp/openclash_last_version" LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |sed "s/^v//g" |tr -d "\n") -OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F '-' '{print $1}' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) -OP_LV=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +if [ -x "/bin/opkg" ]; then + OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +elif [ -x "/usr/bin/apk" ]; then + OP_CV=$(apk list luci-app-openclash |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) +fi +OP_LV=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") LOG_FILE="/tmp/openclash.log" github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0) @@ -60,30 +64,50 @@ if [ -n "$OP_CV" ] && [ -n "$OP_LV" ] && [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 LOG_OUT "Start Downloading【OpenClash - v$LAST_VER】..." if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + if [ -x "/bin/opkg" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + elif [ -x "/usr/bin/apk" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + fi elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + if [ -x "/bin/opkg" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + elif [ -x "/usr/bin/apk" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + fi else - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + if [ -x "/bin/opkg" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + elif [ -x "/usr/bin/apk" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + fi fi else - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + if [ -x "/bin/opkg" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + elif [ -x "/usr/bin/apk" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + fi fi - if [ "${PIPESTATUS[0]}" -eq 0 ] && [ -s "/tmp/openclash.ipk" ]; then - LOG_OUT "【OpenClash - v$LAST_VER】Download Successful, Start Pre Update Test..." - - if [ -z "$(opkg install /tmp/openclash.ipk --noaction 2>/dev/null |grep 'Upgrading luci-app-openclash on root' 2>/dev/null)" ]; then - LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" - if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then - /etc/init.d/openclash restart >/dev/null 2>&1 & - else - SLOG_CLEAN + if [ "${PIPESTATUS[0]}" -eq 0 ]; then + if [ -x "/bin/opkg" ]; then + if [ -s "/tmp/openclash.ipk" ]; then + LOG_OUT "【OpenClash - v$LAST_VER】Download Successful, Start Pre Update Test..." + + if [ -z "$(opkg install /tmp/openclash.ipk --noaction 2>/dev/null |grep 'Upgrading luci-app-openclash on root' 2>/dev/null)" ]; then + LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" + if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then + /etc/init.d/openclash restart >/dev/null 2>&1 & + else + SLOG_CLEAN + fi + del_lock + exit 0 + fi fi - del_lock - exit 0 + LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Passed, Ready to Update and Please Do not Refresh The Page and Other Operations..." fi - LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Passed, Ready to Update and Please Do not Refresh The Page and Other Operations..." cat > /tmp/openclash_update.sh <<"EOF" #!/bin/sh START_LOG="/tmp/openclash_start.log" @@ -106,21 +130,45 @@ SLOG_CLEAN() LOG_OUT "Uninstalling The Old Version, Please Do not Refresh The Page or Do Other Operations..." uci -q set openclash.config.enable=0 uci -q commit openclash -opkg remove --force-depends --force-remove luci-app-openclash +if [ -x "/bin/opkg" ]; then + opkg remove --force-depends --force-remove luci-app-openclash +elif [ -x "/usr/bin/apk" ]; then + apk del luci-app-openclash +fi LOG_OUT "Installing The New Version, Please Do Not Refresh The Page or Do Other Operations..." -opkg install /tmp/openclash.ipk -if [ "$?" != "0" ] || [ -z "$(opkg info *openclash |grep Installed-Time)" ]; then +if [ -x "/bin/opkg" ]; then opkg install /tmp/openclash.ipk +elif [ -x "/usr/bin/apk" ]; then + apk add --allow-untrusted /tmp/openclash.apk fi -if [ "$?" == "0" ] && [ -n "$(opkg info *openclash |grep Installed-Time)" ]; then - rm -rf /tmp/openclash.ipk >/dev/null 2>&1 - LOG_OUT "OpenClash Update Successful, About To Restart!" - uci -q set openclash.config.enable=1 - uci -q commit openclash - /etc/init.d/openclash restart 2>/dev/null -else - LOG_OUT "OpenClash Update Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" - SLOG_CLEAN +if [ -x "/bin/opkg" ]; then + if [ "$?" != "0" ] || [ -z "$(opkg info *openclash |grep Installed-Time)" ]; then + opkg install /tmp/openclash.ipk + fi + if [ "$?" == "0" ] && [ -n "$(opkg info *openclash |grep Installed-Time)" ]; then + rm -rf /tmp/openclash.ipk >/dev/null 2>&1 + LOG_OUT "OpenClash Update Successful, About To Restart!" + uci -q set openclash.config.enable=1 + uci -q commit openclash + /etc/init.d/openclash restart 2>/dev/null + else + LOG_OUT "OpenClash Update Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" + SLOG_CLEAN + fi +elif [ -x "/usr/bin/apk" ]; then + if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash |grep 'installed')" ]; then + apk add --allow-untrusted /tmp/openclash.apk + fi + if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash |grep 'installed')" ]; then + rm -rf /tmp/openclash.apk >/dev/null 2>&1 + LOG_OUT "OpenClash Update Successful, About To Restart!" + uci -q set openclash.config.enable=1 + uci -q commit openclash + /etc/init.d/openclash restart 2>/dev/null + else + LOG_OUT "OpenClash Update Failed, The File is Saved in /tmp/openclash.apk, Please Try to Update Manually!" + SLOG_CLEAN + fi fi EOF chmod 4755 /tmp/openclash_update.sh @@ -130,6 +178,7 @@ EOF else LOG_OUT "【OpenClash - v$LAST_VER】Download Failed, Please Check The Network or Try Again Later!" rm -rf /tmp/openclash.ipk >/dev/null 2>&1 + rm -rf /tmp/openclash.apk >/dev/null 2>&1 if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then /etc/init.d/openclash restart >/dev/null 2>&1 & else diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh index 163559af7c..028b166121 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh @@ -4,8 +4,12 @@ TIME=$(date "+%Y-%m-%d-%H") CHTIME=$(date "+%Y-%m-%d-%H" -r "/tmp/openclash_last_version" 2>/dev/null) LAST_OPVER="/tmp/openclash_last_version" RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") -OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F '-' '{print $1}' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) -OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +if [ -x "/bin/opkg" ]; then + OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +elif [ -x "/usr/bin/apk" ]; then + OP_CV=$(apk list luci-app-openclash |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) +fi +OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0) if [ -n "$1" ]; then github_address_mod="$1" diff --git a/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg b/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg index 4664f7519b..f8cfa888e3 100644 --- a/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg +++ b/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg @@ -1 +1 @@ -Current Version: v0.00.00-betaCurrent Versionv0.00.00-beta \ No newline at end of file +Current Version: v0.00.00Current Versionv0.00.00 \ No newline at end of file From 9b9f3518647ff057b5c42f0d54f51a99f2321d57 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:51:46 +0800 Subject: [PATCH 08/53] chore: refine --- .../luasrc/controller/openclash.lua | 4 +-- .../usr/share/openclash/openclash_debug.sh | 26 +++++++++++-------- .../usr/share/openclash/openclash_update.sh | 6 ++--- .../usr/share/openclash/openclash_version.sh | 2 +- .../resources/openclash/img/version.svg | 2 +- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index 7411895996..db41259660 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -221,7 +221,7 @@ local function coremodel() if fs.access("/bin/opkg") then return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null") elseif fs.access("/usr/bin/apk") then - return luci.sys.exec("apk list libc |awk '{print $2}'") + return luci.sys.exec("apk list libc 2>/dev/null |awk '{print $2}'") end end end @@ -255,7 +255,7 @@ local function opcv() if fs.access("/bin/opkg") then return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print \"v\"$2}'") elseif fs.access("/usr/bin/apk") then - return "v" .. luci.sys.exec("apk list luci-app-openclash |grep 'installed' | grep -oE '\\d+(\\.\\d+)*' | head -1") + return "v" .. luci.sys.exec("apk list luci-app-openclash 2>/dev/null |grep 'installed' | grep -oE '\\d+(\\.\\d+)*' | head -1") end end end diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh index 4d25dd939a..ba7bb18dea 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh @@ -12,6 +12,15 @@ del_lock() { rm -rf "/tmp/lock/openclash_debug.lock" } +ipk_v() +{ + if [ -x "/bin/opkg" ]; then + echo $(opkg status "$1" 2>/dev/null |grep 'Version' |awk -F ': ' '{print $2}' 2>/dev/null) + elif [ -x "/usr/bin/apk" ]; then + echo $(apk list "$1" 2>/dev/null |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) + fi +} + DEBUG_LOG="/tmp/openclash_debug.log" LOGTIME=$(echo $(date "+%Y-%m-%d %H:%M:%S")) set_lock @@ -31,11 +40,15 @@ en_mode=$(uci -q get openclash.config.en_mode) RAW_CONFIG_FILE=$(uci -q get openclash.config.config_path) CONFIG_FILE="/etc/openclash/$(uci -q get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)" core_model=$(uci -q get openclash.config.core_version) -cpu_model=$(ipk_v libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null) +if [ -x "/bin/opkg" ]; then + cpu_model=$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null) +elif [ -x "/usr/bin/apk" ]; then + cpu_model=$(apk list libc 2>/dev/null|awk '{print $2}') +fi core_meta_version=$(/etc/openclash/core/clash_meta -v 2>/dev/null |awk -F ' ' '{print $3}' |head -1 2>/dev/null) servers_update=$(uci -q get openclash.config.servers_update) mix_proxies=$(uci -q get openclash.config.mix_proxies) -op_version=$(ipk_v luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print "v"$2}') +op_version=$(ipk_v "luci-app-openclash") china_ip_route=$(uci -q get openclash.config.china_ip_route) common_ports=$(uci -q get openclash.config.common_ports) router_self_proxy=$(uci -q get openclash.config.router_self_proxy) @@ -80,15 +93,6 @@ ts_re() fi } -ipk_v() -{ - if [ -x "/bin/opkg" ]; then - echo $(opkg status "$1" 2>/dev/null |grep 'Version' |awk -F ': ' '{print $2}' 2>/dev/null) - elif [ -x "/usr/bin/apk" ]; then - echo $(apk list "$1" |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) - fi -} - dns_re() { if [ "$1" = "1" ]; then diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index 16496085ee..2e67b9f476 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -30,7 +30,7 @@ LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |sed "s/^v//g" |tr -d "\n") if [ -x "/bin/opkg" ]; then OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) elif [ -x "/usr/bin/apk" ]; then - OP_CV=$(apk list luci-app-openclash |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) + OP_CV=$(apk list luci-app-openclash 2>/dev/null |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1apk list luci-app-openclash 2>/dev/null|grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1 |awk -F '.' '{print $2$3}' 2>/dev/null) fi OP_LV=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") @@ -156,10 +156,10 @@ if [ -x "/bin/opkg" ]; then SLOG_CLEAN fi elif [ -x "/usr/bin/apk" ]; then - if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash |grep 'installed')" ]; then + if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash 2>/dev/null |grep 'installed')" ]; then apk add --allow-untrusted /tmp/openclash.apk fi - if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash |grep 'installed')" ]; then + if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash 2>/dev/null |grep 'installed')" ]; then rm -rf /tmp/openclash.apk >/dev/null 2>&1 LOG_OUT "OpenClash Update Successful, About To Restart!" uci -q set openclash.config.enable=1 diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh index 028b166121..dfff174167 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh @@ -7,7 +7,7 @@ RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") if [ -x "/bin/opkg" ]; then OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) elif [ -x "/usr/bin/apk" ]; then - OP_CV=$(apk list luci-app-openclash |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) + OP_CV=$(apk list luci-app-openclash 2>/dev/null|grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1 |awk -F '.' '{print $2$3}' 2>/dev/null) fi OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0) diff --git a/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg b/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg index f8cfa888e3..0a2dd4f544 100644 --- a/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg +++ b/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg @@ -1 +1 @@ -Current Version: v0.00.00Current Versionv0.00.00 \ No newline at end of file +Current Version: v0.00.00Current Versionv0.00.00 \ No newline at end of file From bb79940655b546074fc4b2b1c7a55bd38c787ee6 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:37:29 +0800 Subject: [PATCH 09/53] 0.46.051 --- luci-app-openclash/Makefile | 2 +- luci-app-openclash/root/etc/init.d/openclash | 3 ++- .../root/usr/share/openclash/openclash_update.sh | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index ff104cd5e3..ac5768186b 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.050 +PKG_VERSION:=0.46.051 PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index 24a0931ff6..cee99caf17 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -2933,7 +2933,7 @@ start() enable=$(uci -q get openclash.config.enable) [ "$enable" != "1" ] && LOG_OUT "Warning: OpenClash Now Disabled, Need Start From Luci Page, Exit..." && SLOG_CLEAN && del_lock && exit 0 - + service openclash enable LOG_OUT "OpenClash Start Running..." config_choose @@ -3028,6 +3028,7 @@ stop() LOG_OUT "Step 6: Delete OpenClash Residue File..." if [ "$enable" != "1" ]; then + service openclash disable rm -rf /tmp/clash_last_version >/dev/null 2>&1 rm -rf /tmp/Proxy_Group >/dev/null 2>&1 rm -rf /tmp/rules_name >/dev/null 2>&1 diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index 2e67b9f476..fdc9e7e01f 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -132,8 +132,6 @@ uci -q set openclash.config.enable=0 uci -q commit openclash if [ -x "/bin/opkg" ]; then opkg remove --force-depends --force-remove luci-app-openclash -elif [ -x "/usr/bin/apk" ]; then - apk del luci-app-openclash fi LOG_OUT "Installing The New Version, Please Do Not Refresh The Page or Do Other Operations..." if [ -x "/bin/opkg" ]; then From 0f6313f99da9963d443ea0bdb37a2094eed6aee1 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:48:36 +0800 Subject: [PATCH 10/53] fix typo --- luci-app-openclash/Makefile | 2 +- .../root/usr/share/openclash/openclash_update.sh | 4 ++-- .../root/usr/share/openclash/openclash_version.sh | 2 +- .../root/www/luci-static/resources/openclash/img/version.svg | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index ac5768186b..d13c2de773 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -56,7 +56,7 @@ define Build/Prepare $(CP) $(CURDIR)/luasrc $(PKG_BUILD_DIR) $(foreach po,$(wildcard ${CURDIR}/po/zh-cn/*.po), \ po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));) - sed -i "s/v0.00.00-beta/v$(PKG_VERSION)-beta/g" $(PKG_BUILD_DIR)/root/www/luci-static/resources/openclash/img/version.svg >/dev/null 2>&1 + sed -i "s/v0.00.00/v$(PKG_VERSION)/g" $(PKG_BUILD_DIR)/root/www/luci-static/resources/openclash/img/version.svg >/dev/null 2>&1 chmod 0755 $(PKG_BUILD_DIR)/root/etc/init.d/openclash chmod -R 0755 $(PKG_BUILD_DIR)/root/usr/share/openclash/ mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/config diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index fdc9e7e01f..b2fef6fecf 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -30,7 +30,7 @@ LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |sed "s/^v//g" |tr -d "\n") if [ -x "/bin/opkg" ]; then OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) elif [ -x "/usr/bin/apk" ]; then - OP_CV=$(apk list luci-app-openclash 2>/dev/null |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1apk list luci-app-openclash 2>/dev/null|grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1 |awk -F '.' '{print $2$3}' 2>/dev/null) + OP_CV=$(apk list luci-app-openclash 2>/dev/null |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1 |awk -F '.' '{print $2$3}' 2>/dev/null) fi OP_LV=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") @@ -127,10 +127,10 @@ SLOG_CLEAN() echo "" > $START_LOG } -LOG_OUT "Uninstalling The Old Version, Please Do not Refresh The Page or Do Other Operations..." uci -q set openclash.config.enable=0 uci -q commit openclash if [ -x "/bin/opkg" ]; then + LOG_OUT "Uninstalling The Old Version, Please Do not Refresh The Page or Do Other Operations..." opkg remove --force-depends --force-remove luci-app-openclash fi LOG_OUT "Installing The New Version, Please Do Not Refresh The Page or Do Other Operations..." diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh index dfff174167..ad2175e3ad 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh @@ -30,7 +30,7 @@ if [ "$TIME" != "$CHTIME" ]; then fi if [ "${PIPESTATUS[0]}" -eq 0 ] && [ -z "$(cat $LAST_OPVER |grep '')" ]; then - OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) + OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) if [ "$(expr "$OP_CV" \>= "$OP_LV")" = "1" ]; then sed -i '/^https:/,$d' $LAST_OPVER elif [ "$(expr "$OP_LV" \> "$OP_CV")" = "1" ] && [ -n "$OP_LV" ]; then diff --git a/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg b/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg index 0a2dd4f544..a245a36be4 100644 --- a/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg +++ b/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg @@ -1 +1 @@ -Current Version: v0.00.00Current Versionv0.00.00 \ No newline at end of file +Current Version: v0.00.00Current Versionv0.00.00 \ No newline at end of file From 74079f61e9f5e84c0e8820a946aa2d0dced8bc9b Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:50:13 +0800 Subject: [PATCH 11/53] 0.46.052 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index d13c2de773..25bb39d1f5 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.051 +PKG_VERSION:=0.46.052 PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) From ce0ef71d64819d1b933e31109d8889d7dc51d980 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 20 Nov 2024 21:37:31 +0800 Subject: [PATCH 12/53] chore: refine --- luci-app-openclash/Makefile | 1 + .../root/usr/share/openclash/openclash_core.sh | 2 ++ .../root/usr/share/openclash/openclash_update.sh | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 25bb39d1f5..5cb3695e3c 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -112,6 +112,7 @@ define Package/$(PKG_NAME)/prerm #!/bin/sh uci -q set openclash.config.enable=0 uci -q commit openclash + [ -n "$(pidof clash)" ] && /etc/init.d/openclash stop 2>/dev/null cp -f "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1 cp -rf "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1 cp -rf "/usr/share/openclash/ui/yacd" "/tmp/openclash_yacd" >/dev/null 2>&1 diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh index 1a2be0b103..ef35ed9a9e 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh @@ -90,6 +90,8 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then uci -q set openclash.config.config_reload=1 uci -q commit openclash if ([ -z "$2" ] || ([ -n "$2" ] && [ "$2" != "one_key_update" ])) && [ "$(find /tmp/lock/ |grep -v "openclash.lock" |grep -c "openclash")" -le 1 ] && [ "$(unify_ps_prevent)" -eq 0 ]; then + uci -q set openclash.config.config_reload=0 + uci -q commit openclash /etc/init.d/openclash restart >/dev/null 2>&1 & fi else diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index b2fef6fecf..8f93705f4a 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -98,6 +98,8 @@ if [ -n "$OP_CV" ] && [ -n "$OP_LV" ] && [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 if [ -z "$(opkg install /tmp/openclash.ipk --noaction 2>/dev/null |grep 'Upgrading luci-app-openclash on root' 2>/dev/null)" ]; then LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then + uci -q set openclash.config.config_reload=0 + uci -q commit openclash /etc/init.d/openclash restart >/dev/null 2>&1 & else SLOG_CLEAN @@ -178,6 +180,8 @@ EOF rm -rf /tmp/openclash.ipk >/dev/null 2>&1 rm -rf /tmp/openclash.apk >/dev/null 2>&1 if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then + uci -q set openclash.config.config_reload=0 + uci -q commit openclash /etc/init.d/openclash restart >/dev/null 2>&1 & else SLOG_CLEAN @@ -190,6 +194,8 @@ else LOG_OUT "OpenClash Has not Been Updated, Stop Continuing!" fi if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then + uci -q set openclash.config.config_reload=0 + uci -q commit openclash /etc/init.d/openclash restart >/dev/null 2>&1 & else SLOG_CLEAN From a94a901326c77f176aea701ecd925c95f5d3d0f5 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:27:22 +0800 Subject: [PATCH 13/53] chore: add some demo for overwrite --- .../custom/openclash_custom_overwrite.sh | 21 ++++++++++++++++-- .../root/usr/share/openclash/ruby.sh | 22 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/luci-app-openclash/root/etc/openclash/custom/openclash_custom_overwrite.sh b/luci-app-openclash/root/etc/openclash/custom/openclash_custom_overwrite.sh index 9293e3b2b2..1e4f001efc 100644 --- a/luci-app-openclash/root/etc/openclash/custom/openclash_custom_overwrite.sh +++ b/luci-app-openclash/root/etc/openclash/custom/openclash_custom_overwrite.sh @@ -9,9 +9,10 @@ LOG_OUT "Tip: Start Running Custom Overwrite Scripts..." LOGTIME=$(echo $(date "+%Y-%m-%d %H:%M:%S")) LOG_FILE="/tmp/openclash.log" -CONFIG_FILE="$1" #config path +#Config Path +CONFIG_FILE="$1" -#Simple Demo: + #Simple Demo: #Key Overwrite Demo #1--config path #2--key name @@ -28,6 +29,13 @@ CONFIG_FILE="$1" #config path #ruby_edit "$CONFIG_FILE" "['dns']['nameserver-policy']" "{'+.msftconnecttest.com'=>'114.114.114.114', '+.msftncsi.com'=>'114.114.114.114', 'geosite:gfw'=>['https://dns.cloudflare.com/dns-query', 'https://dns.google/dns-query#ecs=1.1.1.1/24&ecs-override=true'], 'geosite:cn'=>['114.114.114.114'], 'geosite:geolocation-!cn'=>['https://dns.cloudflare.com/dns-query', 'https://dns.google/dns-query#ecs=1.1.1.1/24&ecs-override=true']}" #ruby_edit "$CONFIG_FILE" "['sniffer']" "{'enable'=>true, 'parse-pure-ip'=>true, 'force-domain'=>['+.netflix.com', '+.nflxvideo.net', '+.amazonaws.com', '+.media.dssott.com'], 'skip-domain'=>['+.apple.com', 'Mijia Cloud', 'dlg.io.mi.com', '+.oray.com', '+.sunlogin.net'], 'sniff'=>{'TLS'=>nil, 'HTTP'=>{'ports'=>[80, '8080-8880'], 'override-destination'=>true}}}" + #Hash Merge Demo + #1--config path + #2--key name + #3--hash + #ruby_merge_hash "$CONFIG_FILE" "['proxy-providers']" "'TW'=>{'type'=>'http', 'path'=>'./proxy_provider/TW.yaml', 'url'=>'https://gist.githubusercontent.com/raw/tw_clash', 'interval'=>3600, 'health-check'=>{'enable'=>true, 'url'=>'http://cp.cloudflare.com/generate_204', 'interval'=>300}}" + #ruby_merge_hash "$CONFIG_FILE" "['rule-providers']" "'Reject'=>{'type'=>'http', 'behavior'=>'classical', 'url'=>'https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Reject.yaml', 'path'=>'./rule_provider/Reject', 'interval'=>86400}" + #Array Insert Value Demo: #1--config path #2--key name @@ -35,6 +43,15 @@ CONFIG_FILE="$1" #config path #4--value #ruby_arr_insert "$CONFIG_FILE" "['dns']['nameserver']" "0" "114.114.114.114" + #Array Insert Hash Demo: + #1--config path + #2--key name + #3--position(start from 0, end with -1) + #4--hash + #ruby_arr_insert_hash "$CONFIG_FILE" "['proxy-groups']" "0" "{'name'=>'Disney', 'type'=>'select', 'disable-udp'=>false, 'use'=>['TW', 'SG', 'HK']}" + #ruby_arr_insert_hash "$CONFIG_FILE" "['proxies']" "0" "{'name'=>'HKG 01', 'type'=>'ss', 'server'=>'cc.hd.abc', 'port'=>'12345', 'cipher'=>'aes-128-gcm', 'password'=>'123456', 'udp'=>true, 'plugin'=>'obfs', 'plugin-opts'=>{'mode'=>'http', 'host'=>'microsoft.com'}}" + #ruby_arr_insert_hash "$CONFIG_FILE" "['listeners']" "0" "{'name'=>'name', 'type'=>'shadowsocks', 'port'=>'12345', 'listen'=>'0.0.0.0', 'rule'=>'sub-rule-1', 'proxy'=>'proxy'}" + #Array Insert Other Array Demo: #1--config path #2--key name diff --git a/luci-app-openclash/root/usr/share/openclash/ruby.sh b/luci-app-openclash/root/usr/share/openclash/ruby.sh index 46037f987b..b21b3d14d4 100644 --- a/luci-app-openclash/root/usr/share/openclash/ruby.sh +++ b/luci-app-openclash/root/usr/share/openclash/ruby.sh @@ -67,6 +67,17 @@ RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); Value$2=Value$2.uniq; ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null } +#hash覆盖 +ruby_merge_hash() +{ +local Value Value_1 RUBY_YAML_PARSE +if [ -z "$1" ] || [ -z "$2" ]; then + return +fi +RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); Value$2.merge!($3); File.open('$1','w') {|f| YAML.dump(Value, f)}}.join" +ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null +} + #数组指定位置前添加一组值(不要key) ruby_arr_add_file() { @@ -100,6 +111,17 @@ RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); if not Value.key?($2) ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null } +#数组指定位置前增加Hash +ruby_arr_insert_hash() +{ +local Value RUBY_YAML_PARSE +if [ -z "$1" ] || [ -z "$2" ]; then + return +fi +RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); if not Value.key?($2) or Value$2.nil? then Value$2 = []; end; Value$2=Value$2.insert($3,$4).uniq; File.open('$1','w') {|f| YAML.dump(Value, f)}}.join" +ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null +} + #数组指定位置前增加数组 ruby_arr_insert_arr() { From 5408326b84f32023abfd1c60eabd84162f0d95a0 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:26:56 +0800 Subject: [PATCH 14/53] chore: update lhie1 rules --- .../model/cbi/openclash/other-rules-edit.lua | 11 +++++++++++ .../root/etc/uci-defaults/luci-openclash | 2 +- .../root/usr/share/openclash/res/lhie1.yaml | 18 +++++++++++++----- .../share/openclash/res/rule_providers.list | 3 ++- .../usr/share/openclash/yml_groups_name_ch.sh | 2 +- .../root/usr/share/openclash/yml_proxys_set.sh | 7 +++++++ .../usr/share/openclash/yml_rules_change.sh | 4 ++++ 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua b/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua index 0de1378e1d..ea5c5fe284 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua @@ -381,6 +381,17 @@ end o:value("DIRECT") o:value("REJECT") +o = s:option(ListValue, "HTTPDNS", translate("HTTPDNS")) +o:depends("rule_name", "lhie1") +o.rmempty = true +for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do + if groupname ~= nil and groupname ~= "" then + o:value(groupname) + end +end +o:value("DIRECT") +o:value("REJECT") + o = s:option(ListValue, "Domestic", translate("Domestic")) o:depends("rule_name", "lhie1") o.rmempty = true diff --git a/luci-app-openclash/root/etc/uci-defaults/luci-openclash b/luci-app-openclash/root/etc/uci-defaults/luci-openclash index a57fecca96..2164aec908 100644 --- a/luci-app-openclash/root/etc/uci-defaults/luci-openclash +++ b/luci-app-openclash/root/etc/uci-defaults/luci-openclash @@ -192,5 +192,5 @@ sed -i '/.*kB maximum content size*/c\export let HTTP_MAX_CONTENT = 1024*10240; /etc/init.d/uhttpd restart >/dev/null 2>&1 -rm -f /tmp/luci-indexcache +rm -f /tmp/luci-indexcache* >/dev/null 2>&1 exit 0 diff --git a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml index 52382efd52..e6d44e9fe2 100644 --- a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml +++ b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml @@ -1,5 +1,6 @@ rules: -- RULE-SET, Reject, AdBlock +- RULE-SET, AdBlock, AdBlock +- RULE-SET, HTTPDNS, HTTPDNS - RULE-SET, Special, DIRECT - RULE-SET, Netflix, Netflix - RULE-SET, Disney Plus, Disney @@ -65,7 +66,8 @@ script: code: | def main(ctx, metadata): ruleset_action = { - 'Reject': 'AdBlock', + 'AdBlock': 'AdBlock', + 'HTTPDNS': 'HTTPDNS', 'Special': 'DIRECT', 'Netflix': 'Netflix', 'Disney Plus': 'Disney', @@ -154,11 +156,17 @@ script: ctx.log('[Script] FINAL') return 'Others' rule-providers: - Reject: + AdBlock: type: http behavior: classical - url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Reject.yaml - path: "./Rules/Reject" + url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/AdBlock.yaml + path: "./Rules/AdBlock" + interval: 86400 + HTTPDNS: + type: http + behavior: classical + url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/HTTPDNS.yaml + path: "./Rules/HTTPDNS" interval: 86400 Special: type: http diff --git a/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list b/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list index 58dbbb1a5d..4aad222115 100644 --- a/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list +++ b/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list @@ -3,8 +3,9 @@ 国内IP白名单(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/,Domestic IPs.yaml 国内域名白名单(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/,Domestic.yaml 国外常用网站合集(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/,Proxy.yaml -广告规则(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/,Reject.yaml +广告规则(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/,AdBlock.yaml 微软服务,lhie1,classical,dler-io/Rules/master/Clash/Provider/,Microsoft.yaml +HTTPDNS(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/,HTTPDNS.yaml ABC,lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,ABC.yaml Abema TV,lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,Abema TV.yaml AbemaTV(By ACL4SSR),ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,AbemaTV.yaml,AbemaTV-ACL4SSR.yaml diff --git a/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh b/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh index b12b54c907..3ddaae00ba 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh @@ -47,7 +47,7 @@ cfg_groups_set() sed -i "s/new_servers_group \'${convert_old_name_cfg}\'/new_servers_group \'${convert_name}\'/g" $CFG_FILE 2>/dev/null sed -i "s/relay_groups \'${convert_old_name_cfg}\'/relay_groups \'${convert_name}\'/g" $CFG_FILE 2>/dev/null #第三方规则处理 - OTHER_RULE_NAMES=("GlobalTV" "AsianTV" "Proxy" "Youtube" "Bilibili" "Bahamut" "HBOGo" "HBOMax" "Pornhub" "Apple" "GoogleFCM" "Scholar" "Microsoft" "Netflix" "Disney" "Spotify" "Steam" "Speedtest" "Telegram" "PayPal" "Netease_Music" "AdBlock" "Domestic" "Others" "miHoYo" "AI Suite" "AppleTV" "Crypto" "Discord") + OTHER_RULE_NAMES=("GlobalTV" "AsianTV" "Proxy" "Youtube" "Bilibili" "Bahamut" "HBOGo" "HBOMax" "Pornhub" "Apple" "GoogleFCM" "Scholar" "Microsoft" "Netflix" "Disney" "Spotify" "Steam" "Speedtest" "Telegram" "PayPal" "Netease_Music" "AdBlock" "Domestic" "Others" "miHoYo" "AI Suite" "AppleTV" "Crypto" "Discord" "HTTPDNS") for i in ${OTHER_RULE_NAMES[@]}; do sed -i "s/option ${i} \'${convert_old_name_cfg}\'/option ${i} \'${convert_name}\'/g" $CFG_FILE 2>/dev/null done 2>/dev/null diff --git a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh index f39cd882ca..16aec3aef3 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh @@ -1763,6 +1763,12 @@ cat >> "$SERVER_FILE" <<-EOF - REJECT - DIRECT - Proxy + - name: HTTPDNS + type: select + proxies: + - REJECT + - DIRECT + - Proxy EOF cat /tmp/Proxy_Server >> $SERVER_FILE 2>/dev/null if [ -f "/tmp/Proxy_Provider" ]; then @@ -1900,6 +1906,7 @@ ${uci_set}Spotify="Spotify" ${uci_set}Steam="Steam" ${uci_set}miHoYo="miHoYo" ${uci_set}AdBlock="AdBlock" +${uci_set}HTTPDNS="HTTPDNS" ${uci_set}Speedtest="Speedtest" ${uci_set}Telegram="Telegram" ${uci_set}Crypto="Crypto" diff --git a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index 45aafced87..bca63f6293 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -336,6 +336,7 @@ yml_other_set() .gsub(/,[\s]?Steam$/, ', $Steam#delete_') .gsub(/,[\s]?miHoYo$/, ', $miHoYo#delete_') .gsub(/,[\s]?AdBlock$/, ', $AdBlock#delete_') + .gsub(/,[\s]?HTTPDNS$/, ', $HTTPDNS#delete_') .gsub(/,[\s]?Speedtest$/, ', $Speedtest#delete_') .gsub(/,[\s]?Telegram$/, ', $Telegram#delete_') .gsub(/,[\s]?Crypto$/, ', $Crypto#delete_') @@ -368,6 +369,7 @@ yml_other_set() .gsub!(/: \'Steam\'/,': \'$Steam#delete_\'') .gsub!(/: \'miHoYo\'/,': \'$miHoYo#delete_\'') .gsub!(/: \'AdBlock\'/,': \'$AdBlock#delete_\'') + .gsub!(/: \'HTTPDNS\'/,': \'$HTTPDNS#delete_\'') .gsub!(/: \'Speedtest\'/,': \'$Speedtest#delete_\'') .gsub!(/: \'Telegram\'/,': \'$Telegram#delete_\'') .gsub!(/: \'Crypto\'/,': \'$Crypto#delete_\'') @@ -885,6 +887,7 @@ yml_other_rules_get() config_get "Spotify" "$section" "Spotify" "" config_get "Steam" "$section" "Steam" "" config_get "AdBlock" "$section" "AdBlock" "" + config_get "HTTPDNS" "$section" "HTTPDNS" "REJECT" config_get "Netease_Music" "$section" "Netease_Music" "" config_get "Speedtest" "$section" "Speedtest" "" config_get "Telegram" "$section" "Telegram" "" @@ -937,6 +940,7 @@ if [ "$1" != "0" ]; then || [ -z "$(grep -F "$Steam" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$miHoYo" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$AdBlock" /tmp/Proxy_Group)" ]\ + || [ -z "$(grep -F "$HTTPDNS" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$Speedtest" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$Telegram" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$Crypto" /tmp/Proxy_Group)" ]\ From 741cb43759551e2ea3683c2955597665d906159b Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:51:06 +0800 Subject: [PATCH 15/53] 0.46.053 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 5cb3695e3c..2f2fc55eec 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.052 +PKG_VERSION:=0.46.053 PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) From 28ad7827c0e3c0cddbf321d79e6975a963626854 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:42:28 +0800 Subject: [PATCH 16/53] chore: remove HBO Now and HBO GO Asia --- .../model/cbi/openclash/other-rules-edit.lua | 11 - .../luasrc/model/cbi/openclash/settings.lua | 58 +--- .../po/zh-cn/openclash.zh-cn.po | 12 - .../openclash/openclash_streaming_unlock.lua | 276 ++++++------------ .../usr/share/openclash/openclash_watchdog.sh | 10 - .../usr/share/openclash/yml_groups_name_ch.sh | 2 +- .../usr/share/openclash/yml_proxys_set.sh | 16 - .../usr/share/openclash/yml_rules_change.sh | 4 - 8 files changed, 88 insertions(+), 301 deletions(-) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua b/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua index ea5c5fe284..e223dcccb2 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua @@ -150,17 +150,6 @@ end o:value("DIRECT") o:value("REJECT") -o = s:option(ListValue, "HBOGo", translate("HBO Go")) -o:depends("rule_name", "lhie1") -o.rmempty = true -for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do - if groupname ~= nil and groupname ~= "" then - o:value(groupname) - end -end -o:value("DIRECT") -o:value("REJECT") - o = s:option(ListValue, "Pornhub", translate("Pornhub")) o:depends("rule_name", "lhie1") o.rmempty = true diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua index 675d991479..d69cdaf14a 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua @@ -496,28 +496,6 @@ o.template = "openclash/other_stream_option" o.value = "Amazon Prime Video" o:depends("stream_auto_select_prime_video", "1") ---HBO Now -o = s:taboption("stream_enhance", Flag, "stream_auto_select_hbo_now", font_red..translate("HBO Now")..font_off) -o.default = 0 -o:depends("stream_auto_select", "1") - -o = s:taboption("stream_enhance", Value, "stream_auto_select_group_key_hbo_now", translate("Group Filter")) -o.default = "HBO|HBONow|HBO Now" -o.placeholder = "HBO|HBONow|HBO Now" -o.description = translate("It Will Be Searched According To The Regex When Auto Search Group Fails") -o:depends("stream_auto_select_hbo_now", "1") - -o = s:taboption("stream_enhance", Value, "stream_auto_select_node_key_hbo_now", translate("Unlock Nodes Filter")) -o.default = "" -o.description = translate("It Will Be Selected Nodes According To The Regex") -o:depends("stream_auto_select_hbo_now", "1") - -o = s:taboption("stream_enhance", DummyValue, "HBO Now", translate("Manual Test")) -o.rawhtml = true -o.template = "openclash/other_stream_option" -o.value = "HBO Now" -o:depends("stream_auto_select_hbo_now", "1") - --HBO Max o = s:taboption("stream_enhance", Flag, "stream_auto_select_hbo_max", font_red..translate("HBO Max")..font_off) o.default = 0 @@ -552,40 +530,6 @@ o.template = "openclash/other_stream_option" o.value = "HBO Max" o:depends("stream_auto_select_hbo_max", "1") ---HBO GO Asia -o = s:taboption("stream_enhance", Flag, "stream_auto_select_hbo_go_asia", font_red..translate("HBO GO Asia")..font_off) -o.default = 0 -o:depends("stream_auto_select", "1") - -o = s:taboption("stream_enhance", Value, "stream_auto_select_group_key_hbo_go_asia", translate("Group Filter")) -o.default = "HBO|HBOGO|HBO GO" -o.placeholder = "HBO|HBOGO|HBO GO" -o.description = translate("It Will Be Searched According To The Regex When Auto Search Group Fails") -o:depends("stream_auto_select_hbo_go_asia", "1") - -o = s:taboption("stream_enhance", Value, "stream_auto_select_region_key_hbo_go_asia", translate("Unlock Region Filter")) -o.default = "" -o.placeholder = "HK|SG|TW" -o.description = translate("It Will Be Selected Region(Country Shortcode) According To The Regex") -o:depends("stream_auto_select_hbo_go_asia", "1") -function o.validate(self, value) - if value ~= m.uci:get("openclash", "config", "stream_auto_select_region_key_hbo_go_asia") then - fs.unlink("/tmp/openclash_HBO GO Asia_region") - end - return value -end - -o = s:taboption("stream_enhance", Value, "stream_auto_select_node_key_hbo_go_asia", translate("Unlock Nodes Filter")) -o.default = "" -o.description = translate("It Will Be Selected Nodes According To The Regex") -o:depends("stream_auto_select_hbo_go_asia", "1") - -o = s:taboption("stream_enhance", DummyValue, "HBO GO Asia", translate("Manual Test")) -o.rawhtml = true -o.template = "openclash/other_stream_option" -o.value = "HBO GO Asia" -o:depends("stream_auto_select_hbo_go_asia", "1") - --TVB Anywhere+ o = s:taboption("stream_enhance", Flag, "stream_auto_select_tvb_anywhere", font_red..translate("TVB Anywhere+")..font_off) o.default = 0 @@ -787,7 +731,7 @@ o:depends("stream_auto_select", "1") o = s:taboption("stream_enhance", Value, "stream_auto_select_group_key_openai", translate("Group Filter")) o.default = "OpenAI|ChatGPT" -o.placeholder = "OpenAI|ChatGPT" +o.placeholder = "OpenAI|ChatGPT|AI" o.description = translate("It Will Be Searched According To The Regex When Auto Search Group Fails") o:depends("stream_auto_select_openai", "1") diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index 8550816e81..4fbf926208 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -2487,15 +2487,9 @@ msgstr "提示:开始自动选择(检测)Netflix 解锁节点..." msgid "Tip: Start Auto Select Proxy For Disney Plus Unlock..." msgstr "提示:开始自动选择(检测)Disney Plus 解锁节点..." -msgid "Tip: Start Auto Select Proxy For HBO Now Unlock..." -msgstr "提示:开始自动选择(检测)HBO Now 解锁节点..." - msgid "Tip: Start Auto Select Proxy For HBO Max Unlock..." msgstr "提示:开始自动选择(检测)HBO Max 解锁节点..." -msgid "Tip: Start Auto Select Proxy For HBO GO Asia Unlock..." -msgstr "提示:开始自动选择(检测)HBO GO Asia 解锁节点..." - msgid "Tip: Start Auto Select Proxy For YouTube Premium Unlock..." msgstr "提示:开始自动选择(检测)YouTube Premium 解锁节点..." @@ -2529,15 +2523,9 @@ msgstr "Netflix 策略组:" msgid "Disney Plus Group:" msgstr "Disney Plus 策略组:" -msgid "HBO Now Group:" -msgstr "HBO Now 策略组:" - msgid "HBO Max Group:" msgstr "HBO Max 策略组:" -msgid "HBO GO Asia Group:" -msgstr "HBO GO Asia 策略组:" - msgid "TVB Anywhere+ Group:" msgstr "TVB Anywhere+ 策略组:" diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_streaming_unlock.lua b/luci-app-openclash/root/usr/share/openclash/openclash_streaming_unlock.lua index 9a37709d9b..7a3069e3f4 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_streaming_unlock.lua +++ b/luci-app-openclash/root/usr/share/openclash/openclash_streaming_unlock.lua @@ -8,7 +8,7 @@ local HTTP = require "luci.http" local UCI = require("luci.model.uci").cursor() local FS = require "luci.openclash" local JSON = require "luci.jsonc" -local UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36" +local UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" local class_type = type local type = arg[1] local all_test @@ -99,12 +99,8 @@ function unlock_auto_select() key_group = UCI:get("openclash", "config", "stream_auto_select_group_key_netflix") or "netflix|奈飞" elseif type == "Disney Plus" then key_group = UCI:get("openclash", "config", "stream_auto_select_group_key_disney") or "disney|迪士尼" - elseif type == "HBO Now" then - key_group = UCI:get("openclash", "config", "stream_auto_select_group_key_hbo_now") or "hbo|hbonow|hbo now" elseif type == "HBO Max" then key_group = UCI:get("openclash", "config", "stream_auto_select_group_key_hbo_max") or "hbo|hbomax|hbo max" - elseif type == "HBO GO Asia" then - key_group = UCI:get("openclash", "config", "stream_auto_select_group_key_hbo_go_asia") or "hbo|hbogo|hbo go" elseif type == "YouTube Premium" then key_group = UCI:get("openclash", "config", "stream_auto_select_group_key_ytb") or "youtobe|油管" elseif type == "TVB Anywhere+" then @@ -825,12 +821,8 @@ function nodes_filter(t, info) regex = UCI:get("openclash", "config", "stream_auto_select_node_key_netflix") or "" elseif type == "Disney Plus" then regex = UCI:get("openclash", "config", "stream_auto_select_node_key_disney") or "" - elseif type == "HBO Now" then - regex = UCI:get("openclash", "config", "stream_auto_select_node_key_hbo_now") or "" elseif type == "HBO Max" then regex = UCI:get("openclash", "config", "stream_auto_select_node_key_hbo_max") or "" - elseif type == "HBO GO Asia" then - regex = UCI:get("openclash", "config", "stream_auto_select_node_key_hbo_go_asia") or "" elseif type == "YouTube Premium" then regex = UCI:get("openclash", "config", "stream_auto_select_node_key_ytb") or "" elseif type == "TVB Anywhere+" then @@ -889,12 +881,8 @@ function proxy_unlock_test() region, old_region = netflix_unlock_test() elseif type == "Disney Plus" then region, old_region = disney_unlock_test() - elseif type == "HBO Now" then - region, old_region = hbo_now_unlock_test() elseif type == "HBO Max" then region, old_region = hbo_max_unlock_test() - elseif type == "HBO GO Asia" then - region, old_region = hbo_go_asia_unlock_test() elseif type == "YouTube Premium" then region, old_region = ytb_unlock_test() elseif type == "TVB Anywhere+" then @@ -924,16 +912,12 @@ function auto_get_policy_group(passwd, ip, port) SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://www.netflix.com &') elseif type == "Disney Plus" then SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://www.disneyplus.com &') - elseif type == "HBO Now" then - SYS.call('curl -s -m 5 --limit-rate 50B -o /dev/null https://play.hbonow.com/assets/fonts/Street2-Medium.ttf &') elseif type == "HBO Max" then - SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://www.hbomax.com &') - elseif type == "HBO GO Asia" then - SYS.call('curl -s -m 5 --limit-rate 50B -o /dev/null https://www.hbogoasia.sg/static/media/GothamLight.8566e233.ttf &') + SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://www.max.com &') elseif type == "YouTube Premium" then SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://m.youtube.com/premium &') elseif type == "TVB Anywhere+" then - SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://uapisfm.tvbanywhere.com.sg &') + SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://www.tvbanywhere.com/img/tvb/vip_purchase.png &') elseif type == "Amazon Prime Video" then SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://www.primevideo.com &') elseif type == "DAZN" then @@ -947,7 +931,7 @@ function auto_get_policy_group(passwd, ip, port) elseif type == "Google" then SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://timeline.google.com &') elseif type == "OpenAI" then - SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://chat.openai.com/ &') + SYS.call('curl -sL -m 5 --limit-rate 1k -o /dev/null https://chatgpt.com/ &') end os.execute("sleep 1") con = SYS.exec(string.format('curl -sL -m 5 --retry 2 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XGET http://%s:%s/connections', passwd, ip, port)) @@ -966,18 +950,8 @@ function auto_get_policy_group(passwd, ip, port) auto_get_group = con.connections[i].chains[#(con.connections[i].chains)] break end - elseif type == "HBO Now" then - if string.match(con.connections[i].metadata.host, "play%.hbonow%.com") then - auto_get_group = con.connections[i].chains[#(con.connections[i].chains)] - break - end elseif type == "HBO Max" then - if string.match(con.connections[i].metadata.host, "www%.hbomax%.com") then - auto_get_group = con.connections[i].chains[#(con.connections[i].chains)] - break - end - elseif type == "HBO GO Asia" then - if string.match(con.connections[i].metadata.host, "www%.hbogoasia%.sg") then + if string.match(con.connections[i].metadata.host, "www%.max%.com") then auto_get_group = con.connections[i].chains[#(con.connections[i].chains)] break end @@ -987,7 +961,7 @@ function auto_get_policy_group(passwd, ip, port) break end elseif type == "TVB Anywhere+" then - if string.match(con.connections[i].metadata.host, "uapisfm%.tvbanywhere%.com%.sg") then + if string.match(con.connections[i].metadata.host, "www%.tvbanywhere%.com") then auto_get_group = con.connections[i].chains[#(con.connections[i].chains)] break end @@ -1022,7 +996,7 @@ function auto_get_policy_group(passwd, ip, port) break end elseif type == "OpenAI" then - if string.match(con.connections[i].metadata.host, "chat%.openai%.com") then + if string.match(con.connections[i].metadata.host, "chatgpt%.com") then auto_get_group = con.connections[i].chains[#(con.connections[i].chains)] break end @@ -1264,104 +1238,38 @@ function disney_unlock_test() return end -function hbo_now_unlock_test() - status = 0 - local url = "https://play.hbonow.com/" - local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -o /dev/null -w %%{json} -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) - if data then - data = JSON.parse(data) - end - if data then - if data.http_code == 200 then - status = 1 - if string.find(data.url_effective,"play%.hbonow%.com") then - status = 2 - end - end - end - return -end - function hbo_max_unlock_test() status = 0 - local url = "https://www.hbomax.com/" - local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -o /dev/null -w %%{json} -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) + local url = "https://www.max.com/" + local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -w '_TAG_%%{http_code}_TAG_' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) local result = {} local region = "" local old_region = get_old_region() local old_regex = get_old_regex() local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_hbo_max") or "" - if data then - data = JSON.parse(data) - end - if data then - if data.http_code == 200 then - status = 1 - if not string.find(data.url_effective,"geo%-availability") then - status = 2 - string.gsub(data.url_effective, '[^/]+', function(w) table.insert(result, w) end) - if result[3] then - region = string.upper(string.match(result[3], "^%a+")) - end - if region then - if not datamatch(region, regex) then - status = 3 - elseif old_regex ~= regex and not all_test then - status = 2 - elseif old_region ~= "" and region ~= old_region and not all_test then - status = 4 - end - if status == 2 and not all_test and region ~= "" and region ~= old_region then - write_cache(type, "old_region", region) - end - if status == 2 and not all_test and regex ~= old_regex then - write_cache(type, "old_regex", regex) - end - end - return region, old_region - end - end - end - return -end - -function hbo_go_asia_unlock_test() - status = 0 - local url = "https://api2.hbogoasia.com/v1/geog?lang=undefined&version=0&bundleId=www.hbogoasia.com" - local httpcode = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -o /dev/null -w %%{http_code} -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) - local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_hbo_go_asia") or "" - local region = "" - local old_region = get_old_region() - local old_regex = get_old_regex() - if tonumber(httpcode) == 200 then + if data and tonumber(string.sub(string.match(data, "_TAG_%d+_TAG_"), 6, 8)) == 200 then status = 1 - local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) - if data then - data = JSON.parse(data) + for i in string.gmatch(data, "\"url\":\"/%a+/%a+\"") do + table.insert(result, string.sub(string.match(i, "/%a+/"), 2, -2)) end - if data then - if data.territory then + region = string.sub(string.match(data, "\"countryCode\":\"%a+\""), 16, -2) + if region and table_include(result, region) then + status = 2 + region = string.upper(region) + if not datamatch(region, regex) then + status = 3 + elseif old_regex ~= regex and not all_test then status = 2 - if data.country then - region = string.upper(data.country) - end - if region then - if not datamatch(region, regex) then - status = 3 - elseif old_regex ~= regex and not all_test then - status = 2 - elseif old_region ~= "" and region ~= old_region and not all_test then - status = 4 - end - if status == 2 and not all_test and region ~= "" and region ~= old_region then - write_cache(type, "old_region", region) - end - if status == 2 and not all_test and regex ~= old_regex then - write_cache(type, "old_regex", regex) - end - end - return region, old_region + elseif old_region ~= "" and region ~= old_region and not all_test then + status = 4 + end + if status == 2 and not all_test and region ~= "" and region ~= old_region then + write_cache(type, "old_region", region) + end + if status == 2 and not all_test and regex ~= old_regex then + write_cache(type, "old_regex", regex) end + return region, old_region end end return @@ -1370,15 +1278,14 @@ end function ytb_unlock_test() status = 0 local url = "https://m.youtube.com/premium" - local httpcode = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -o /dev/null -w %%{http_code} -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) local region = "" local old_region = get_old_region() local data, he_data local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_ytb") or "" local old_regex = get_old_regex() - if tonumber(httpcode) == 200 then + data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -w '_TAG_%%{http_code}_TAG_' -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' -b 'YSC=BiCUU3-5Gdk; CONSENT=YES+cb.20220301-11-p0.en+FX+700; GPS=1; VISITOR_INFO1_LIVE=4VwPMkB7W5A; PREF=tz=Asia.Shanghai; _gcl_au=1.1.1809531354.1646633279' %s", UA, url)) + if data and tonumber(string.sub(string.match(data, "_TAG_%d+_TAG_"), 6, 8)) == 200 then status = 1 - data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' -b 'YSC=BiCUU3-5Gdk; CONSENT=YES+cb.20220301-11-p0.en+FX+700; GPS=1; VISITOR_INFO1_LIVE=4VwPMkB7W5A; PREF=tz=Asia.Shanghai; _gcl_au=1.1.1809531354.1646633279' %s", UA, url)) if string.find(data,"www%.google%.cn") or string.find(data, "is not available in your country") then return end @@ -1414,17 +1321,14 @@ end function tvb_anywhere_unlock_test() status = 0 local url = "https://uapisfm.tvbanywhere.com.sg/geoip/check/platform/android" - local httpcode = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -o /dev/null -w %%{http_code} -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) local region = "" local old_region = get_old_region() local old_regex = get_old_regex() local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_tvb_anywhere") or "" - if tonumber(httpcode) == 200 then + local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -w '_TAG_%%{http_code}_TAG_' -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) + if data and tonumber(string.sub(string.match(data, "_TAG_%d+_TAG_"), 6, 8)) == 200 then status = 1 - local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) - if data then - data = JSON.parse(data) - end + data = JSON.parse(data) if data and data.allow_in_this_country then status = 2 if data.country then @@ -1453,33 +1357,30 @@ end function prime_video_unlock_test() status = 0 local url = "https://www.primevideo.com" - local httpcode = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -o /dev/null -w %%{http_code} -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) local region local old_region = get_old_region() local old_regex = get_old_regex() local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_prime_video") or "" - if tonumber(httpcode) == 200 then + local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -w '_TAG_%%{http_code}_TAG_' -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) + if data and tonumber(string.sub(string.match(data, "_TAG_%d+_TAG_"), 6, 8)) == 200 then status = 1 - local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) - if data then - region = string.sub(string.match(data, "\"currentTerritory\":\"%a+\""), 21, -2) - if region then + region = string.sub(string.match(data, "\"currentTerritory\":\"%a+\""), 21, -2) + if region then + status = 2 + if not datamatch(region, regex) then + status = 3 + elseif old_regex ~= regex and not all_test then status = 2 - if not datamatch(region, regex) then - status = 3 - elseif old_regex ~= regex and not all_test then - status = 2 - elseif old_region ~= "" and region ~= old_region and not all_test then - status = 4 - end - if status == 2 and not all_test and region ~= "" and region ~= old_region then - write_cache(type, "old_region", region) - end - if status == 2 and not all_test and regex ~= old_regex then - write_cache(type, "old_regex", regex) - end - return region, old_region + elseif old_region ~= "" and region ~= old_region and not all_test then + status = 4 + end + if status == 2 and not all_test and region ~= "" and region ~= old_region then + write_cache(type, "old_region", region) end + if status == 2 and not all_test and regex ~= old_regex then + write_cache(type, "old_regex", regex) + end + return region, old_region end end return @@ -1487,19 +1388,15 @@ end function dazn_unlock_test() status = 0 - local url = "https://www.dazn.com" - local url2 = "https://startup.core.indazn.com/misl/v5/Startup" - local httpcode = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -o /dev/null -w %%{http_code} -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) + local url = "https://startup.core.indazn.com/misl/v5/Startup" local region local old_region = get_old_region() local old_regex = get_old_regex() local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_dazn") or "" - if tonumber(httpcode) == 200 then + local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -w '_TAG_%%{http_code}_TAG_' -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' -X POST -d '{\"LandingPageKey\":\"generic\",\"Languages\":\"zh-CN,zh,en\",\"Platform\":\"web\",\"PlatformAttributes\":{},\"Manufacturer\":\"\",\"PromoCode\":\"\",\"Version\":\"2\"}' %s", UA, url)) + if data and tonumber(string.sub(string.match(data, "_TAG_%d+_TAG_"), 6, 8)) == 200 then status = 1 - local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' -X POST -d '{\"LandingPageKey\":\"generic\",\"Languages\":\"zh-CN,zh,en\",\"Platform\":\"web\",\"PlatformAttributes\":{},\"Manufacturer\":\"\",\"PromoCode\":\"\",\"Version\":\"2\"}' %s", UA, url2)) - if data then - data = JSON.parse(data) - end + data = JSON.parse(data) if data and data.Region and data.Region.isAllowed then status = 2 if data.Region.GeolocatedCountry then @@ -1532,13 +1429,11 @@ function paramount_plus_unlock_test() local old_region = get_old_region() local old_regex = get_old_regex() local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_paramount_plus") or "" - local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -o /dev/null -w %%{json} -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) - data = JSON.parse(data) - if data and tonumber(data.http_code) == 200 then + local data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -w '_TAG_%%{http_code}_TAG_%%{url_effective}_TAGS_' -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) + if data and tonumber(string.sub(string.match(data, "_TAG_%d+_TAG_"), 6, 8)) == 200 then status = 1 - if not string.find(data.url_effective, "intl") then + if not string.find(string.match(data, "_TAG_[^\n]+_TAGS_"), "intl") then status = 2 - data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' %s", UA, url)) region = string.upper(string.sub(string.match(data, "\"siteEdition\":\"%a+|%a+\""), 19, -2)) or string.upper(string.sub(string.match(data, "property: '%a+'"), 12, -2)) if region then if not datamatch(region, regex) then @@ -1599,9 +1494,9 @@ end function bilibili_unlock_test() status = 0 - local randsession = SYS.exec("cat /dev/urandom | head -n 32 | md5sum | head -c 32") + local randsession = SYS.exec("cat /dev/urandom 2>/dev/null | head -n 32 | md5sum | head -c 32") local region, httpcode, data, url - local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_bilibili") or "" + local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_bilibili") or "CN" local old_region = get_old_region() if regex == "HK/MO/TW" then url = string.format("https://api.bilibili.com/pgc/player/web/playurl?avid=18281381&cid=29892777&qn=0&type=&otype=json&ep_id=183799&fourk=1&fnver=0&fnval=16&session=%s&module=bangumi", randsession) @@ -1613,26 +1508,23 @@ function bilibili_unlock_test() url = string.format("https://api.bilibili.com/pgc/player/web/playurl?avid=82846771&qn=0&type=&otype=json&ep_id=307247&fourk=1&fnver=0&fnval=16&session=%s&module=bangumi", randsession) region = "CN" end - httpcode = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -o /dev/null -w %%{http_code} -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' '%s'", UA, url)) - if httpcode and tonumber(httpcode) == 200 then - data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' '%s'", UA, url)) - if data then - data = JSON.parse(data) - status = 1 - if data.code then - if data.code == 0 then - status = 2 - if old_region ~= "" and region ~= old_region and not all_test then - status = 4 - end - if status == 2 and not all_test and region ~= "" and region ~= old_region then - write_cache(type, "old_region", region) - end - if status == 2 and not all_test and regex ~= old_regex then - write_cache(type, "old_regex", regex) - end - return region, old_region + data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -w '_TAG_%%{http_code}_TAG_' -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' '%s'", UA, url)) + if data and tonumber(string.sub(string.match(data, "_TAG_%d+_TAG_"), 6, 8)) == 200 then + data = JSON.parse(data) + status = 1 + if data.code then + if data.code == 0 then + status = 2 + if old_region ~= "" and region ~= old_region and not all_test then + status = 4 end + if status == 2 and not all_test and region ~= "" and region ~= old_region then + write_cache(type, "old_region", region) + end + if status == 2 and not all_test and regex ~= old_regex then + write_cache(type, "old_regex", regex) + end + return region, old_region end end end @@ -1660,17 +1552,23 @@ end function openai_unlock_test() status = 0 - local url = "https://chat.openai.com/" + local url = "https://api.openai.com/compliance/cookie_requirements" + local url2 = "https://ios.chat.openai.com/" local region_url = "https://chat.openai.com/cdn-cgi/trace" + local UA_SEC_CH_UA = '"Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24"' local regex = UCI:get("openclash", "config", "stream_auto_select_region_key_openai") or "" local region = "" + local region_data local old_region = get_old_region() local old_regex = get_old_regex() - local data = SYS.exec(string.format("curl -sIL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' '%s'", UA, url)) - if data then - if string.find(data, "text/html") then + local data = SYS.exec(string.format("curl -sIL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'authority: api.openai.com' -H 'accept: */*' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer null' -H 'content-type: application/json' -H 'origin: https://platform.openai.com' -H 'referer: https://platform.openai.com/' -H 'sec-ch-ua: %s' -H 'sec-ch-ua-mobile: ?0' -H 'sec-ch-ua-platform: \"Windows\"' -H 'sec-fetch-dest: empty' -H 'sec-fetch-mode: cors' -H 'sec-fetch-site: same-site' -H 'User-Agent: %s' '%s'", UA_SEC_CH_UA, UA, url)) + local datas = SYS.exec(string.format("curl -sIL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'authority: ios.chat.openai.com' -H 'accept: */*;q=0.8,application/signed-exchange;v=b3;q=0.7' -H 'accept-language: en-US,en;q=0.9' -H 'sec-ch-ua: %s' -H 'sec-ch-ua-mobile: ?0' -H 'sec-ch-ua-platform: \"Windows\"' -H 'sec-fetch-dest: document' -H 'sec-fetch-mode: navigate' -H 'sec-fetch-site: none' -H 'sec-fetch-user: ?1' -H 'upgrade-insecure-requests: 1' -H 'User-Agent: %s' '%s'", UA_SEC_CH_UA, UA, url2)) + if data and datas then + if string.find(data, "unsupported_country") or string.find(datas, "VPN") then + status = 1 + else status = 2 - local region_data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' '%s'", UA, region_url)) + region_data = SYS.exec(string.format("curl -sL --connect-timeout 5 -m 5 --speed-time 5 --speed-limit 1 --retry 2 -H 'Accept-Language: en' -H 'Content-Type: application/json' -H 'User-Agent: %s' '%s'", UA, region_url)) if region_data and string.match(region_data, "loc=%a+") then region = string.upper(string.sub(string.match(region_data, "loc=%a+"), 5, -1)) end @@ -1689,8 +1587,6 @@ function openai_unlock_test() write_cache(type, "old_regex", regex) end end - else - status = 1 end return region, old_region end diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh b/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh index c7622c8364..4f687213b8 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh @@ -159,9 +159,7 @@ do stream_auto_select_interval_now=$(uci -q get openclash.config.stream_auto_select_interval || echo 30) stream_auto_select_netflix=$(uci -q get openclash.config.stream_auto_select_netflix || echo 0) stream_auto_select_disney=$(uci -q get openclash.config.stream_auto_select_disney || echo 0) - stream_auto_select_hbo_now=$(uci -q get openclash.config.stream_auto_select_hbo_now || echo 0) stream_auto_select_hbo_max=$(uci -q get openclash.config.stream_auto_select_hbo_max || echo 0) - stream_auto_select_hbo_go_asia=$(uci -q get openclash.config.stream_auto_select_hbo_go_asia || echo 0) stream_auto_select_tvb_anywhere=$(uci -q get openclash.config.stream_auto_select_tvb_anywhere || echo 0) stream_auto_select_prime_video=$(uci -q get openclash.config.stream_auto_select_prime_video || echo 0) stream_auto_select_ytb=$(uci -q get openclash.config.stream_auto_select_ytb || echo 0) @@ -381,18 +379,10 @@ fi LOG_OUT "Tip: Start Auto Select Proxy For Amazon Prime Video Unlock..." /usr/share/openclash/openclash_streaming_unlock.lua "Amazon Prime Video" >> $LOG_FILE fi - if [ "$stream_auto_select_hbo_now" -eq 1 ]; then - LOG_OUT "Tip: Start Auto Select Proxy For HBO Now Unlock..." - /usr/share/openclash/openclash_streaming_unlock.lua "HBO Now" >> $LOG_FILE - fi if [ "$stream_auto_select_hbo_max" -eq 1 ]; then LOG_OUT "Tip: Start Auto Select Proxy For HBO Max Unlock..." /usr/share/openclash/openclash_streaming_unlock.lua "HBO Max" >> $LOG_FILE fi - if [ "$stream_auto_select_hbo_go_asia" -eq 1 ]; then - LOG_OUT "Tip: Start Auto Select Proxy For HBO GO Asia Unlock..." - /usr/share/openclash/openclash_streaming_unlock.lua "HBO GO Asia" >> $LOG_FILE - fi if [ "$stream_auto_select_tvb_anywhere" -eq 1 ]; then LOG_OUT "Tip: Start Auto Select Proxy For TVB Anywhere+ Unlock..." /usr/share/openclash/openclash_streaming_unlock.lua "TVB Anywhere+" >> $LOG_FILE diff --git a/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh b/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh index 3ddaae00ba..a5d3478eea 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh @@ -47,7 +47,7 @@ cfg_groups_set() sed -i "s/new_servers_group \'${convert_old_name_cfg}\'/new_servers_group \'${convert_name}\'/g" $CFG_FILE 2>/dev/null sed -i "s/relay_groups \'${convert_old_name_cfg}\'/relay_groups \'${convert_name}\'/g" $CFG_FILE 2>/dev/null #第三方规则处理 - OTHER_RULE_NAMES=("GlobalTV" "AsianTV" "Proxy" "Youtube" "Bilibili" "Bahamut" "HBOGo" "HBOMax" "Pornhub" "Apple" "GoogleFCM" "Scholar" "Microsoft" "Netflix" "Disney" "Spotify" "Steam" "Speedtest" "Telegram" "PayPal" "Netease_Music" "AdBlock" "Domestic" "Others" "miHoYo" "AI Suite" "AppleTV" "Crypto" "Discord" "HTTPDNS") + OTHER_RULE_NAMES=("GlobalTV" "AsianTV" "Proxy" "Youtube" "Bilibili" "Bahamut" "HBOMax" "Pornhub" "Apple" "GoogleFCM" "Scholar" "Microsoft" "Netflix" "Disney" "Spotify" "Steam" "Speedtest" "Telegram" "PayPal" "Netease_Music" "AdBlock" "Domestic" "Others" "miHoYo" "AI Suite" "AppleTV" "Crypto" "Discord" "HTTPDNS") for i in ${OTHER_RULE_NAMES[@]}; do sed -i "s/option ${i} \'${convert_old_name_cfg}\'/option ${i} \'${convert_name}\'/g" $CFG_FILE 2>/dev/null done 2>/dev/null diff --git a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh index 16aec3aef3..306228d9e1 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh @@ -1615,20 +1615,6 @@ cat >> "$SERVER_FILE" <<-EOF EOF fi cat /tmp/Proxy_Provider >> $SERVER_FILE 2>/dev/null -cat >> "$SERVER_FILE" <<-EOF - - name: HBO Go - type: select - proxies: - - Global TV - - DIRECT -EOF -cat /tmp/Proxy_Server >> $SERVER_FILE 2>/dev/null -if [ -f "/tmp/Proxy_Provider" ]; then -cat >> "$SERVER_FILE" <<-EOF - use: -EOF -fi -cat /tmp/Proxy_Provider >> $SERVER_FILE 2>/dev/null cat >> "$SERVER_FILE" <<-EOF - name: Pornhub type: select @@ -1890,7 +1876,6 @@ ${uci_set}Youtube="Youtube" ${uci_set}Bilibili="Bilibili" ${uci_set}Bahamut="Bahamut" ${uci_set}HBOMax="HBO Max" -${uci_set}HBOGo="HBO Go" ${uci_set}Pornhub="Pornhub" ${uci_set}Apple="Apple" ${uci_set}AppleTV="Apple TV" @@ -1924,7 +1909,6 @@ ${uci_set}Others="Others" ${UCI_DEL_LIST}="Bilibili" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Bilibili" >/dev/null 2>&1 ${UCI_DEL_LIST}="Bahamut" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Bahamut" >/dev/null 2>&1 ${UCI_DEL_LIST}="HBO Max" >/dev/null 2>&1 && ${UCI_ADD_LIST}="HBO Max" >/dev/null 2>&1 - ${UCI_DEL_LIST}="HBO Go" >/dev/null 2>&1 && ${UCI_ADD_LIST}="HBO Go" >/dev/null 2>&1 ${UCI_DEL_LIST}="Pornhub" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Pornhub" >/dev/null 2>&1 ${UCI_DEL_LIST}="Asian TV" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Asian TV" >/dev/null 2>&1 ${UCI_DEL_LIST}="Global TV" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Global TV" >/dev/null 2>&1 diff --git a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index bca63f6293..b606da6a6d 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -318,7 +318,6 @@ yml_other_set() x.to_s.gsub(/,[\s]?Bilibili,[\s]?Asian TV$/, ', Bilibili, $Bilibili#delete_') .gsub(/,[\s]?Bahamut,[\s]?Global TV$/, ', Bahamut, $Bahamut#delete_') .gsub(/,[\s]?HBO Max,[\s]?Global TV$/, ', HBO Max, $HBOMax#delete_') - .gsub(/,[\s]?HBO Go,[\s]?Global TV$/, ', HBO Go, $HBOGo#delete_') .gsub(/,[\s]?Discovery Plus,[\s]?Global TV$/, ', Discovery Plus, $Discovery#delete_') .gsub(/,[\s]?DAZN,[\s]?Global TV$/, ', DAZN, $DAZN#delete_') .gsub(/,[\s]?Pornhub,[\s]?Global TV$/, ', Pornhub, $Pornhub#delete_') @@ -351,7 +350,6 @@ yml_other_set() Value['script']['code'].to_s.gsub!(/\'Bilibili\': \'Asian TV\'/,'\'Bilibili\': \'$Bilibili#delete_\'') .gsub!(/\'Bahamut\': \'Global TV\'/,'\'Bahamut\': \'$Bahamut#delete_\'') .gsub!(/\'HBO Max\': \'Global TV\'/,'\'HBO Max\': \'$HBOMax#delete_\'') - .gsub!(/\'HBO Go\': \'Global TV\'/,'\'HBO Go\': \'$HBOGo#delete_\'') .gsub!(/\'Discovery Plus\': \'Global TV\'/,'\'Discovery Plus\': \'$Discovery#delete_\'') .gsub!(/\'DAZN\': \'Global TV\'/,'\'DAZN\': \'$DAZN#delete_\'') .gsub!(/\'Pornhub\': \'Global TV\'/,'\'Pornhub\': \'$Pornhub#delete_\'') @@ -878,7 +876,6 @@ yml_other_rules_get() config_get "Bilibili" "$section" "Bilibili" "" config_get "Bahamut" "$section" "Bahamut" "" config_get "HBOMax" "$section" "HBOMax" "$GlobalTV" - config_get "HBOGo" "$section" "HBOGo" "$GlobalTV" config_get "Pornhub" "$section" "Pornhub" "" config_get "Apple" "$section" "Apple" "" config_get "Scholar" "$section" "Scholar" "" @@ -926,7 +923,6 @@ if [ "$1" != "0" ]; then || [ -z "$(grep -F "$Bilibili" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$Bahamut" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$HBOMax" /tmp/Proxy_Group)" ]\ - || [ -z "$(grep -F "$HBOGo" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$Pornhub" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$Apple" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$AppleTV" /tmp/Proxy_Group)" ]\ From 33f97468e6eb36c74bf64ca15ec30569bcbc0d92 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:51:25 +0800 Subject: [PATCH 17/53] fix #4187 --- luci-app-openclash/root/usr/share/openclash/ruby.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/luci-app-openclash/root/usr/share/openclash/ruby.sh b/luci-app-openclash/root/usr/share/openclash/ruby.sh index b21b3d14d4..7c81762e90 100644 --- a/luci-app-openclash/root/usr/share/openclash/ruby.sh +++ b/luci-app-openclash/root/usr/share/openclash/ruby.sh @@ -107,7 +107,7 @@ local Value RUBY_YAML_PARSE if [ -z "$1" ] || [ -z "$2" ]; then return fi -RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); if not Value.key?($2) or Value$2.nil? then Value$2 = []; end; Value$2=Value$2.insert($3,'$4').uniq; File.open('$1','w') {|f| YAML.dump(Value, f)}}.join" +RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); if not Value$2 or Value$2.nil? then Value$2 = []; end; Value$2=Value$2.insert($3,'$4').uniq; File.open('$1','w') {|f| YAML.dump(Value, f)}}.join" ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null } @@ -118,7 +118,7 @@ local Value RUBY_YAML_PARSE if [ -z "$1" ] || [ -z "$2" ]; then return fi -RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); if not Value.key?($2) or Value$2.nil? then Value$2 = []; end; Value$2=Value$2.insert($3,$4).uniq; File.open('$1','w') {|f| YAML.dump(Value, f)}}.join" +RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); if not Value$2 or Value$2.nil? then Value$2 = []; end; Value$2=Value$2.insert($3,$4).uniq; File.open('$1','w') {|f| YAML.dump(Value, f)}}.join" ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null } @@ -129,7 +129,7 @@ local Value RUBY_YAML_PARSE if [ -z "$1" ] || [ -z "$2" ]; then return fi -RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); if not Value.key?($2) or Value$2.nil? then Value$2 = []; end; ${4}.reverse.each{|x| Value$2=Value$2.insert($3,x).uniq}; File.open('$1','w') {|f| YAML.dump(Value, f)}}.join" +RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); if not Value$2 or Value$2.nil? then Value$2 = []; end; ${4}.reverse.each{|x| Value$2=Value$2.insert($3,x).uniq}; File.open('$1','w') {|f| YAML.dump(Value, f)}}.join" ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null } From 4ed6c4af220456a16cfc446d47800a4759a40522 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 23 Nov 2024 07:57:03 +0800 Subject: [PATCH 18/53] chore: refine --- .../root/usr/share/openclash/res/lhie1.yaml | 24 +++++++------------ .../share/openclash/res/rule_providers.list | 2 +- .../usr/share/openclash/yml_groups_name_ch.sh | 2 +- .../usr/share/openclash/yml_rules_change.sh | 4 ++-- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml index e6d44e9fe2..850330f3e1 100644 --- a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml +++ b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml @@ -25,8 +25,6 @@ rules: - RULE-SET, F1 TV, Global TV - RULE-SET, Fox Now, Global TV - RULE-SET, Fox+, Global TV -- RULE-SET, HBO Go, Global TV -- RULE-SET, HBO Max, Global TV - RULE-SET, Hulu Japan, Global TV - RULE-SET, Hulu, Global TV - RULE-SET, Japonx, Global TV @@ -34,6 +32,7 @@ rules: - RULE-SET, KKBOX, Global TV - RULE-SET, KKTV, Global TV - RULE-SET, Line TV, Global TV +- RULE-SET, Max, Global TV - RULE-SET, myTV SUPER, Global TV - RULE-SET, Niconico, Global TV - RULE-SET, Pandora, Global TV @@ -92,8 +91,6 @@ script: 'F1 TV': 'Global TV', 'Fox Now': 'Global TV', 'Fox+': 'Global TV', - 'HBO Go': 'Global TV', - 'HBO Max': 'Global TV', 'Hulu Japan': 'Global TV', 'Hulu': 'Global TV', 'Japonx': 'Global TV', @@ -101,6 +98,7 @@ script: 'KKBOX': 'Global TV', 'KKTV': 'Global TV', 'Line TV': 'Global TV', + 'Max': 'Global TV', 'myTV SUPER': 'Global TV', 'Niconico': 'Global TV', 'Pandora': 'Global TV', @@ -354,18 +352,6 @@ rule-providers: url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Media/Fox%2B.yaml path: "./Rules/Media/Fox+" interval: 86400 - HBO Go: - type: http - behavior: classical - url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Media/HBO%20Go.yaml - path: "./Rules/Media/HBO_Go" - interval: 86400 - HBO Max: - type: http - behavior: classical - url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Media/HBO%20Max.yaml - path: "./Rules/Media/HBO_Max" - interval: 86400 Hulu Japan: type: http behavior: classical @@ -408,6 +394,12 @@ rule-providers: url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Media/Line%20TV.yaml path: "./Rules/Media/Line_TV" interval: 86400 + Max: + type: http + behavior: classical + url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Media/Max.yaml + path: "./Rules/Media/Max" + interval: 86400 myTV SUPER: type: http behavior: classical diff --git a/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list b/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list index 4aad222115..c14184ccd7 100644 --- a/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list +++ b/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list @@ -47,7 +47,7 @@ Google,ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,Google. GoogleCN,ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,GoogleCN.yaml GoogleFCM,ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,GoogleFCM.yaml HBO(By ACL4SSR),ACL4SSR,classical,ACL4SSR/ACL4SSR/master/Clash/Providers/Ruleset/,HBO.yaml,HBO-ACL4SSR.yaml -HBO(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,HBO.yaml,HBO-lhie1.yaml +HBO MAX(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,MAX.yaml,MAX-lhie1.yaml Hulu Japan,lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,Hulu Japan.yaml Hulu(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,Hulu.yaml,Hulu-lhie1.yaml JOOX(By lhie1),lhie1,classical,dler-io/Rules/master/Clash/Provider/Media/,JOOX.yaml,JOOX-lhie1.yaml diff --git a/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh b/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh index a5d3478eea..f2aa46c12f 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh @@ -47,7 +47,7 @@ cfg_groups_set() sed -i "s/new_servers_group \'${convert_old_name_cfg}\'/new_servers_group \'${convert_name}\'/g" $CFG_FILE 2>/dev/null sed -i "s/relay_groups \'${convert_old_name_cfg}\'/relay_groups \'${convert_name}\'/g" $CFG_FILE 2>/dev/null #第三方规则处理 - OTHER_RULE_NAMES=("GlobalTV" "AsianTV" "Proxy" "Youtube" "Bilibili" "Bahamut" "HBOMax" "Pornhub" "Apple" "GoogleFCM" "Scholar" "Microsoft" "Netflix" "Disney" "Spotify" "Steam" "Speedtest" "Telegram" "PayPal" "Netease_Music" "AdBlock" "Domestic" "Others" "miHoYo" "AI Suite" "AppleTV" "Crypto" "Discord" "HTTPDNS") + OTHER_RULE_NAMES=("GlobalTV" "AsianTV" "Proxy" "Youtube" "Bilibili" "Bahamut" "HBOMax" "Pornhub" "Apple" "GoogleFCM" "Scholar" "Microsoft" "Netflix" "Disney" "Spotify" "Steam" "Speedtest" "Telegram" "PayPal" "Netease_Music" "AdBlock" "Domestic" "Others" "miHoYo" "AI_Suite" "AppleTV" "Crypto" "Discord" "HTTPDNS") for i in ${OTHER_RULE_NAMES[@]}; do sed -i "s/option ${i} \'${convert_old_name_cfg}\'/option ${i} \'${convert_name}\'/g" $CFG_FILE 2>/dev/null done 2>/dev/null diff --git a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index b606da6a6d..6b108a0429 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -317,7 +317,7 @@ yml_other_set() Value['rules'].to_a.collect!{|x| x.to_s.gsub(/,[\s]?Bilibili,[\s]?Asian TV$/, ', Bilibili, $Bilibili#delete_') .gsub(/,[\s]?Bahamut,[\s]?Global TV$/, ', Bahamut, $Bahamut#delete_') - .gsub(/,[\s]?HBO Max,[\s]?Global TV$/, ', HBO Max, $HBOMax#delete_') + .gsub(/,[\s]?Max,[\s]?Global TV$/, ', Max, $HBOMax#delete_') .gsub(/,[\s]?Discovery Plus,[\s]?Global TV$/, ', Discovery Plus, $Discovery#delete_') .gsub(/,[\s]?DAZN,[\s]?Global TV$/, ', DAZN, $DAZN#delete_') .gsub(/,[\s]?Pornhub,[\s]?Global TV$/, ', Pornhub, $Pornhub#delete_') @@ -349,7 +349,7 @@ yml_other_set() }; Value['script']['code'].to_s.gsub!(/\'Bilibili\': \'Asian TV\'/,'\'Bilibili\': \'$Bilibili#delete_\'') .gsub!(/\'Bahamut\': \'Global TV\'/,'\'Bahamut\': \'$Bahamut#delete_\'') - .gsub!(/\'HBO Max\': \'Global TV\'/,'\'HBO Max\': \'$HBOMax#delete_\'') + .gsub!(/\'Max\': \'Global TV\'/,'\'Max\': \'$HBOMax#delete_\'') .gsub!(/\'Discovery Plus\': \'Global TV\'/,'\'Discovery Plus\': \'$Discovery#delete_\'') .gsub!(/\'DAZN\': \'Global TV\'/,'\'DAZN\': \'$DAZN#delete_\'') .gsub!(/\'Pornhub\': \'Global TV\'/,'\'Pornhub\': \'$Pornhub#delete_\'') From c72115366b84060aa2dc3db2341130f6d9f8cf72 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 23 Nov 2024 08:32:55 +0800 Subject: [PATCH 19/53] 0.46.054 --- luci-app-openclash/Makefile | 2 +- luci-app-openclash/po/zh-cn/openclash.zh-cn.po | 3 +++ luci-app-openclash/root/usr/share/openclash/yml_change.sh | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 2f2fc55eec..71b182bf4c 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.053 +PKG_VERSION:=0.46.054 PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index 4fbf926208..0129146fc1 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -3422,3 +3422,6 @@ msgstr "全局" msgid "Direct" msgstr "直连" + +msgid "Error: Config File Overwrite Failed," +msgstr "错误:配置文件覆写失败," \ No newline at end of file diff --git a/luci-app-openclash/root/usr/share/openclash/yml_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_change.sh index a09f0ef098..9c749ab8e9 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_change.sh @@ -789,6 +789,8 @@ begin YAML.LOG('Tip: Respect-rules Option Need Proxy-server-nameserver Option Must Be Setted, Auto Set to【114.114.114.114, 119.29.29.29, 8.8.8.8, 1.1.1.1】'); end; end; +rescue Exception => e + YAML.LOG('Error: Config File Overwrite Failed,【' + e.message + '】'); ensure File.open('$5','w') {|f| YAML.dump(Value, f)}; end" 2>/dev/null >> $LOG_FILE \ No newline at end of file From 2a1e398d58bd4cf3cb71b646cbf4cd3b0f6388c9 Mon Sep 17 00:00:00 2001 From: pillarcoin <6373858+liangyi9812@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:35:08 +0800 Subject: [PATCH 20/53] fix: save file after ruby_delete() (#4196) --- luci-app-openclash/root/usr/share/openclash/ruby.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/root/usr/share/openclash/ruby.sh b/luci-app-openclash/root/usr/share/openclash/ruby.sh index 7c81762e90..02a5e81082 100644 --- a/luci-app-openclash/root/usr/share/openclash/ruby.sh +++ b/luci-app-openclash/root/usr/share/openclash/ruby.sh @@ -149,6 +149,6 @@ local Value RUBY_YAML_PARSE if [ -z "$1" ] || [ -z "$3" ]; then return fi -RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); Value$2.delete('$3')}.join" +RUBY_YAML_PARSE="Thread.new{Value = YAML.load_file('$1'); Value$2.delete('$3'); File.open('$1','w') {|f| YAML.dump(Value, f)}}.join" ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "$RUBY_YAML_PARSE" 2>/dev/null } From 892c7bdbab4ca4f69238acb000f65eb16de160da Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:18:45 +0800 Subject: [PATCH 21/53] chore: refine --- .../model/cbi/openclash/other-rules-edit.lua | 11 + .../po/zh-cn/openclash.zh-cn.po | 3 + .../root/usr/share/openclash/res/default.yaml | 1149 ++++++++++++++--- .../root/usr/share/openclash/res/lhie1.yaml | 182 +-- .../root/usr/share/openclash/yml_change.sh | 1 - .../usr/share/openclash/yml_groups_name_ch.sh | 2 +- .../usr/share/openclash/yml_proxys_set.sh | 18 +- .../usr/share/openclash/yml_rules_change.sh | 16 +- 8 files changed, 1046 insertions(+), 336 deletions(-) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua b/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua index e223dcccb2..1258bfc7e1 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua @@ -95,6 +95,17 @@ end o:value("DIRECT") o:value("REJECT") +o = s:option(ListValue, "CN Mainland TV", translate("CN Mainland TV")) +o:depends("rule_name", "lhie1") +o.rmempty = true +for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do + if groupname ~= nil and groupname ~= "" then + o:value(groupname) + end +end +o:value("DIRECT") +o:value("REJECT") + o = s:option(ListValue, "Proxy", translate("Proxy")) o:depends("rule_name", "lhie1") o.rmempty = true diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index 0129146fc1..2d452bfaad 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -518,6 +518,9 @@ msgstr "国际流媒体" msgid "AsianTV" msgstr "亚洲流媒体" +msgid "CN Mainland TV" +msgstr "大陆流媒体" + msgid "Proxy" msgstr "必须代理的流量" diff --git a/luci-app-openclash/root/usr/share/openclash/res/default.yaml b/luci-app-openclash/root/usr/share/openclash/res/default.yaml index 834f33f901..57010d4616 100644 --- a/luci-app-openclash/root/usr/share/openclash/res/default.yaml +++ b/luci-app-openclash/root/usr/share/openclash/res/default.yaml @@ -1,170 +1,386 @@ -# 官方配置模板:https://github.com/Dreamacro/clash/wiki/Configuration -# Meta配置模板:https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/docs/config.yaml -# 接管:部分参数不支持在此页面直接修改,请到全局设置页面进行修改 +# Meta配置模板:https://github.com/MetaCubeX/mihomo/blob/Alpha/docs/config.yaml +# 接管:部分参数不支持在此页面直接修改,请到覆写设置页面进行修改 -# Port of HTTP(S) proxy server on the local end -port: 7890 +# port: 7890 # HTTP(S) 代理服务器端口 +# socks-port: 7891 # SOCKS5 代理端口 +mixed-port: 10801 # HTTP(S) 和 SOCKS 代理混合端口 +# redir-port: 7892 # 透明代理端口,用于 Linux 和 MacOS -# Port of SOCKS5 proxy server on the local end -socks-port: 7891 +# Transparent proxy server port for Linux (TProxy TCP and TProxy UDP) +# tproxy-port: 7893 -# Transparent proxy server port for Linux and macOS (Redirect TCP and TProxy UDP) -redir-port: 7892 +allow-lan: true # 允许局域网连接 +bind-address: "*" # 绑定 IP 地址,仅作用于 allow-lan 为 true,'*'表示所有地址 +authentication: # http,socks 入口的验证用户名,密码 + - "username:password" +skip-auth-prefixes: # 设置跳过验证的 IP 段 + - 127.0.0.1/8 + - ::1/128 +lan-allowed-ips: # 允许连接的 IP 地址段,仅作用于 allow-lan 为 true, 默认值为 0.0.0.0/0 和::/0 + - 0.0.0.0/0 + - ::/0 +lan-disallowed-ips: # 禁止连接的 IP 地址段,黑名单优先级高于白名单,默认值为空 + - 192.168.0.3/32 + +# find-process-mode has 3 values:always, strict, off +# - always, 开启,强制匹配所有进程 +# - strict, 默认,由 mihomo 判断是否开启 +# - off, 不匹配进程,推荐在路由器上使用此模式 +find-process-mode: strict -# Transparent proxy server port for Linux (TProxy TCP and TProxy UDP) -tproxy-port: 7893 - -# HTTP(S) and SOCKS4(A)/SOCKS5 server on the same port -mixed-port: 7893 - -# authentication of local SOCKS5/HTTP(S) server -# authentication: -# - "user1:pass1" -# - "user2:pass2" - -# Set to true to allow connections to the local-end server from -# other LAN IP addresses -allow-lan: true - -# This is only applicable when `allow-lan` is `true` -# '*': bind all IP addresses -# 192.168.122.11: bind a single IPv4 address -# "[aaaa::a8aa:ff:fe09:57d8]": bind a single IPv6 address -bind-address: '*' - -# Clash router working mode -# rule: rule-based packet routing -# global: all packets will be forwarded to a single endpoint -# direct: directly forward the packets to the Internet mode: rule -# Clash by default prints logs to STDOUT -# info / warning / error / debug / silent -# log-level: info +#自定义 geodata url +geox-url: + geoip: "https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.dat" + geosite: "https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.dat" + mmdb: "https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.metadb" -# When set to false, resolver won't translate hostnames to IPv6 addresses -# ipv6: false +geo-auto-update: false # 是否自动更新 geodata +geo-update-interval: 24 # 更新间隔,单位:小时 -# RESTful web API listening address -external-controller: 127.0.0.1:9090 +# Matcher implementation used by GeoSite, available implementations: +# - succinct (default, same as rule-set) +# - mph (from V2Ray, also `hybrid` in Xray) +# geosite-matcher: succinct -# A relative path to the configuration directory or an absolute path to a -# directory in which you put some static web resource. Clash core will then -# serve it at `http://{{external-controller}}/ui`. -# external-ui: folder +log-level: debug # 日志等级 silent/error/warning/info/debug -# Secret for the RESTful API (optional) -# Authenticate by spedifying HTTP header `Authorization: Bearer ${secret}` -# ALWAYS set a secret if RESTful API is listening on 0.0.0.0 -# secret: "" +ipv6: true # 开启 IPv6 总开关,关闭阻断所有 IPv6 链接和屏蔽 DNS 请求 AAAA 记录 -# Outbound interface name -# interface-name: en0 +tls: + certificate: string # 证书 PEM 格式,或者 证书的路径 + private-key: string # 证书对应的私钥 PEM 格式,或者私钥路径 + custom-certifactes: + - | + -----BEGIN CERTIFICATE----- + format/pem... + -----END CERTIFICATE----- -# fwmark on Linux only -# routing-mark: 6666 +external-controller: 0.0.0.0:9093 # RESTful API 监听地址 +external-controller-tls: 0.0.0.0:9443 # RESTful API HTTPS 监听地址,需要配置 tls 部分配置文件 +# secret: "123456" # `Authorization:Bearer ${secret}` -# Static hosts for DNS server and connection establishment (like /etc/hosts) -# -# Wildcard hostnames are supported (e.g. *.clash.dev, *.foo.*.example.com) -# Non-wildcard domain names have a higher priority than wildcard domain names -# e.g. foo.example.com > *.example.com > .example.com -# P.S. +.foo.com equals to .foo.com and foo.com +# RESTful API CORS标头配置 +external-controller-cors: + allow-origins: + - * + allow-private-network: true + +# RESTful API Unix socket 监听地址( windows版本大于17063也可以使用,即大于等于1803/RS4版本即可使用 ) +# !!!注意: 从Unix socket访问api接口不会验证secret, 如果开启请自行保证安全问题 !!! +# 测试方法: curl -v --unix-socket "mihomo.sock" http://localhost/ +external-controller-unix: mihomo.sock + +# RESTful API Windows namedpipe 监听地址 +# !!!注意: 从Windows namedpipe访问api接口不会验证secret, 如果开启请自行保证安全问题 !!! +external-controller-pipe: \\.\pipe\mihomo + +# tcp-concurrent: true # TCP 并发连接所有 IP, 将使用最快握手的 TCP + +# 配置 WEB UI 目录,使用 http://{{external-controller}}/ui 访问 +external-ui: /path/to/ui/folder/ +external-ui-name: xd +external-ui-url: "https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip" + +# 在RESTful API端口上开启DOH服务器 +# !!!该URL不会验证secret, 如果开启请自行保证安全问题 !!! +external-doh-server: /dns-query + +# interface-name: en0 # 设置出口网卡 + +# 全局 TLS 指纹,优先低于 proxy 内的 client-fingerprint +# 可选: "chrome","firefox","safari","ios","random","none" options. +# Utls is currently support TLS transport in TCP/grpc/WS/HTTP for VLESS/Vmess and trojan. +global-client-fingerprint: chrome + +# TCP keep alive interval +# disable-keep-alive: false #目前在android端强制为true +# keep-alive-idle: 15 +# keep-alive-interval: 15 + +# routing-mark:6666 # 配置 fwmark 仅用于 Linux +experimental: + # Disable quic-go GSO support. This may result in reduced performance on Linux. + # This is not recommended for most users. + # Only users encountering issues with quic-go's internal implementation should enable this, + # and they should disable it as soon as the issue is resolved. + # This field will be removed when quic-go fixes all their issues in GSO. + # This equivalent to the environment variable QUIC_GO_DISABLE_GSO=1. + #quic-go-disable-gso: true + +# 类似于 /etc/hosts, 仅支持配置单个 IP hosts: - # '*.clash.dev': 127.0.0.1 - # '.dev': 127.0.0.1 - # 'alpha.clash.dev': '::1' +# '*.mihomo.dev': 127.0.0.1 +# '.dev': 127.0.0.1 +# 'alpha.mihomo.dev': '::1' +# test.com: [1.1.1.1, 2.2.2.2] +# home.lan: lan # lan 为特别字段,将加入本地所有网卡的地址 +# baidu.com: google.com # 只允许配置一个别名 -profile: - # Store the `select` results in $HOME/.config/clash/.cache - # set false If you don't want this behavior - # when two different configurations have groups with the same name, the selected values are shared - store-selected: true +profile: # 存储 select 选择记录 + store-selected: false - # persistence fakeip + # 持久化 fake-ip store-fake-ip: true -# DNS server settings -# This section is optional. When not present, the DNS server will be disabled. -dns: - enable: true - listen: 0.0.0.0:53 - # ipv6: false # when the false, response to AAAA questions will be empty +# Tun 配置 +tun: + enable: false + stack: system # gvisor/mixed + dns-hijack: + - 0.0.0.0:53 # 需要劫持的 DNS + # auto-detect-interface: true # 自动识别出口网卡 + # auto-route: true # 配置路由表 + # mtu: 9000 # 最大传输单元 + # gso: false # 启用通用分段卸载,仅支持 Linux + # gso-max-size: 65536 # 通用分段卸载包的最大大小 + auto-redirect: false # 自动配置 iptables 以重定向 TCP 连接。仅支持 Linux。带有 auto-redirect 的 auto-route 现在可以在路由器上按预期工作,无需干预。 + # strict-route: true # 将所有连接路由到 tun 来防止泄漏,但你的设备将无法其他设备被访问 + route-address-set: # 将指定规则集中的目标 IP CIDR 规则添加到防火墙, 不匹配的流量将绕过路由, 仅支持 Linux,且需要 nftables,`auto-route` 和 `auto-redirect` 已启用。 + - ruleset-1 + - ruleset-2 + route-exclude-address-set: # 将指定规则集中的目标 IP CIDR 规则添加到防火墙, 匹配的流量将绕过路由, 仅支持 Linux,且需要 nftables,`auto-route` 和 `auto-redirect` 已启用。 + - ruleset-3 + - ruleset-4 + route-address: # 启用 auto-route 时使用自定义路由而不是默认路由 + - 0.0.0.0/1 + - 128.0.0.0/1 + - "::/1" + - "8000::/1" + # inet4-route-address: # 启用 auto-route 时使用自定义路由而不是默认路由(旧写法) + # - 0.0.0.0/1 + # - 128.0.0.0/1 + # inet6-route-address: # 启用 auto-route 时使用自定义路由而不是默认路由(旧写法) + # - "::/1" + # - "8000::/1" + # endpoint-independent-nat: false # 启用独立于端点的 NAT + # include-interface: # 限制被路由的接口。默认不限制,与 `exclude-interface` 冲突 + # - "lan0" + # exclude-interface: # 排除路由的接口,与 `include-interface` 冲突 + # - "lan1" + # include-uid: # UID 规则仅在 Linux 下被支持,并且需要 auto-route + # - 0 + # include-uid-range: # 限制被路由的的用户范围 + # - 1000:9999 + # exclude-uid: # 排除路由的的用户 + #- 1000 + # exclude-uid-range: # 排除路由的的用户范围 + # - 1000:9999 + + # Android 用户和应用规则仅在 Android 下被支持 + # 并且需要 auto-route + + # include-android-user: # 限制被路由的 Android 用户 + # - 0 + # - 10 + # include-package: # 限制被路由的 Android 应用包名 + # - com.android.chrome + # exclude-package: # 排除被路由的 Android 应用包名 + # - com.android.captiveportallogin + +# 嗅探域名 可选配置 +sniffer: + enable: false + ## 对 redir-host 类型识别的流量进行强制嗅探 + ## 如:Tun、Redir 和 TProxy 并 DNS 为 redir-host 皆属于 + # force-dns-mapping: false + ## 对所有未获取到域名的流量进行强制嗅探 + # parse-pure-ip: false + # 是否使用嗅探结果作为实际访问,默认 true + # 全局配置,优先级低于 sniffer.sniff 实际配置 + override-destination: false + sniff: # TLS 和 QUIC 默认如果不配置 ports 默认嗅探 443 + QUIC: + # ports: [ 443 ] + TLS: + # ports: [443, 8443] - # These nameservers are used to resolve the DNS nameserver hostnames below. - # Specify IP addresses only + # 默认嗅探 80 + HTTP: # 需要嗅探的端口 + ports: [80, 8080-8880] + # 可覆盖 sniffer.override-destination + override-destination: true + force-domain: + - +.v2ex.com + # skip-src-address: # 对于来源ip跳过嗅探 + # - 192.168.0.3/32 + # skip-dst-address: # 对于目标ip跳过嗅探 + # - 192.168.0.3/32 + ## 对嗅探结果进行跳过 + # skip-domain: + # - Mijia Cloud + # 需要嗅探协议 + # 已废弃,若 sniffer.sniff 配置则此项无效 + sniffing: + - tls + - http + # 强制对此域名进行嗅探 + + # 仅对白名单中的端口进行嗅探,默认为 443,80 + # 已废弃,若 sniffer.sniff 配置则此项无效 + port-whitelist: + - "80" + - "443" + # - 8000-9999 + +tunnels: # one line config + - tcp/udp,127.0.0.1:6553,114.114.114.114:53,proxy + - tcp,127.0.0.1:6666,rds.mysql.com:3306,vpn + # full yaml config + - network: [tcp, udp] + address: 127.0.0.1:7777 + target: target.com + proxy: proxy + +# DNS 配置 +dns: + cache-algorithm: arc + enable: false # 关闭将使用系统 DNS + prefer-h3: false # 是否开启 DoH 支持 HTTP/3,将并发尝试 + listen: 0.0.0.0:53 # 开启 DNS 服务器监听 + # ipv6: false # false 将返回 AAAA 的空结果 + # ipv6-timeout: 300 # 单位:ms,内部双栈并发时,向上游查询 AAAA 时,等待 AAAA 的时间,默认 100ms + # 用于解析 nameserver,fallback 以及其他 DNS 服务器配置的,DNS 服务域名 + # 只能使用纯 IP 地址,可使用加密 DNS default-nameserver: - 114.114.114.114 - 8.8.8.8 - enhanced-mode: fake-ip # or redir-host (not recommended) - fake-ip-range: 198.18.0.1/16 # Fake IP addresses pool CIDR - # use-hosts: true # lookup hosts and return IP record - - # Hostnames in this list will not be resolved with fake IPs - # i.e. questions to these domain names will always be answered with their - # real IP addresses - # fake-ip-filter: - # - '*.lan' - # - localhost.ptlogin2.qq.com - - # The matching mode of fake-ip-filter is set to a blacklist by default. - # That is, fake-ip is not returned if the matching succeeds - # It can be set to whitelist, that is, fake-ip is returned only after the match is successful + - tls://1.12.12.12:853 + - tls://223.5.5.5:853 + - system # append DNS server from system configuration. If not found, it would print an error log and skip. + enhanced-mode: fake-ip # or redir-host + + fake-ip-range: 198.18.0.1/16 # fake-ip 池设置 + + # 配置不使用 fake-ip 的域名 + fake-ip-filter: + - '*.lan' + - localhost.ptlogin2.qq.com + # fakeip-filter 为 rule-providers 中的名为 fakeip-filter 规则订阅, + # 且 behavior 必须为 domain/classical,当为 classical 时仅会生效域名类规则 + - rule-set:fakeip-filter + # fakeip-filter 为 geosite 中名为 fakeip-filter 的分类(需要自行保证该分类存在) + - geosite:fakeip-filter + # 配置fake-ip-filter的匹配模式,默认为blacklist,即如果匹配成功不返回fake-ip + # 可设置为whitelist,即只有匹配成功才返回fake-ip fake-ip-filter-mode: blacklist - - # Supports UDP, TCP, DoT, DoH. You can specify the port to connect to. - # All DNS questions are sent directly to the nameserver, without proxies - # involved. Clash answers the DNS question with the first result gathered. + + # use-hosts: true # 查询 hosts + + # 配置后面的nameserver、fallback和nameserver-policy向dns服务器的连接过程是否遵守遵守rules规则 + # 如果为false(默认值)则这三部分的dns服务器在未特别指定的情况下会直连 + # 如果为true,将会按照rules的规则匹配链接方式(走代理或直连),如果有特别指定则任然以指定值为准 + # 仅当proxy-server-nameserver非空时可以开启此选项, 强烈不建议和prefer-h3一起使用 + # 此外,这三者配置中的dns服务器如果出现域名会采用default-nameserver配置项解析,也请确保正确配置default-nameserver + respect-rules: false + + # DNS 主要域名配置 + # 支持 UDP,TCP,DoT,DoH,DoQ + # 这部分为主要 DNS 配置,影响所有直连,确保使用对大陆解析精准的 DNS nameserver: - 114.114.114.114 # default value - #- 8.8.8.8 # default value - #- tls://dns.rubyfish.cn:853 # DNS over TLS - #- https://1.1.1.1/dns-query # DNS over HTTPS - #- dhcp://en0 # dns from dhcp - # - '8.8.8.8#en0' - - # When `fallback` is present, the DNS server will send concurrent requests - # to the servers in this section along with servers in `nameservers`. - # The answers from fallback servers are used when the GEOIP country - # is not `CN`. + - 8.8.8.8 # default value + - tls://223.5.5.5:853 # DNS over TLS + - https://doh.pub/dns-query # DNS over HTTPS + - https://dns.alidns.com/dns-query#h3=true # 强制 HTTP/3,与 perfer-h3 无关,强制开启 DoH 的 HTTP/3 支持,若不支持将无法使用 + - https://mozilla.cloudflare-dns.com/dns-query#DNS&h3=true # 指定策略组和使用 HTTP/3 + - dhcp://en0 # dns from dhcp + - quic://dns.adguard.com:784 # DNS over QUIC + # - '8.8.8.8#RULES' # 效果同respect-rules,但仅对该服务器生效 + # - '8.8.8.8#en0' # 兼容指定 DNS 出口网卡 + + # 当配置 fallback 时,会查询 nameserver 中返回的 IP 是否为 CN,非必要配置 + # 当不是 CN,则使用 fallback 中的 DNS 查询结果 + # 确保配置 fallback 时能够正常查询 # fallback: # - tcp://1.1.1.1 - # - 'tcp://1.1.1.1#en0' - - # If IP addresses resolved with servers in `nameservers` are in the specified - # subnets below, they are considered invalid and results from `fallback` - # servers are used instead. - # - # IP address resolved with servers in `nameserver` is used when - # `fallback-filter.geoip` is true and when GEOIP of the IP address is `CN`. - # - # If `fallback-filter.geoip` is false, results from `nameserver` nameservers - # are always used if not match `fallback-filter.ipcidr`. - # - # This is a countermeasure against DNS pollution attacks. + # - 'tcp://1.1.1.1#ProxyGroupName' # 指定 DNS 过代理查询,ProxyGroupName 为策略组名或节点名,过代理配置优先于配置出口网卡,当找不到策略组或节点名则设置为出口网卡 + + # 专用于节点域名解析的 DNS 服务器,非必要配置项,如果不填则遵循nameserver-policy、nameserver和fallback的配置 + # proxy-server-nameserver: + # - https://dns.google/dns-query + # - tls://one.one.one.one + + # 专用于direct出口域名解析的 DNS 服务器,非必要配置项,如果不填则遵循nameserver-policy、nameserver和fallback的配置 + # direct-nameserver: + # - system:// + # direct-nameserver-follow-policy: false # 是否遵循nameserver-policy,默认为不遵守,仅当direct-nameserver不为空时生效 + + # 配置 fallback 使用条件 # fallback-filter: - # geoip: true - # geoip-code: CN + # geoip: true # 配置是否使用 geoip + # geoip-code: CN # 当 nameserver 域名的 IP 查询 geoip 库为 CN 时,不使用 fallback 中的 DNS 查询结果 + # 配置强制 fallback,优先于 IP 判断,具体分类自行查看 geosite 库 + # geosite: + # - gfw + # 如果不匹配 ipcidr 则使用 nameservers 中的结果 # ipcidr: # - 240.0.0.0/4 # domain: # - '+.google.com' # - '+.facebook.com' # - '+.youtube.com' - - # Lookup domains via specific nameservers - # nameserver-policy: - # 'www.baidu.com': '114.114.114.114' - # '+.internal.crop.com': '10.0.0.1' -proxies: + # 配置查询域名使用的 DNS 服务器 + nameserver-policy: + # 'www.baidu.com': '114.114.114.114' + # '+.internal.crop.com': '10.0.0.1' + "geosite:cn,private,apple": + - https://doh.pub/dns-query + - https://dns.alidns.com/dns-query + "geosite:category-ads-all": rcode://success + "www.baidu.com,+.google.cn": [223.5.5.5, https://dns.alidns.com/dns-query] + ## global,dns 为 rule-providers 中的名为 global 和 dns 规则订阅, + ## 且 behavior 必须为 domain/classical,当为 classical 时仅会生效域名类规则 + # "rule-set:global,dns": 8.8.8.8 + +proxies: # socks5 + - name: "socks" + type: socks5 + server: server + port: 443 + # username: username + # password: password + # tls: true + # fingerprint: xxxx + # skip-cert-verify: true + # udp: true + # ip-version: ipv6 + + # http + - name: "http" + type: http + server: server + port: 443 + # username: username + # password: password + # tls: true # https + # skip-cert-verify: true + # sni: custom.com + # fingerprint: xxxx # 同 experimental.fingerprints 使用 sha256 指纹,配置协议独立的指纹,将忽略 experimental.fingerprints + # ip-version: dual + + # Snell + # Beware that there's currently no UDP support yet + - name: "snell" + type: snell + server: server + port: 44046 + psk: yourpsk + # version: 2 + # obfs-opts: + # mode: http # or tls + # host: bing.com + # Shadowsocks - # The supported ciphers (encryption methods): + # cipher支持: # aes-128-gcm aes-192-gcm aes-256-gcm # aes-128-cfb aes-192-cfb aes-256-cfb # aes-128-ctr aes-192-ctr aes-256-ctr # rc4-md5 chacha20-ietf xchacha20 # chacha20-ietf-poly1305 xchacha20-ietf-poly1305 + # 2022-blake3-aes-128-gcm 2022-blake3-aes-256-gcm 2022-blake3-chacha20-poly1305 - name: "ss1" type: ss server: server @@ -172,6 +388,22 @@ proxies: cipher: chacha20-ietf-poly1305 password: "password" # udp: true + # udp-over-tcp: false + # ip-version: ipv4 # 设置节点使用 IP 版本,可选:dual,ipv4,ipv6,ipv4-prefer,ipv6-prefer。默认使用 dual + # ipv4:仅使用 IPv4 ipv6:仅使用 IPv6 + # ipv4-prefer:优先使用 IPv4 对于 TCP 会进行双栈解析,并发链接但是优先使用 IPv4 链接, + # UDP 则为双栈解析,获取结果中的第一个 IPv4 + # ipv6-prefer 同 ipv4-prefer + # 现有协议都支持此参数,TCP 效果仅在开启 tcp-concurrent 生效 + smux: + enabled: false + protocol: smux # smux/yamux/h2mux + # max-connections: 4 # Maximum connections. Conflict with max-streams. + # min-streams: 4 # Minimum multiplexed streams in a connection before opening a new connection. Conflict with max-streams. + # max-streams: 0 # Maximum multiplexed streams in a connection before opening a new connection. Conflict with max-connections and min-streams. + # padding: false # Enable padding. Requires sing-box server version 1.3-beta9 or later. + # statistic: false # 控制是否将底层连接显示在面板中,方便打断底层连接 + # only-tcp: false # 如果设置为 true, smux 的设置将不会对 udp 生效,udp 连接会直接走底层协议 - name: "ss2" type: ss @@ -194,15 +426,74 @@ proxies: plugin-opts: mode: websocket # no QUIC now # tls: true # wss + # 可使用 openssl x509 -noout -fingerprint -sha256 -inform pem -in yourcert.pem 获取 + # 配置指纹将实现 SSL Pining 效果 + # fingerprint: xxxx # skip-cert-verify: true # host: bing.com # path: "/" # mux: true # headers: # custom: value + # v2ray-http-upgrade: false + # v2ray-http-upgrade-fast-open: false + + - name: "ss4-shadow-tls" + type: ss + server: server + port: 443 + cipher: chacha20-ietf-poly1305 + password: "password" + plugin: shadow-tls + client-fingerprint: chrome + plugin-opts: + host: "cloud.tencent.com" + password: "shadow_tls_password" + version: 2 # support 1/2/3 + + - name: "ss-restls-tls13" + type: ss + server: [YOUR_SERVER_IP] + port: 443 + cipher: chacha20-ietf-poly1305 + password: [YOUR_SS_PASSWORD] + client-fingerprint: + chrome # One of: chrome, ios, firefox or safari + # 可以是 chrome, ios, firefox, safari 中的一个 + plugin: restls + plugin-opts: + host: + "www.microsoft.com" # Must be a TLS 1.3 server + # 应当是一个 TLS 1.3 服务器 + password: [YOUR_RESTLS_PASSWORD] + version-hint: "tls13" + # Control your post-handshake traffic through restls-script + # Hide proxy behaviors like "tls in tls". + # see https://github.com/3andne/restls/blob/main/Restls-Script:%20Hide%20Your%20Proxy%20Traffic%20Behavior.md + # 用 restls 剧本来控制握手后的行为,隐藏"tls in tls"等特征 + # 详情:https://github.com/3andne/restls/blob/main/Restls-Script:%20%E9%9A%90%E8%97%8F%E4%BD%A0%E7%9A%84%E4%BB%A3%E7%90%86%E8%A1%8C%E4%B8%BA.md + restls-script: "300?100<1,400~100,350~100,600~100,300~200,300~100" + + - name: "ss-restls-tls12" + type: ss + server: [YOUR_SERVER_IP] + port: 443 + cipher: chacha20-ietf-poly1305 + password: [YOUR_SS_PASSWORD] + client-fingerprint: + chrome # One of: chrome, ios, firefox or safari + # 可以是 chrome, ios, firefox, safari 中的一个 + plugin: restls + plugin-opts: + host: + "vscode.dev" # Must be a TLS 1.2 server + # 应当是一个 TLS 1.2 服务器 + password: [YOUR_RESTLS_PASSWORD] + version-hint: "tls12" + restls-script: "1000?100<1,500~100,350~100,600~100,400~200" # vmess - # cipher support auto/aes-128-gcm/chacha20-poly1305/none + # cipher 支持 auto/aes-128-gcm/chacha20-poly1305/none - name: "vmess" type: vmess server: server @@ -212,15 +503,19 @@ proxies: cipher: auto # udp: true # tls: true + # fingerprint: xxxx + # client-fingerprint: chrome # Available: "chrome","firefox","safari","ios","random", currently only support TLS transport in TCP/GRPC/WS/HTTP for VLESS/Vmess and trojan. # skip-cert-verify: true # servername: example.com # priority over wss host # network: ws # ws-opts: - # path: /path - # headers: - # Host: v2ray.com - # max-early-data: 2048 - # early-data-header-name: Sec-WebSocket-Protocol + # path: /path + # headers: + # Host: v2ray.com + # max-early-data: 2048 + # early-data-header-name: Sec-WebSocket-Protocol + # v2ray-http-upgrade: false + # v2ray-http-upgrade-fast-open: false - name: "vmess-h2" type: vmess @@ -231,12 +526,13 @@ proxies: cipher: auto network: h2 tls: true + # fingerprint: xxxx h2-opts: host: - http.example.com - http-alt.example.com path: / - + - name: "vmess-http" type: vmess server: server @@ -247,13 +543,14 @@ proxies: # udp: true # network: http # http-opts: - # # method: "GET" - # # path: - # # - '/' - # # - '/video' - # # headers: - # # Connection: - # # - keep-alive + # method: "GET" + # path: + # - '/' + # - '/video' + # headers: + # Connection: + # - keep-alive + # ip-version: ipv4 # 设置使用 IP 类型偏好,可选:ipv4,ipv6,dual,默认值:dual - name: vmess-grpc server: server @@ -264,44 +561,90 @@ proxies: cipher: auto network: grpc tls: true + # fingerprint: xxxx servername: example.com # skip-cert-verify: true grpc-opts: grpc-service-name: "example" + # ip-version: ipv4 - # socks5 - - name: "socks" - type: socks5 + # vless + - name: "vless-tcp" + type: vless server: server port: 443 - # username: username - # password: password - # tls: true + uuid: uuid + network: tcp + servername: example.com # AKA SNI + # flow: xtls-rprx-direct # xtls-rprx-origin # enable XTLS # skip-cert-verify: true - # udp: true + # fingerprint: xxxx + # client-fingerprint: random # Available: "chrome","firefox","safari","random","none" - # http - - name: "http" - type: http + - name: "vless-vision" + type: vless server: server port: 443 - # username: username - # password: password - # tls: true # https + uuid: uuid + network: tcp + tls: true + udp: true + flow: xtls-rprx-vision + client-fingerprint: chrome + # fingerprint: xxxx # skip-cert-verify: true - # sni: custom.com - # Snell - # Beware that there's currently no UDP support yet - - name: "snell" - type: snell + - name: "vless-reality-vision" + type: vless server: server - port: 44046 - psk: yourpsk - # version: 2 - # obfs-opts: - # mode: http # or tls - # host: bing.com + port: 443 + uuid: uuid + network: tcp + tls: true + udp: true + flow: xtls-rprx-vision + servername: www.microsoft.com # REALITY servername + reality-opts: + public-key: xxx + short-id: xxx # optional + client-fingerprint: chrome # cannot be empty + + - name: "vless-reality-grpc" + type: vless + server: server + port: 443 + uuid: uuid + network: grpc + tls: true + udp: true + flow: + # skip-cert-verify: true + client-fingerprint: chrome + servername: testingcf.jsdelivr.net + grpc-opts: + grpc-service-name: "grpc" + reality-opts: + public-key: CrrQSjAG_YkHLwvM2M-7XkKJilgL5upBKCp0od0tLhE + short-id: 10f897e26c4b9478 + + - name: "vless-ws" + type: vless + server: server + port: 443 + uuid: uuid + udp: true + tls: true + network: ws + # client-fingerprint: random # Available: "chrome","firefox","safari","random","none" + servername: example.com # priority over wss host + # skip-cert-verify: true + # fingerprint: xxxx + ws-opts: + path: "/" + headers: + Host: example.com + # v2ray-http-upgrade: false + # v2ray-http-upgrade-fast-open: false # Trojan - name: "trojan" @@ -309,12 +652,18 @@ proxies: server: server port: 443 password: yourpsk + # client-fingerprint: random # Available: "chrome","firefox","safari","random","none" + # fingerprint: xxxx # udp: true # sni: example.com # aka server name # alpn: # - h2 # - http/1.1 # skip-cert-verify: true + # ss-opts: # like trojan-go's `shadowsocks` config + # enabled: false + # method: aes-128-gcm # aes-128-gcm/aes-256-gcm/chacha20-ietf-poly1305 + # password: "example" - name: trojan-grpc server: server @@ -324,6 +673,7 @@ proxies: network: grpc sni: example.com # skip-cert-verify: true + # fingerprint: xxxx udp: true grpc-opts: grpc-service-name: "example" @@ -336,20 +686,148 @@ proxies: network: ws sni: example.com # skip-cert-verify: true + # fingerprint: xxxx udp: true # ws-opts: - # path: /path - # headers: - # Host: example.com + # path: /path + # headers: + # Host: example.com + # v2ray-http-upgrade: false + # v2ray-http-upgrade-fast-open: false + + - name: "trojan-xtls" + type: trojan + server: server + port: 443 + password: yourpsk + flow: "xtls-rprx-direct" # xtls-rprx-origin xtls-rprx-direct + flow-show: true + # udp: true + # sni: example.com # aka server name + # skip-cert-verify: true + # fingerprint: xxxx + + #hysteria + - name: "hysteria" + type: hysteria + server: server.com + port: 443 + # ports: 1000,2000-3000,5000 # port 不可省略 + auth-str: yourpassword + # obfs: obfs_str + # alpn: + # - h3 + protocol: udp # 支持 udp/wechat-video/faketcp + up: "30 Mbps" # 若不写单位,默认为 Mbps + down: "200 Mbps" # 若不写单位,默认为 Mbps + # sni: server.com + # skip-cert-verify: false + # recv-window-conn: 12582912 + # recv-window: 52428800 + # ca: "./my.ca" + # ca-str: "xyz" + # disable-mtu-discovery: false + # fingerprint: xxxx + # fast-open: true # 支持 TCP 快速打开,默认为 false + + #hysteria2 + - name: "hysteria2" + type: hysteria2 + server: server.com + port: 443 + # ports: 1000,2000-3000,5000 # port 不可省略 + # hop-interval: 15 + # up 和 down 均不写或为 0 则使用 BBR 流控 + # up: "30 Mbps" # 若不写单位,默认为 Mbps + # down: "200 Mbps" # 若不写单位,默认为 Mbps + password: yourpassword + # obfs: salamander # 默认为空,如果填写则开启 obfs,目前仅支持 salamander + # obfs-password: yourpassword + # sni: server.com + # skip-cert-verify: false + # fingerprint: xxxx + # alpn: + # - h3 + # ca: "./my.ca" + # ca-str: "xyz" + + # wireguard + - name: "wg" + type: wireguard + server: 162.159.192.1 + port: 2480 + ip: 172.16.0.2 + ipv6: fd01:5ca1:ab1e:80fa:ab85:6eea:213f:f4a5 + public-key: Cr8hWlKvtDt7nrvf+f0brNQQzabAqrjfBvas9pmowjo= + # pre-shared-key: 31aIhAPwktDGpH4JDhA8GNvjFXEf/a6+UaQRyOAiyfM= + private-key: eCtXsJZ27+4PbhDkHnB923tkUn2Gj59wZw5wFA75MnU= + udp: true + reserved: "U4An" + # 数组格式也是合法的 + # reserved: [209,98,59] + # 一个出站代理的标识。当值不为空时,将使用指定的 proxy 发出连接 + # dialer-proxy: "ss1" + # remote-dns-resolve: true # 强制 dns 远程解析,默认值为 false + # dns: [ 1.1.1.1, 8.8.8.8 ] # 仅在 remote-dns-resolve 为 true 时生效 + # refresh-server-ip-interval: 60 # 重新解析server ip的间隔,单位为秒,默认值为0即仅第一次链接时解析server域名,仅应在server域名对应的IP会发生变化时启用该选项(如家宽ddns) + # 如果 peers 不为空,该段落中的 allowed-ips 不可为空;前面段落的 server,port,public-key,pre-shared-key 均会被忽略,但 private-key 会被保留且只能在顶层指定 + # peers: + # - server: 162.159.192.1 + # port: 2480 + # public-key: Cr8hWlKvtDt7nrvf+f0brNQQzabAqrjfBvas9pmowjo= + # # pre-shared-key: 31aIhAPwktDGpH4JDhA8GNvjFXEf/a6+UaQRyOAiyfM= + # allowed-ips: ['0.0.0.0/0'] + # reserved: [209,98,59] + # 如果存在则开启AmneziaWG功能 + # amnezia-wg-option: + # jc: 5 + # jmin: 500 + # jmax: 501 + # s1: 30 + # s2: 40 + # h1: 123456 + # h2: 67543 + # h4: 32345 + # h3: 123123 + + # tuic + - name: tuic + server: www.example.com + port: 10443 + type: tuic + # tuicV4 必须填写 token(不可同时填写 uuid 和 password) + token: TOKEN + # tuicV5 必须填写 uuid 和 password(不可同时填写 token) + uuid: 00000000-0000-0000-0000-000000000001 + password: PASSWORD_1 + # ip: 127.0.0.1 # for overwriting the DNS lookup result of the server address set in option 'server' + # heartbeat-interval: 10000 + # alpn: [h3] + disable-sni: true + reduce-rtt: true + request-timeout: 8000 + udp-relay-mode: native # Available: "native", "quic". Default: "native" + # congestion-controller: bbr # Available: "cubic", "new_reno", "bbr". Default: "cubic" + # cwnd: 10 # default: 32 + # max-udp-relay-packet-size: 1500 + # fast-open: true + # skip-cert-verify: true + # max-open-streams: 20 # default 100, too many open streams may hurt performance + # sni: example.com + # + # meta 和 sing-box 私有扩展,将 ss-uot 用于 udp 中继,开启此选项后 udp-relay-mode 将失效 + # 警告,与原版 tuic 不兼容!!! + # udp-over-stream: false + # udp-over-stream-version: 1 # ShadowsocksR # The supported ciphers (encryption methods): all stream ciphers in ss # The supported obfses: # plain http_simple http_post # random_head tls1.2_ticket_auth tls1.2_ticket_fastauth - # The supported supported protocols: + # The supported protocols: # origin auth_sha1_v4 auth_aes128_md5 - # auth_aes128_sha1 auth_chain_a auth_chain_b + # auth_aes128_sha1 auth_chain_a auth_chain_b - name: "ssr" type: ssr server: server @@ -362,9 +840,22 @@ proxies: # protocol-param: "#" # udp: true + - name: "ssh-out" + type: ssh + + server: 127.0.0.1 + port: 22 + username: root + password: password + privateKey: path + +# dns 出站会将请求劫持到内部 dns 模块,所有请求均在内部处理 + - name: "dns-out" + type: dns proxy-groups: - # relay chains the proxies. proxies shall not contain a relay. No UDP support. - # Traffic: clash <-> http <-> vmess <-> ss1 <-> ss2 <-> Internet + # 代理链,目前 relay 可以支持 udp 的只有 vmess/vless/trojan/ss/ssr/tuic + # wireguard 目前不支持在 relay 中使用,请使用 proxy 中的 dialer-proxy 配置项 + # Traffic: mihomo <-> http <-> vmess <-> ss1 <-> ss2 <-> Internet - name: "relay" type: relay proxies: @@ -373,7 +864,7 @@ proxy-groups: - ss1 - ss2 - # url-test select which proxy will be used by benchmarking speed to a URL. + # url-test 将按照 url 测试结果使用延迟最低节点 - name: "auto" type: url-test proxies: @@ -382,32 +873,32 @@ proxy-groups: - vmess1 # tolerance: 150 # lazy: true - url: 'http://www.gstatic.com/generate_204' + # expected-status: 204 # 当健康检查返回状态码与期望值不符时,认为节点不可用 + url: "https://cp.cloudflare.com/generate_204" interval: 300 - # fallback selects an available policy by priority. The availability is tested by accessing an URL, just like an auto url-test group. + # fallback 将按照 url 测试结果按照节点顺序选择 - name: "fallback-auto" type: fallback proxies: - ss1 - ss2 - vmess1 - url: 'http://www.gstatic.com/generate_204' + url: "https://cp.cloudflare.com/generate_204" interval: 300 - # load-balance: The request of the same eTLD+1 will be dial to the same proxy. + # load-balance 将按照算法随机选择节点 - name: "load-balance" type: load-balance proxies: - ss1 - ss2 - vmess1 - url: 'http://www.gstatic.com/generate_204' + url: "https://cp.cloudflare.com/generate_204" interval: 300 - # strategy: consistent-hashing # or round-robin + # strategy: consistent-hashing # 可选 round-robin 和 sticky-sessions - # select is used for selecting proxy or proxy group - # you can use RESTful API to switch proxy is recommended for use in GUI. + # select 用户自行选择节点 - name: Proxy type: select # disable-udp: true @@ -416,62 +907,302 @@ proxy-groups: - ss2 - vmess1 - auto - - # direct to another infacename or fwmark, also supported on proxy + + # 配置指定 interface-name 和 fwmark 的 DIRECT - name: en1 type: select interface-name: en1 routing-mark: 6667 proxies: - - DIRECT + - DIRECT - name: UseProvider type: select + filter: "HK|TW" # 正则表达式,过滤 provider1 中节点名包含 HK 或 TW use: - provider1 proxies: - Proxy - DIRECT +# Mihomo 格式的节点或支持 *ray 的分享格式 proxy-providers: provider1: - type: http + type: http # http 的 path 可空置,默认储存路径为 homedir 的 proxies 文件夹,文件名为 url 的 md5 url: "url" interval: 3600 - path: ./provider1.yaml + path: ./provider1.yaml # 默认只允许存储在 mihomo 的 Home Dir,如果想存储到任意位置,添加环境变量 SKIP_SAFE_PATH_CHECK=1 + proxy: DIRECT + # size-limit: 10240 # 限制下载文件最大为10kb,默认为0即不限制文件大小 + header: + User-Agent: + - "Clash/v1.18.0" + - "mihomo/1.18.3" + # Accept: + # - 'application/vnd.github.v3.raw' + # Authorization: + # - 'token 1231231' health-check: enable: true interval: 600 # lazy: true - url: http://www.gstatic.com/generate_204 + url: https://cp.cloudflare.com/generate_204 + # expected-status: 204 # 当健康检查返回状态码与期望值不符时,认为节点不可用 + override: # 覆写节点加载时的一些配置项 + skip-cert-verify: true + udp: true + # down: "50 Mbps" + # up: "10 Mbps" + # dialer-proxy: proxy + # interface-name: tailscale0 + # routing-mark: 233 + # ip-version: ipv4-prefer + # additional-prefix: "[provider1]" + # additional-suffix: "test" + # # 名字替换,支持正则表达式 + # proxy-name: + # - pattern: "test" + # target: "TEST" + # - pattern: "IPLC-(.*?)倍" + # target: "iplc x $1" + test: type: file path: /test.yaml health-check: enable: true interval: 36000 - url: http://www.gstatic.com/generate_204 + url: https://cp.cloudflare.com/generate_204 +rule-providers: + rule1: + behavior: classical # domain ipcidr + interval: 259200 + path: /path/to/save/file.yaml # 默认只允许存储在 mihomo 的 Home Dir,如果想存储到任意位置,添加环境变量 SKIP_SAFE_PATH_CHECK=1 + type: http # http 的 path 可空置,默认储存路径为 homedir 的 rules 文件夹,文件名为 url 的 md5 + url: "url" + proxy: DIRECT + # size-limit: 10240 # 限制下载文件最大为10kb,默认为0即不限制文件大小 + rule2: + behavior: classical + interval: 259200 + path: /path/to/save/file.yaml + type: file + rule3: + # mrs类型ruleset,目前仅支持domain和ipcidr(即不支持classical), + # + # 对于behavior=domain: + # - format=yaml 可以通过“mihomo convert-ruleset domain yaml XXX.yaml XXX.mrs”转换到mrs格式 + # - format=text 可以通过“mihomo convert-ruleset domain text XXX.text XXX.mrs”转换到mrs格式 + # - XXX.mrs 可以通过"mihomo convert-ruleset domain mrs XXX.mrs XXX.text"转换回text格式(暂不支持转换回yaml格式) + # + # 对于behavior=ipcidr: + # - format=yaml 可以通过“mihomo convert-ruleset ipcidr yaml XXX.yaml XXX.mrs”转换到mrs格式 + # - format=text 可以通过“mihomo convert-ruleset ipcidr text XXX.text XXX.mrs”转换到mrs格式 + # - XXX.mrs 可以通过"mihomo convert-ruleset ipcidr mrs XXX.mrs XXX.text"转换回text格式(暂不支持转换回yaml格式) + # + type: http + url: "url" + format: mrs + behavior: domain + path: /path/to/save/file.mrs +rules: + - RULE-SET,rule1,REJECT + - IP-ASN,1,PROXY + - DOMAIN-REGEX,^abc,DIRECT + - DOMAIN-SUFFIX,baidu.com,DIRECT + - DOMAIN-KEYWORD,google,ss1 + - IP-CIDR,1.1.1.1/32,ss1 + - IP-CIDR6,2409::/64,DIRECT + # 当满足条件是 TCP 或 UDP 流量时,使用名为 sub-rule-name1 的规则集 + - SUB-RULE,(OR,((NETWORK,TCP),(NETWORK,UDP))),sub-rule-name1 + - SUB-RULE,(AND,((NETWORK,UDP))),sub-rule-name2 +# 定义多个子规则集,规则将以分叉匹配,使用 SUB-RULE 使用 +# google.com(not match)--> baidu.com(match) +# / | +# / | +# https://baidu.com --> rule1 --> rule2 --> sub-rule-name1(match tcp) 使用 DIRECT +# +# +# google.com(not match)--> baidu.com(not match) +# / | +# / | +# dns 1.1.1.1 --> rule1 --> rule2 --> sub-rule-name1(match udp) sub-rule-name2(match udp) +# | +# | +# 使用 REJECT <-- 1.1.1.1/32(match) +# -tunnels: - # one line config - #- tcp/udp,127.0.0.1:6553,114.114.114.114:53,proxy - #- tcp,127.0.0.1:6666,rds.mysql.com:3306,vpn - # full yaml config - #- network: [tcp, udp] - # address: 127.0.0.1:7777 - # target: target.com - # proxy: proxy +sub-rules: + sub-rule-name1: + - DOMAIN,google.com,ss1 + - DOMAIN,baidu.com,DIRECT + sub-rule-name2: + - IP-CIDR,1.1.1.1/32,REJECT + - IP-CIDR,8.8.8.8/32,ss1 + - DOMAIN,dns.alidns.com,REJECT -rules: - - DOMAIN-SUFFIX,google.com,auto - - DOMAIN-KEYWORD,google,auto - - DOMAIN,google.com,auto - - DOMAIN-SUFFIX,ad.com,REJECT - - SRC-IP-CIDR,192.168.1.201/32,DIRECT - # optional param "no-resolve" for IP rules (GEOIP, IP-CIDR, IP-CIDR6) - - IP-CIDR,127.0.0.0/8,DIRECT - - GEOIP,CN,DIRECT - - DST-PORT,80,DIRECT - - SRC-PORT,7777,DIRECT - - RULE-SET,apple,REJECT # Premium only - - MATCH,auto +# 流量入站 +listeners: + - name: socks5-in-1 + type: socks + port: 10808 + #listen: 0.0.0.0 # 默认监听 0.0.0.0 + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 + # udp: false # 默认 true + # users: # 如果不填写users项,则遵从全局authentication设置,如果填写会忽略全局设置, 如想跳过该入站的验证可填写 users: [] + # - username: aaa + # password: aaa + + - name: http-in-1 + type: http + port: 10809 + listen: 0.0.0.0 + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错) + # users: # 如果不填写users项,则遵从全局authentication设置,如果填写会忽略全局设置, 如想跳过该入站的验证可填写 users: [] + # - username: aaa + # password: aaa + + - name: mixed-in-1 + type: mixed # HTTP(S) 和 SOCKS 代理混合 + port: 10810 + listen: 0.0.0.0 + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错) + # udp: false # 默认 true + # users: # 如果不填写users项,则遵从全局authentication设置,如果填写会忽略全局设置, 如想跳过该入站的验证可填写 users: [] + # - username: aaa + # password: aaa + + - name: reidr-in-1 + type: redir + port: 10811 + listen: 0.0.0.0 + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错) + + - name: tproxy-in-1 + type: tproxy + port: 10812 + listen: 0.0.0.0 + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错) + # udp: false # 默认 true + + - name: shadowsocks-in-1 + type: shadowsocks + port: 10813 + listen: 0.0.0.0 + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错) + password: vlmpIPSyHH6f4S8WVPdRIHIlzmB+GIRfoH3aNJ/t9Gg= + cipher: 2022-blake3-aes-256-gcm + + - name: vmess-in-1 + type: vmess + port: 10814 + listen: 0.0.0.0 + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错) + users: + - username: 1 + uuid: 9d0cb9d0-964f-4ef6-897d-6c6b3ccf9e68 + alterId: 1 + # ws-path: "/" # 如果不为空则开启 websocket 传输层 + # 下面两项如果填写则开启 tls(需要同时填写) + # certificate: ./server.crt + # private-key: ./server.key + + - name: tuic-in-1 + type: tuic + port: 10815 + listen: 0.0.0.0 + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错) + # token: # tuicV4 填写(可以同时填写 users) + # - TOKEN + # users: # tuicV5 填写(可以同时填写 token) + # 00000000-0000-0000-0000-000000000000: PASSWORD_0 + # 00000000-0000-0000-0000-000000000001: PASSWORD_1 + # certificate: ./server.crt + # private-key: ./server.key + # congestion-controller: bbr + # max-idle-time: 15000 + # authentication-timeout: 1000 + # alpn: + # - h3 + # max-udp-relay-packet-size: 1500 + + - name: tunnel-in-1 + type: tunnel + port: 10816 + listen: 0.0.0.0 + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错) + network: [tcp, udp] + target: target.com + + - name: tun-in-1 + type: tun + # rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules + # proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错) + stack: system # gvisor / mixed + dns-hijack: + - 0.0.0.0:53 # 需要劫持的 DNS + # auto-detect-interface: false # 自动识别出口网卡 + # auto-route: false # 配置路由表 + # mtu: 9000 # 最大传输单元 + inet4-address: # 必须手动设置 ipv4 地址段 + - 198.19.0.1/30 + inet6-address: # 必须手动设置 ipv6 地址段 + - "fdfe:dcba:9877::1/126" + # strict-route: true # 将所有连接路由到 tun 来防止泄漏,但你的设备将无法其他设备被访问 + # inet4-route-address: # 启用 auto-route 时使用自定义路由而不是默认路由 + # - 0.0.0.0/1 + # - 128.0.0.0/1 + # inet6-route-address: # 启用 auto-route 时使用自定义路由而不是默认路由 + # - "::/1" + # - "8000::/1" + # endpoint-independent-nat: false # 启用独立于端点的 NAT + # include-uid: # UID 规则仅在 Linux 下被支持,并且需要 auto-route + # - 0 + # include-uid-range: # 限制被路由的的用户范围 + # - 1000:99999 + # exclude-uid: # 排除路由的的用户 + # - 1000 + # exclude-uid-range: # 排除路由的的用户范围 + # - 1000:99999 + + # Android 用户和应用规则仅在 Android 下被支持 + # 并且需要 auto-route + + # include-android-user: # 限制被路由的 Android 用户 + # - 0 + # - 10 + # include-package: # 限制被路由的 Android 应用包名 + # - com.android.chrome + # exclude-package: # 排除被路由的 Android 应用包名 + # - com.android.captiveportallogin +# 入口配置与 Listener 等价,传入流量将和 socks,mixed 等入口一样按照 mode 所指定的方式进行匹配处理 +# shadowsocks,vmess 入口配置(传入流量将和 socks,mixed 等入口一样按照 mode 所指定的方式进行匹配处理) +# ss-config: ss://2022-blake3-aes-256-gcm:vlmpIPSyHH6f4S8WVPdRIHIlzmB+GIRfoH3aNJ/t9Gg=@:23456 +# vmess-config: vmess://1:9d0cb9d0-964f-4ef6-897d-6c6b3ccf9e68@:12345 + +# tuic 服务器入口(传入流量将和 socks,mixed 等入口一样按照 mode 所指定的方式进行匹配处理) +# tuic-server: +# enable: true +# listen: 127.0.0.1:10443 +# token: # tuicV4 填写(可以同时填写 users) +# - TOKEN +# users: # tuicV5 填写(可以同时填写 token) +# 00000000-0000-0000-0000-000000000000: PASSWORD_0 +# 00000000-0000-0000-0000-000000000001: PASSWORD_1 +# certificate: ./server.crt +# private-key: ./server.key +# congestion-controller: bbr +# max-idle-time: 15000 +# authentication-timeout: 1000 +# alpn: +# - h3 +# max-udp-relay-packet-size: 1500 \ No newline at end of file diff --git a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml index 850330f3e1..0b5e58f495 100644 --- a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml +++ b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml @@ -5,41 +5,41 @@ rules: - RULE-SET, Netflix, Netflix - RULE-SET, Disney Plus, Disney - RULE-SET, YouTube, YouTube +- RULE-SET, Max, Max - RULE-SET, Spotify, Spotify -- RULE-SET, Bilibili, Asian TV -- RULE-SET, IQ, Asian TV -- RULE-SET, IQIYI, Asian TV -- RULE-SET, Letv, Asian TV -- RULE-SET, Netease Music, Asian TV -- RULE-SET, Tencent Video, Asian TV -- RULE-SET, Youku, Asian TV -- RULE-SET, WeTV, Asian TV +- RULE-SET, Bilibili, CN Mainland TV +- RULE-SET, IQ, CN Mainland TV +- RULE-SET, IQIYI, CN Mainland TV +- RULE-SET, Letv, CN Mainland TV +- RULE-SET, Netease Music, CN Mainland TV +- RULE-SET, Tencent Video, CN Mainland TV +- RULE-SET, WeTV, CN Mainland TV +- RULE-SET, Youku, CN Mainland TV +- RULE-SET, Abema TV, Asian TV +- RULE-SET, Bahamut, Asian TV +- RULE-SET, Fox+, Asian TV +- RULE-SET, Hulu Japan, Asian TV +- RULE-SET, Japonx, Asian TV +- RULE-SET, JOOX, Asian TV +- RULE-SET, KKBOX, Asian TV +- RULE-SET, KKTV, Asian TV +- RULE-SET, Line TV, Asian TV +- RULE-SET, myTV SUPER, Asian TV +- RULE-SET, Niconico, Asian TV +- RULE-SET, ViuTV, Asian TV - RULE-SET, ABC, Global TV -- RULE-SET, Abema TV, Global TV - RULE-SET, Amazon, Global TV -- RULE-SET, Bahamut, Global TV - RULE-SET, BBC iPlayer, Global TV - RULE-SET, DAZN, Global TV - RULE-SET, Discovery Plus, Global TV - RULE-SET, encoreTVB, Global TV - RULE-SET, F1 TV, Global TV - RULE-SET, Fox Now, Global TV -- RULE-SET, Fox+, Global TV -- RULE-SET, Hulu Japan, Global TV - RULE-SET, Hulu, Global TV -- RULE-SET, Japonx, Global TV -- RULE-SET, JOOX, Global TV -- RULE-SET, KKBOX, Global TV -- RULE-SET, KKTV, Global TV -- RULE-SET, Line TV, Global TV -- RULE-SET, Max, Global TV -- RULE-SET, myTV SUPER, Global TV -- RULE-SET, Niconico, Global TV - RULE-SET, Pandora, Global TV - RULE-SET, PBS, Global TV - RULE-SET, Pornhub, Global TV - RULE-SET, Soundcloud, Global TV -- RULE-SET, ViuTV, Global TV - RULE-SET, Apple Music, Apple TV - RULE-SET, Apple News, Apple TV - RULE-SET, Apple TV, Apple TV @@ -62,97 +62,43 @@ rules: - GEOIP, CN, Domestic - MATCH, Others script: - code: | - def main(ctx, metadata): - ruleset_action = { - 'AdBlock': 'AdBlock', - 'HTTPDNS': 'HTTPDNS', - 'Special': 'DIRECT', - 'Netflix': 'Netflix', - 'Disney Plus': 'Disney', - 'YouTube': 'YouTube', - 'Spotify': 'Spotify', - 'Bilibili': 'Asian TV', - 'IQ': 'Asian TV', - 'IQIYI': 'Asian TV', - 'Letv': 'Asian TV', - 'Netease Music': 'Asian TV', - 'Tencent Video': 'Asian TV', - 'Youku': 'Asian TV', - 'WeTV': 'Asian TV', - 'ABC': 'Global TV', - 'Abema TV': 'Global TV', - 'Amazon': 'Global TV', - 'Bahamut': 'Global TV', - 'BBC iPlayer': 'Global TV', - 'DAZN': 'Global TV', - 'Discovery Plus': 'Global TV', - 'encoreTVB': 'Global TV', - 'F1 TV': 'Global TV', - 'Fox Now': 'Global TV', - 'Fox+': 'Global TV', - 'Hulu Japan': 'Global TV', - 'Hulu': 'Global TV', - 'Japonx': 'Global TV', - 'JOOX': 'Global TV', - 'KKBOX': 'Global TV', - 'KKTV': 'Global TV', - 'Line TV': 'Global TV', - 'Max': 'Global TV', - 'myTV SUPER': 'Global TV', - 'Niconico': 'Global TV', - 'Pandora': 'Global TV', - 'PBS': 'Global TV', - 'Pornhub': 'Global TV', - 'Soundcloud': 'Global TV', - 'ViuTV': 'Global TV', - 'Apple Music': 'Apple TV', - 'Apple News': 'Apple TV', - 'Apple TV': 'Apple TV', - 'Apple': 'Apple', - 'Telegram': 'Telegram', - 'Crypto': 'Crypto', - 'Discord': 'Discord', - 'Google FCM': 'Google FCM', - 'Microsoft': 'Microsoft', - 'AI Suite': 'AI Suite', - 'PayPal': 'PayPal', - 'Scholar': 'Scholar', - 'Speedtest': 'Speedtest', - 'Steam': 'Steam', - 'miHoYo': 'miHoYo', - 'PROXY': 'Proxy', - 'Domestic': 'Domestic', - 'Domestic IPs': 'Domestic', - 'LAN': 'DIRECT' - } - - port = int(metadata['dst_port']) - - if metadata['network'] == 'UDP' and port == 443: - ctx.log('[Script] matched QUIC traffic use reject') - return 'REJECT' - - port_list = [21, 22, 23, 53, 80, 123, 143, 194, 443, 465, 587, 853, 993, 995, 998, 2052, 2053, 2082, 2083, 2086, 2095, 2096, 3389, 5222, 5228, 5229, 5230, 8080, 8443, 8880, 8888, 8889] - if port not in port_list: - ctx.log('[Script] not common port use direct') - return 'DIRECT' - - if metadata['dst_ip'] == '': - metadata['dst_ip'] = ctx.resolve_ip(metadata['host']) - - for ruleset in ruleset_action: - if ctx.rule_providers[ruleset].match(metadata): - return ruleset_action[ruleset] - - if metadata['dst_ip'] != '': - code = ctx.geoip(metadata['dst_ip']) - if code == 'CN': - ctx.log('[Script] Geoip CN') - return 'Domestic' - - ctx.log('[Script] FINAL') - return 'Others' + code: "def main(ctx, metadata):\n ruleset_action = {\n 'AdBlock': 'AdBlock', + \n 'HTTPDNS': 'HTTPDNS', \n 'Special': 'DIRECT', \n 'Netflix': + 'Netflix', \n 'Disney Plus': 'Disney', \n 'YouTube': 'YouTube', + \n 'Max': 'Max', \n 'Spotify': 'Spotify', \n 'Bilibili': + 'CN Mainland TV', \n 'IQ': 'CN Mainland TV', \n 'IQIYI': 'CN Mainland + TV', \n 'Letv': 'CN Mainland TV', \n 'Netease Music': 'CN Mainland + TV', \n 'Tencent Video': 'CN Mainland TV', \n 'Youku': 'CN Mainland + TV', \n 'WeTV': 'CN Mainland TV', \n 'Abema TV': 'Asian TV', \n + \ 'Bahamut': 'Asian TV', \n 'Fox+': 'Asian TV', \n 'Hulu Japan': + 'Asian TV', \n 'Japonx': 'Asian TV', \n 'JOOX': 'Asian TV', \n 'KKBOX': + 'Asian TV', \n 'KKTV': 'Asian TV', \n 'Line TV': 'Asian TV', \n + \ 'myTV SUPER': 'Asian TV', \n 'Niconico': 'Asian TV', \n 'ViuTV': + 'Asian TV', \n 'ABC': 'Global TV', \n 'Amazon': 'Global TV', \n + \ 'BBC iPlayer': 'Global TV', \n 'DAZN': 'Global TV', \n 'Discovery + Plus': 'Global TV', \n 'encoreTVB': 'Global TV', \n 'F1 TV': 'Global + TV', \n 'Fox Now': 'Global TV', \n 'Hulu': 'Global TV', \n 'Pandora': + 'Global TV', \n 'PBS': 'Global TV', \n 'Pornhub': 'Global TV', \n + \ 'Soundcloud': 'Global TV', \n 'Apple Music': 'Apple TV', \n 'Apple + News': 'Apple TV', \n 'Apple TV': 'Apple TV', \n 'Apple': 'Apple', + \n 'Telegram': 'Telegram', \n 'Crypto': 'Crypto', \n 'Discord': + 'Discord', \n 'Google FCM': 'Google FCM', \n 'Microsoft': 'Microsoft', + \n 'AI Suite': 'AI Suite', \n 'PayPal': 'PayPal', \n 'Scholar': + 'Scholar', \n 'Speedtest': 'Speedtest', \n 'Steam': 'Steam', \n + \ 'miHoYo': 'miHoYo', \n 'PROXY': 'Proxy', \n 'Domestic': + 'Domestic', \n 'Domestic IPs': 'Domestic', \n 'LAN': 'DIRECT'\n + \ }\n\n port = int(metadata['dst_port'])\n\n if metadata['network'] + == 'UDP' and port == 443:\n ctx.log('[Script] matched QUIC traffic use + reject')\n return 'REJECT'\n\n port_list = [21, 22, 23, 53, 80, 123, + 143, 194, 443, 465, 587, 853, 993, 995, 998, 2052, 2053, 2082, 2083, 2086, 2095, + 2096, 3389, 5222, 5228, 5229, 5230, 8080, 8443, 8880, 8888, 8889]\n if port + not in port_list:\n ctx.log('[Script] not common port use direct')\n return + 'DIRECT'\n\n if metadata['dst_ip'] == '':\n metadata['dst_ip'] = ctx.resolve_ip(metadata['host'])\n\n + \ for ruleset in ruleset_action:\n if ctx.rule_providers[ruleset].match(metadata):\n + \ return ruleset_action[ruleset]\n\n if metadata['dst_ip'] != '':\n + \ code = ctx.geoip(metadata['dst_ip'])\n if code == 'CN':\n ctx.log('[Script] + Geoip CN')\n return 'Domestic'\n\n ctx.log('[Script] FINAL')\n return + 'Others'\n" rule-providers: AdBlock: type: http @@ -214,6 +160,12 @@ rule-providers: url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Media/YouTube.yaml path: "./Rules/Media/YouTube" interval: 86400 + Max: + type: http + behavior: classical + url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Media/Max.yaml + path: "./Rules/Media/Max" + interval: 86400 Bilibili: type: http behavior: classical @@ -394,12 +346,6 @@ rule-providers: url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Media/Line%20TV.yaml path: "./Rules/Media/Line_TV" interval: 86400 - Max: - type: http - behavior: classical - url: https://testingcf.jsdelivr.net/gh/dler-io/Rules@main/Clash/Provider/Media/Max.yaml - path: "./Rules/Media/Max" - interval: 86400 myTV SUPER: type: http behavior: classical diff --git a/luci-app-openclash/root/usr/share/openclash/yml_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_change.sh index 9c749ab8e9..2c21fbfe03 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_change.sh @@ -341,7 +341,6 @@ threads << Thread.new { Value['log-level']='$9'; end; Value['allow-lan']=true; - Value['disable-keep-alive']=true; Value['external-controller']='0.0.0.0:$3'; Value['secret']='$2'; Value['bind-address']='*'; diff --git a/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh b/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh index f2aa46c12f..33080ab8a1 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh @@ -47,7 +47,7 @@ cfg_groups_set() sed -i "s/new_servers_group \'${convert_old_name_cfg}\'/new_servers_group \'${convert_name}\'/g" $CFG_FILE 2>/dev/null sed -i "s/relay_groups \'${convert_old_name_cfg}\'/relay_groups \'${convert_name}\'/g" $CFG_FILE 2>/dev/null #第三方规则处理 - OTHER_RULE_NAMES=("GlobalTV" "AsianTV" "Proxy" "Youtube" "Bilibili" "Bahamut" "HBOMax" "Pornhub" "Apple" "GoogleFCM" "Scholar" "Microsoft" "Netflix" "Disney" "Spotify" "Steam" "Speedtest" "Telegram" "PayPal" "Netease_Music" "AdBlock" "Domestic" "Others" "miHoYo" "AI_Suite" "AppleTV" "Crypto" "Discord" "HTTPDNS") + OTHER_RULE_NAMES=("GlobalTV" "AsianTV" "MainlandTV" "Proxy" "Youtube" "Bilibili" "Bahamut" "HBOMax" "Pornhub" "Apple" "GoogleFCM" "Scholar" "Microsoft" "Netflix" "Disney" "Spotify" "Steam" "Speedtest" "Telegram" "PayPal" "Netease_Music" "AdBlock" "Domestic" "Others" "miHoYo" "AI_Suite" "AppleTV" "Crypto" "Discord" "HTTPDNS") for i in ${OTHER_RULE_NAMES[@]}; do sed -i "s/option ${i} \'${convert_old_name_cfg}\'/option ${i} \'${convert_name}\'/g" $CFG_FILE 2>/dev/null done 2>/dev/null diff --git a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh index 306228d9e1..5f33d86e32 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh @@ -1577,7 +1577,7 @@ cat >> "$SERVER_FILE" <<-EOF - name: Bilibili type: select proxies: - - Asian TV + - CN Mainland TV - DIRECT EOF cat /tmp/Proxy_Server >> $SERVER_FILE 2>/dev/null @@ -1763,6 +1763,20 @@ cat >> "$SERVER_FILE" <<-EOF EOF fi cat /tmp/Proxy_Provider >> $SERVER_FILE 2>/dev/null +cat >> "$SERVER_FILE" <<-EOF + - name: CN Mainland TV + type: select + proxies: + - DIRECT + - Proxy +EOF +cat /tmp/Proxy_Server >> $SERVER_FILE 2>/dev/null +if [ -f "/tmp/Proxy_Provider" ]; then +cat >> "$SERVER_FILE" <<-EOF + use: +EOF +fi +cat /tmp/Proxy_Provider >> $SERVER_FILE 2>/dev/null cat >> "$SERVER_FILE" <<-EOF - name: Asian TV type: select @@ -1871,6 +1885,7 @@ ${uci_set}rule_name="lhie1" ${uci_set}config="$CONFIG_NAME" ${uci_set}GlobalTV="Global TV" ${uci_set}AsianTV="Asian TV" +${uci_set}MainlandTV="CN Mainland TV" ${uci_set}Proxy="Proxy" ${uci_set}Youtube="Youtube" ${uci_set}Bilibili="Bilibili" @@ -1911,6 +1926,7 @@ ${uci_set}Others="Others" ${UCI_DEL_LIST}="HBO Max" >/dev/null 2>&1 && ${UCI_ADD_LIST}="HBO Max" >/dev/null 2>&1 ${UCI_DEL_LIST}="Pornhub" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Pornhub" >/dev/null 2>&1 ${UCI_DEL_LIST}="Asian TV" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Asian TV" >/dev/null 2>&1 + ${UCI_DEL_LIST}="CN Mainland TV" >/dev/null 2>&1 && ${UCI_ADD_LIST}="CN Mainland TV" >/dev/null 2>&1 ${UCI_DEL_LIST}="Global TV" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Global TV" >/dev/null 2>&1 ${UCI_DEL_LIST}="Netflix" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Netflix" >/dev/null 2>&1 ${UCI_DEL_LIST}="Discovery Plus" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Discovery Plus" >/dev/null 2>&1 diff --git a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index 6b108a0429..f3b7cb2d3c 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -315,14 +315,15 @@ yml_other_set() Value['script']=Value_1['script']; Value['rules']=Value_1['rules']; Value['rules'].to_a.collect!{|x| - x.to_s.gsub(/,[\s]?Bilibili,[\s]?Asian TV$/, ', Bilibili, $Bilibili#delete_') - .gsub(/,[\s]?Bahamut,[\s]?Global TV$/, ', Bahamut, $Bahamut#delete_') - .gsub(/,[\s]?Max,[\s]?Global TV$/, ', Max, $HBOMax#delete_') + x.to_s.gsub(/,[\s]?Bilibili,[\s]?CN Mainland TV$/, ', Bilibili, $Bilibili#delete_') + .gsub(/,[\s]?Bahamut,[\s]?Asian TV$/, ', Bahamut, $Bahamut#delete_') + .gsub(/,[\s]?Max,[\s]?Max$/, ', Max, $HBOMax#delete_') .gsub(/,[\s]?Discovery Plus,[\s]?Global TV$/, ', Discovery Plus, $Discovery#delete_') .gsub(/,[\s]?DAZN,[\s]?Global TV$/, ', DAZN, $DAZN#delete_') .gsub(/,[\s]?Pornhub,[\s]?Global TV$/, ', Pornhub, $Pornhub#delete_') .gsub(/,[\s]?Global TV$/, ', $GlobalTV#delete_') .gsub(/,[\s]?Asian TV$/, ', $AsianTV#delete_') + .gsub(/,[\s]?CN Mainland TV$/, ', $MainlandTV#delete_') .gsub(/,[\s]?Proxy$/, ', $Proxy#delete_') .gsub(/,[\s]?YouTube$/, ', $Youtube#delete_') .gsub(/,[\s]?Apple$/, ', $Apple#delete_') @@ -347,14 +348,15 @@ yml_other_set() .gsub(/,[\s]?Google FCM$/, ', $GoogleFCM#delete_') .gsub(/#delete_/, '') }; - Value['script']['code'].to_s.gsub!(/\'Bilibili\': \'Asian TV\'/,'\'Bilibili\': \'$Bilibili#delete_\'') - .gsub!(/\'Bahamut\': \'Global TV\'/,'\'Bahamut\': \'$Bahamut#delete_\'') - .gsub!(/\'Max\': \'Global TV\'/,'\'Max\': \'$HBOMax#delete_\'') + Value['script']['code'].to_s.gsub!(/\'Bilibili\': \'CN Mainland TV\'/,'\'Bilibili\': \'$Bilibili#delete_\'') + .gsub!(/\'Bahamut\': \'Asian TV\'/,'\'Bahamut\': \'$Bahamut#delete_\'') + .gsub!(/\'Max\': \'Max\'/,'\'Max\': \'$HBOMax#delete_\'') .gsub!(/\'Discovery Plus\': \'Global TV\'/,'\'Discovery Plus\': \'$Discovery#delete_\'') .gsub!(/\'DAZN\': \'Global TV\'/,'\'DAZN\': \'$DAZN#delete_\'') .gsub!(/\'Pornhub\': \'Global TV\'/,'\'Pornhub\': \'$Pornhub#delete_\'') .gsub!(/: \'Global TV\'/,': \'$GlobalTV#delete_\'') .gsub!(/: \'Asian TV\'/,': \'$AsianTV#delete_\'') + .gsub!(/: \'CN Mainland TV\'/,': \'$MainlandTV#delete_\'') .gsub!(/: \'Proxy\'/,': \'$Proxy#delete_\'') .gsub!(/: \'YouTube\'/,': \'$Youtube#delete_\'') .gsub!(/: \'Apple\'/,': \'$Apple#delete_\'') @@ -871,6 +873,7 @@ yml_other_rules_get() config_get "rule_name" "$section" "rule_name" "" config_get "GlobalTV" "$section" "GlobalTV" "" config_get "AsianTV" "$section" "AsianTV" "" + config_get "MainlandTV" "$section" "MainlandTV" "DIRECT" config_get "Proxy" "$section" "Proxy" "" config_get "Youtube" "$section" "Youtube" "" config_get "Bilibili" "$section" "Bilibili" "" @@ -918,6 +921,7 @@ if [ "$1" != "0" ]; then elif [ "$rule_name" = "lhie1" ]; then if [ -z "$(grep -F "$GlobalTV" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$AsianTV" /tmp/Proxy_Group)" ]\ + || [ -z "$(grep -F "$MainlandTV" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$Proxy" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$Youtube" /tmp/Proxy_Group)" ]\ || [ -z "$(grep -F "$Bilibili" /tmp/Proxy_Group)" ]\ From 5a232b86d435ebad03fce1a4032dad0838585538 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:19:38 +0800 Subject: [PATCH 22/53] 0.46.055 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 71b182bf4c..a071ee2a82 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.054 +PKG_VERSION:=0.46.055 PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) From 46395938f8f976d89c144376c846bd44a289849c Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:32:54 +0800 Subject: [PATCH 23/53] chore: refine --- luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh index 5f33d86e32..184ff62689 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh @@ -1781,8 +1781,8 @@ cat >> "$SERVER_FILE" <<-EOF - name: Asian TV type: select proxies: - - DIRECT - Proxy + - DIRECT EOF cat /tmp/Proxy_Server >> $SERVER_FILE 2>/dev/null if [ -f "/tmp/Proxy_Provider" ]; then From 02180f3844e15c7965f669b94e6f2a4eb41e180a Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 30 Nov 2024 16:55:43 +0800 Subject: [PATCH 24/53] #4200 --- .../luasrc/controller/openclash.lua | 15 ++------------- .../model/cbi/openclash/config-overwrite.lua | 15 +-------------- .../luasrc/model/cbi/openclash/settings.lua | 14 +------------- luci-app-openclash/luasrc/openclash.lua | 19 +++++++++++++++++++ luci-app-openclash/root/etc/init.d/openclash | 6 +++--- .../root/etc/uci-defaults/luci-openclash | 3 ++- .../usr/share/openclash/openclash_debug.sh | 4 ++-- .../share/openclash/openclash_debug_dns.lua | 17 ++++------------- .../openclash/openclash_debug_getcon.lua | 15 ++------------- .../share/openclash/openclash_history_get.sh | 4 ++-- .../openclash/openclash_streaming_unlock.lua | 15 +-------------- 11 files changed, 39 insertions(+), 88 deletions(-) diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index db41259660..021529bda8 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -160,19 +160,8 @@ local function chnroutev6() end local function daip() - local daip, lan_int_name - lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" - if lan_int_name == "0" then - daip = luci.sys.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") - else - daip = luci.sys.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) - end - if not daip or daip == "" then - daip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") - end - if not daip or daip == "" then - daip = luci.sys.exec("ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") - end + local daip + daip = fs.lanip() return daip end diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua b/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua index 72b13a9156..16e49c9c74 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua @@ -17,20 +17,7 @@ bold_off = [[]] local op_mode = string.sub(luci.sys.exec('uci get openclash.config.operation_mode 2>/dev/null'),0,-2) if not op_mode then op_mode = "redir-host" end -local lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" - -local lan_ip -if lan_int_name == "0" then - lan_ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") -else - lan_ip = SYS.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) -end -if not lan_ip or lan_ip == "" then - lan_ip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") -end -if not lan_ip or lan_ip == "" then - lan_ip = luci.sys.exec("ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") -end +local lan_ip = fs.lanip() m = Map("openclash", translate("Overwrite Settings")) m.pageaction = false m.description = translate("Note: To restore the default configuration, try accessing:").." http://"..lan_ip.."/cgi-bin/luci/admin/services/openclash/restore".. diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua index d69cdaf14a..130f735819 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua @@ -16,19 +16,7 @@ bold_off = [[]] local op_mode = string.sub(luci.sys.exec('uci get openclash.config.operation_mode 2>/dev/null'),0,-2) if not op_mode then op_mode = "redir-host" end -local lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" -local lan_ip -if lan_int_name == "0" then - lan_ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") -else - lan_ip = SYS.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) -end -if not lan_ip or lan_ip == "" then - lan_ip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") -end -if not lan_ip or lan_ip == "" then - lan_ip = luci.sys.exec("ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") -end +local lan_ip = fs.lanip() m = Map("openclash", translate("Plugin Settings")) m.pageaction = false m.description = translate("Note: To restore the default configuration, try accessing:").." http://"..lan_ip.."/cgi-bin/luci/admin/services/openclash/restore".. diff --git a/luci-app-openclash/luasrc/openclash.lua b/luci-app-openclash/luasrc/openclash.lua index 5142a86e4c..ad7b7320ba 100644 --- a/luci-app-openclash/luasrc/openclash.lua +++ b/luci-app-openclash/luasrc/openclash.lua @@ -29,6 +29,8 @@ local os = require "os" local ltn12 = require "luci.ltn12" local fs = require "nixio.fs" local nutil = require "nixio.util" +local uci = require "luci.model.uci".cursor() +local SYS = require "luci.sys" local type = type local string = string @@ -261,4 +263,21 @@ function filesize(e) t=t+1 until(e<=1024) return string.format("%.1f",e)..a[t] +end + +function lanip() + local lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" + local lan_ip + if lan_int_name == "0" then + lan_ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") + else + lan_ip = SYS.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' |head -1 | tr -d '\n'", lan_int_name)) + end + if not lan_ip or lan_ip == "" then + lan_ip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' |head -1 | tr -d '\n'") + end + if not lan_ip or lan_ip == "" then + lan_ip = luci.sys.exec("ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") + end + return lan_ip end \ No newline at end of file diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index cee99caf17..9e8250163c 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -2881,9 +2881,9 @@ get_config() lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo 0) if [ "$lan_interface_name" = "0" ]; then - lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) + lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' |head -1 || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) else - lan_ip=$(ip address show $lan_interface_name | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') + lan_ip=$(ip address show $lan_interface_name | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' |head -1) fi wan_ip4s=$(/usr/share/openclash/openclash_get_network.lua "wanip" 2>/dev/null) @@ -2923,7 +2923,7 @@ get_config() enable_respect_rules=$(uci -q get openclash.config.enable_respect_rules || echo 0) intranet_allowed_wan_name=$(uci -q get openclash.config.intranet_allowed_wan_name || echo 0) custom_fakeip_filter_mode=$(uci -q get openclash.config.custom_fakeip_filter_mode || echo "blacklist") - iptables_compat=$(iptables -m owner -h| grep "owner match options" || echo 0) + iptables_compat=$(iptables -m owner -h 2>/dev/null | grep "owner match options" || echo 0) [ -z "$dns_port" ] && dns_port=7874 && uci -q set openclash.config.dns_port=7874 uci -q commit openclash } diff --git a/luci-app-openclash/root/etc/uci-defaults/luci-openclash b/luci-app-openclash/root/etc/uci-defaults/luci-openclash index 2164aec908..daf4cfb434 100644 --- a/luci-app-openclash/root/etc/uci-defaults/luci-openclash +++ b/luci-app-openclash/root/etc/uci-defaults/luci-openclash @@ -47,7 +47,7 @@ EOF uci -q set openclash.config.dashboard_password="$(tr -cd 'a-zA-Z0-9' /dev/null| head -c8 || date +%N| md5sum |head -c8)" #Set authentication -uci_name_tmp=$(uci add openclash authentication) +uci_name_tmp=$(uci -q add openclash authentication) uci_set="uci -q set openclash.$uci_name_tmp." ${uci_set}enabled="1" ${uci_set}username="Clash" @@ -123,6 +123,7 @@ if [ -f "/tmp/openclash.bak" ]; then rm -rf "/etc/openclash/custom/openclash_sniffing_ports_filter.yaml" >/dev/null 2>&1 rm -rf "/etc/openclash/custom/openclash_sniffing_port_filter.yaml" >/dev/null 2>&1 rm -rf "/etc/openclash/custom/openclash_sniffing_domain_filter.yaml" >/dev/null 2>&1 + rm -rf "/etc/config/openclash.apk-new" >/dev/null 2>&1 fi uci -q set openclash.config.enable=0 diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh index ba7bb18dea..22c83fc6e6 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh @@ -57,9 +57,9 @@ da_password=$(uci -q get openclash.config.dashboard_password) cn_port=$(uci -q get openclash.config.cn_port) lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo "0") if [ "$lan_interface_name" = "0" ]; then - lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) + lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' |head -1 || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) else - lan_ip=$(ip address show $lan_interface_name | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') + lan_ip=$(ip address show $lan_interface_name | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' |head -1) fi dnsmasq_default_resolvfile=$(uci -q get openclash.config.default_resolvfile) diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua b/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua index 8c91fa8d65..523456fb19 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug_dns.lua @@ -6,23 +6,14 @@ require "luci.sys" local uci = require("luci.model.uci").cursor() local json = require "luci.jsonc" local datatype = require "luci.cbi.datatypes" +local fs = require "luci.openclash" + local addr = arg[1] local resolve = arg[2] local function debug_dns() - local info, ip, host, lan_int_name - lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" - if lan_int_name == "0" then - ip = luci.sys.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") - else - ip = luci.sys.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) - end - if not ip or ip == "" then - ip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") - end - if not ip or ip == "" then - ip = luci.sys.exec("ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") - end + local info, ip, host + ip = fs.lanip() local port = uci:get("openclash", "config", "cn_port") local passwd = uci:get("openclash", "config", "dashboard_password") or "" diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug_getcon.lua b/luci-app-openclash/root/usr/share/openclash/openclash_debug_getcon.lua index e528688828..bbc62e0c4d 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug_getcon.lua +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug_getcon.lua @@ -20,19 +20,8 @@ return string.format("%.1f",e)..a[t] end local function debug_getcon() - local info, ip, host, diag_info, lan_int_name - lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0" - if lan_int_name == "0" then - ip = luci.sys.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") - else - ip = luci.sys.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) - end - if not ip or ip == "" then - ip = luci.sys.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") - end - if not ip or ip == "" then - ip = luci.sys.exec("ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") - end + local info, ip, host, diag_info + ip = fs.lanip() local port = uci:get("openclash", "config", "cn_port") local passwd = uci:get("openclash", "config", "dashboard_password") or "" if ip and port then diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh index 04e11731b6..a7f4bfd91f 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh @@ -16,9 +16,9 @@ close_all_conection() { SECRET=$(uci -q get openclash.config.dashboard_password) lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo "0") if [ "$lan_interface_name" = "0" ]; then - LAN_IP=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) + LAN_IP=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' |head -1 || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) else - LAN_IP=$(ip address show $lan_interface_name | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}') + LAN_IP=$(ip address show $lan_interface_name | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' |head -1) fi PORT=$(uci -q get openclash.config.cn_port) curl -m 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X DELETE http://"$LAN_IP":"$PORT"/connections >/dev/null 2>&1 diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_streaming_unlock.lua b/luci-app-openclash/root/usr/share/openclash/openclash_streaming_unlock.lua index 7a3069e3f4..4d50d22f6b 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_streaming_unlock.lua +++ b/luci-app-openclash/root/usr/share/openclash/openclash_streaming_unlock.lua @@ -769,20 +769,7 @@ end function get_auth_info() port = UCI:get("openclash", "config", "cn_port") passwd = UCI:get("openclash", "config", "dashboard_password") or "" - local lan_int_name = UCI:get("openclash", "config", "lan_interface_name") or "0" - if lan_int_name == "0" then - ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'") - else - ip = SYS.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name)) - end - - if not ip or ip == "" then - ip = SYS.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'") - end - - if not ip or ip == "" then - ip = SYS.exec("ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n'") - end + ip = FS.lanip() if not ip or not port then os.exit(0) end From 7a0a5ce6fcca694849dd7934a2fb7cc77e8d97bc Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 30 Nov 2024 17:03:57 +0800 Subject: [PATCH 25/53] chore: refine --- .../usr/share/openclash/openclash_rule.sh | 2 +- .../root/usr/share/openclash/res/lhie1.yaml | 38 ------------------- .../usr/share/openclash/yml_rules_change.sh | 34 ----------------- 3 files changed, 1 insertion(+), 73 deletions(-) diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh b/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh index e6c95ee42e..a75af2d14a 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh @@ -99,7 +99,7 @@ fi #取出规则部分 - ruby_read "/tmp/rules.yaml" ".select {|x| 'rule-providers' == x or 'script' == x or 'rules' == x }.to_yaml" > "$OTHER_RULE_FILE" + ruby_read "/tmp/rules.yaml" ".select {|x| 'rule-providers' == x or 'rules' == x }.to_yaml" > "$OTHER_RULE_FILE" #合并 cat "$OTHER_RULE_FILE" > "/tmp/rules.yaml" 2>/dev/null rm -rf /tmp/other_rule* 2>/dev/null diff --git a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml index 0b5e58f495..75aa6d897b 100644 --- a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml +++ b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml @@ -61,44 +61,6 @@ rules: - RULE-SET, LAN, DIRECT - GEOIP, CN, Domestic - MATCH, Others -script: - code: "def main(ctx, metadata):\n ruleset_action = {\n 'AdBlock': 'AdBlock', - \n 'HTTPDNS': 'HTTPDNS', \n 'Special': 'DIRECT', \n 'Netflix': - 'Netflix', \n 'Disney Plus': 'Disney', \n 'YouTube': 'YouTube', - \n 'Max': 'Max', \n 'Spotify': 'Spotify', \n 'Bilibili': - 'CN Mainland TV', \n 'IQ': 'CN Mainland TV', \n 'IQIYI': 'CN Mainland - TV', \n 'Letv': 'CN Mainland TV', \n 'Netease Music': 'CN Mainland - TV', \n 'Tencent Video': 'CN Mainland TV', \n 'Youku': 'CN Mainland - TV', \n 'WeTV': 'CN Mainland TV', \n 'Abema TV': 'Asian TV', \n - \ 'Bahamut': 'Asian TV', \n 'Fox+': 'Asian TV', \n 'Hulu Japan': - 'Asian TV', \n 'Japonx': 'Asian TV', \n 'JOOX': 'Asian TV', \n 'KKBOX': - 'Asian TV', \n 'KKTV': 'Asian TV', \n 'Line TV': 'Asian TV', \n - \ 'myTV SUPER': 'Asian TV', \n 'Niconico': 'Asian TV', \n 'ViuTV': - 'Asian TV', \n 'ABC': 'Global TV', \n 'Amazon': 'Global TV', \n - \ 'BBC iPlayer': 'Global TV', \n 'DAZN': 'Global TV', \n 'Discovery - Plus': 'Global TV', \n 'encoreTVB': 'Global TV', \n 'F1 TV': 'Global - TV', \n 'Fox Now': 'Global TV', \n 'Hulu': 'Global TV', \n 'Pandora': - 'Global TV', \n 'PBS': 'Global TV', \n 'Pornhub': 'Global TV', \n - \ 'Soundcloud': 'Global TV', \n 'Apple Music': 'Apple TV', \n 'Apple - News': 'Apple TV', \n 'Apple TV': 'Apple TV', \n 'Apple': 'Apple', - \n 'Telegram': 'Telegram', \n 'Crypto': 'Crypto', \n 'Discord': - 'Discord', \n 'Google FCM': 'Google FCM', \n 'Microsoft': 'Microsoft', - \n 'AI Suite': 'AI Suite', \n 'PayPal': 'PayPal', \n 'Scholar': - 'Scholar', \n 'Speedtest': 'Speedtest', \n 'Steam': 'Steam', \n - \ 'miHoYo': 'miHoYo', \n 'PROXY': 'Proxy', \n 'Domestic': - 'Domestic', \n 'Domestic IPs': 'Domestic', \n 'LAN': 'DIRECT'\n - \ }\n\n port = int(metadata['dst_port'])\n\n if metadata['network'] - == 'UDP' and port == 443:\n ctx.log('[Script] matched QUIC traffic use - reject')\n return 'REJECT'\n\n port_list = [21, 22, 23, 53, 80, 123, - 143, 194, 443, 465, 587, 853, 993, 995, 998, 2052, 2053, 2082, 2083, 2086, 2095, - 2096, 3389, 5222, 5228, 5229, 5230, 8080, 8443, 8880, 8888, 8889]\n if port - not in port_list:\n ctx.log('[Script] not common port use direct')\n return - 'DIRECT'\n\n if metadata['dst_ip'] == '':\n metadata['dst_ip'] = ctx.resolve_ip(metadata['host'])\n\n - \ for ruleset in ruleset_action:\n if ctx.rule_providers[ruleset].match(metadata):\n - \ return ruleset_action[ruleset]\n\n if metadata['dst_ip'] != '':\n - \ code = ctx.geoip(metadata['dst_ip'])\n if code == 'CN':\n ctx.log('[Script] - Geoip CN')\n return 'Domestic'\n\n ctx.log('[Script] FINAL')\n return - 'Others'\n" rule-providers: AdBlock: type: http diff --git a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index f3b7cb2d3c..586d2d8566 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -312,7 +312,6 @@ yml_other_set() Value['rule-providers']=Value_1['rule-providers'] end end; - Value['script']=Value_1['script']; Value['rules']=Value_1['rules']; Value['rules'].to_a.collect!{|x| x.to_s.gsub(/,[\s]?Bilibili,[\s]?CN Mainland TV$/, ', Bilibili, $Bilibili#delete_') @@ -348,39 +347,6 @@ yml_other_set() .gsub(/,[\s]?Google FCM$/, ', $GoogleFCM#delete_') .gsub(/#delete_/, '') }; - Value['script']['code'].to_s.gsub!(/\'Bilibili\': \'CN Mainland TV\'/,'\'Bilibili\': \'$Bilibili#delete_\'') - .gsub!(/\'Bahamut\': \'Asian TV\'/,'\'Bahamut\': \'$Bahamut#delete_\'') - .gsub!(/\'Max\': \'Max\'/,'\'Max\': \'$HBOMax#delete_\'') - .gsub!(/\'Discovery Plus\': \'Global TV\'/,'\'Discovery Plus\': \'$Discovery#delete_\'') - .gsub!(/\'DAZN\': \'Global TV\'/,'\'DAZN\': \'$DAZN#delete_\'') - .gsub!(/\'Pornhub\': \'Global TV\'/,'\'Pornhub\': \'$Pornhub#delete_\'') - .gsub!(/: \'Global TV\'/,': \'$GlobalTV#delete_\'') - .gsub!(/: \'Asian TV\'/,': \'$AsianTV#delete_\'') - .gsub!(/: \'CN Mainland TV\'/,': \'$MainlandTV#delete_\'') - .gsub!(/: \'Proxy\'/,': \'$Proxy#delete_\'') - .gsub!(/: \'YouTube\'/,': \'$Youtube#delete_\'') - .gsub!(/: \'Apple\'/,': \'$Apple#delete_\'') - .gsub!(/: \'Apple TV\'/,': \'$AppleTV#delete_\'') - .gsub!(/: \'Scholar\'/,': \'$Scholar#delete_\'') - .gsub!(/: \'Netflix\'/,': \'$Netflix#delete_\'') - .gsub!(/: \'Disney\'/,': \'$Disney#delete_\'') - .gsub!(/: \'Spotify\'/,': \'$Spotify#delete_\'') - .gsub!(/: \'AI Suite\'/,': \'$AI_Suite#delete_\'') - .gsub!(/: \'Steam\'/,': \'$Steam#delete_\'') - .gsub!(/: \'miHoYo\'/,': \'$miHoYo#delete_\'') - .gsub!(/: \'AdBlock\'/,': \'$AdBlock#delete_\'') - .gsub!(/: \'HTTPDNS\'/,': \'$HTTPDNS#delete_\'') - .gsub!(/: \'Speedtest\'/,': \'$Speedtest#delete_\'') - .gsub!(/: \'Telegram\'/,': \'$Telegram#delete_\'') - .gsub!(/: \'Crypto\'/,': \'$Crypto#delete_\'') - .gsub!(/: \'Discord\'/,': \'$Discord#delete_\'') - .gsub!(/: \'Microsoft\'/,': \'$Microsoft#delete_\'') - .gsub!(/: \'PayPal\'/,': \'$PayPal#delete_\'') - .gsub!(/: \'Domestic\'/,': \'$Domestic#delete_\'') - .gsub!(/: \'Google FCM\'/,': \'$GoogleFCM#delete_\'') - .gsub!(/return \'Domestic\'$/, 'return \'$Domestic#delete_\'') - .gsub!(/return \'Others\'$/, 'return \'$Others#delete_\'') - .gsub!(/#delete_/, ''); end; rescue Exception => e YAML.LOG('Error: Set lhie1 Rules Failed,【' + e.message + '】'); From 5c7bd73d9945c8c2bf704ff63f31c7e4a681c43a Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 1 Dec 2024 01:33:17 +0800 Subject: [PATCH 26/53] fix error --- luci-app-openclash/Makefile | 1 + .../luasrc/model/cbi/openclash/servers.lua | 15 ++++++++------ .../usr/share/openclash/yml_proxys_get.sh | 20 +++++++++---------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index a071ee2a82..a957c7b614 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -127,6 +127,7 @@ define Package/$(PKG_NAME)/postrm DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) DNSMASQ_CONF_DIR=${DNSMASQ_CONF_DIR%*/} rm -rf /etc/openclash >/dev/null 2>&1 + rm -rf /etc/config/openclash >/dev/null 2>&1 rm -rf /tmp/openclash.log >/dev/null 2>&1 rm -rf /tmp/openclash_start.log >/dev/null 2>&1 rm -rf /tmp/openclash_last_version >/dev/null 2>&1 diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua b/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua index 3e28e08f6a..00a16cf337 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua @@ -255,24 +255,27 @@ o = a:option(Button,"Load_Config", " ") o.inputtitle = translate("Read Config") o.inputstyle = "apply" o.write = function() - luci.sys.call("/usr/share/openclash/yml_groups_get.sh 2>/dev/null &") - luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash")) + m.uci:commit("openclash") + luci.sys.call("/usr/share/openclash/yml_groups_get.sh 2>/dev/null &") + luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash")) end o = a:option(Button, "Commit", " ") o.inputtitle = translate("Commit Settings") o.inputstyle = "apply" o.write = function() - fs.unlink("/tmp/Proxy_Group") + fs.unlink("/tmp/Proxy_Group") + m.uci:commit("openclash") end o = a:option(Button, "Apply", " ") o.inputtitle = translate("Apply Settings") o.inputstyle = "apply" o.write = function() - fs.unlink("/tmp/Proxy_Group") - luci.sys.call("/usr/share/openclash/yml_groups_set.sh >/dev/null 2>&1 &") - luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash")) + m.uci:commit("openclash") + fs.unlink("/tmp/Proxy_Group") + luci.sys.call("/usr/share/openclash/yml_groups_set.sh >/dev/null 2>&1 &") + luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash")) end m:append(Template("openclash/toolbar_show")) diff --git a/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh b/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh index aa9b44ca80..6fd9bbf9a2 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh @@ -171,8 +171,8 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " begin YAML.LOG('Start Getting【${CONFIG_NAME} - ' + y['type'].to_s + ' - ' + x.to_s + '】Proxy-provider Setting...'); #代理集存在时获取代理集编号 - cmd = 'grep -E \'\.' + x + '$\' ${match_provider} 2>/dev/null|awk -F \".\" \'{print \$1}\''; - provider_nums=%x(#{cmd}).chomp; + cmd = 'grep -F \'.' + x + '\' ${match_provider} 2>/dev/null |awk -F \".\" \'{print \$1}\''; + provider_nums = %x(#{cmd}).chomp; if not provider_nums.empty? then cmd = 'sed -i \"/^' + provider_nums + '\./c\\#match#\" $match_provider 2>/dev/null'; system(cmd); @@ -181,7 +181,7 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " uci_add='uci -q add_list openclash.@proxy-provider[' + provider_nums + '].'; uci_del='uci -q delete openclash.@proxy-provider[' + provider_nums + '].'; cmd = uci_get + 'manual'; - if not %x(#{cmd}).chomp then + if not provider_nums then uci_commands << uci_set + 'manual=0'; end; uci_commands << uci_set + 'type=\"' + y['type'].to_s + '\"'; @@ -269,7 +269,7 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " #新代理集且设置默认策略组时加入指定策略组 new_provider_groups = %x{uci get openclash.config.new_servers_group}.chomp.split(\"'\").map { |x| x.strip }.reject { |x| x.empty? }; new_provider_groups.each do |x| - uci_commands << uci_add + 'groups=\"' + x + '\"' + uci_commands << uci_add + 'groups=\"^' + x + '$\"' end elsif '$servers_if_update' != '1' then threads_agr = []; @@ -304,8 +304,8 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " begin YAML.LOG('Start Getting【${CONFIG_NAME} - ' + x['type'].to_s + ' - ' + x['name'].to_s + '】Proxy Setting...'); #节点存在时获取节点编号 - cmd = 'grep -E \'\.' + x['name'].to_s + '$\' ${match_servers} 2>/dev/null|awk -F \".\" \'{print \$1}\''; - server_num=%x(#{cmd}).chomp; + cmd = 'grep -F \'.' + x['name'].to_s + '\' ${match_servers} 2>/dev/null |awk -F \".\" \'{print \$1}\''; + server_num = %x(#{cmd}).chomp; if not server_num.empty? then #更新已有节点 cmd = 'sed -i \"/^' + server_num + '\./c\\#match#\" $match_servers 2>/dev/null'; @@ -315,7 +315,7 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " uci_add='uci -q add_list openclash.@servers[' + server_num + '].'; uci_del='uci -q delete openclash.@servers[' + server_num + '].'; cmd = uci_get + 'manual'; - if not %x(#{cmd}).chomp then + if not server_num then uci_commands << uci_set + 'manual=0'; end; else @@ -1329,10 +1329,10 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " threads << Thread.new{ #加入策略组 if '$servers_if_update' == '1' and '$config_group_exist' == '1' and '$servers_update' == '1' and server_num.empty? then - #新代理集且设置默认策略组时加入指定策略组 + #新代理且设置默认策略组时加入指定策略组 new_provider_groups = %x{uci get openclash.config.new_servers_group}.chomp.split(\"'\").map { |x| x.strip }.reject { |x| x.empty? }; new_provider_groups.each do |x| - uci_commands << uci_add + 'groups=\"' + x + '\"' + uci_commands << uci_add + 'groups=\"^' + x + '$\"' end elsif '$servers_if_update' != '1' then threads_gr = []; @@ -1345,7 +1345,7 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " z['proxies'].each{ |v| if v == x['name'] then - uci_commands << uci_add + 'groups=^\"' + z['name'] + '$\"' + uci_commands << uci_add + 'groups=\"^' + z['name'] + '$\"' break end } From 20000349e9e553d6c7c88f900dc87f5e558e649b Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 1 Dec 2024 01:54:10 +0800 Subject: [PATCH 27/53] chore: refine --- luci-app-openclash/root/usr/share/openclash/yml_groups_get.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/luci-app-openclash/root/usr/share/openclash/yml_groups_get.sh b/luci-app-openclash/root/usr/share/openclash/yml_groups_get.sh index 07cb743742..d19545f2e8 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_groups_get.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_groups_get.sh @@ -242,7 +242,8 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " x['proxies'].each{ |y| if Value_1.include?(y) then - uci_commands << uci_add + 'other_group=\"^' + y.to_s + '$\"' + commands = uci_add + 'other_group=\"^' + y.to_s + '$\"' + system(commands) end } end From 35d6593f9f7c13afc2c71342035fd5cbd11e108f Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 3 Dec 2024 12:39:47 +0800 Subject: [PATCH 28/53] 0.46.056 --- luci-app-openclash/Makefile | 2 +- .../luasrc/controller/openclash.lua | 9 +++++++++ .../luasrc/model/cbi/openclash/settings.lua | 4 ++++ .../luasrc/view/openclash/update.htm | 7 ++++++- luci-app-openclash/po/zh-cn/openclash.zh-cn.po | 11 ++++++++++- luci-app-openclash/root/etc/init.d/openclash | 15 ++++++++++++++- .../root/usr/share/openclash/yml_change.sh | 2 ++ 7 files changed, 46 insertions(+), 4 deletions(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index a957c7b614..e8fa311932 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.055 +PKG_VERSION:=0.46.056 PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index 021529bda8..d9b5c83eaa 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -203,6 +203,14 @@ local function startlog() return line_trans end +local funciton pkg_type() + if fs.access("/usr/bin/apk") then + return "apk" + else + return "opkg" + end +end + local function coremodel() if opkg and opkg.info("libc") and opkg.info("libc")["libc"] then return opkg.info("libc")["libc"]["Architecture"] @@ -1079,6 +1087,7 @@ function action_update_ma() luci.http.prepare_content("application/json") luci.http.write_json({ oplv = oplv(), + pkg_type = pkg_type(), corelv = corelv(), corever = corever(); }) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua index 130f735819..f21fc8da11 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua @@ -95,6 +95,10 @@ o = s:taboption("op_mode", Value, "log_size", translate("Log Size (KB)")) o.description = translate("Set Log File Size (KB)") o.default = "1024" +o = s:taboption("op_mode", Flag, "test_before_start", translate("Test Before Start")) +o.description = translate("Test Config Before Core Start") +o.default = 0 + o = s:taboption("op_mode", Flag, "bypass_gateway_compatible", translate("Bypass Gateway Compatible")) o.description = translate("If The Network Cannot be Connected in Bypass Gateway Mode, Please Try to Enable.")..font_red..bold_on..translate("Suggestion: If The Device Does Not Have WLAN, Please Disable The Lan Interface's Bridge Option")..bold_off..font_off o.default = 0 diff --git a/luci-app-openclash/luasrc/view/openclash/update.htm b/luci-app-openclash/luasrc/view/openclash/update.htm index fb1b3a5d29..40554e2927 100644 --- a/luci-app-openclash/luasrc/view/openclash/update.htm +++ b/luci-app-openclash/luasrc/view/openclash/update.htm @@ -346,7 +346,12 @@ var oplv = status.oplv; var oplvis = oplv.substring(oplv.indexOf("v") + 1,oplv.indexOf(",")); if ( oplvis != "" ) { - url2='https://raw.githubusercontent.com/vernesong/OpenClash/package/'+r+'/luci-app-openclash_'+oplvis+'_all.ipk'; + if (status.pkg_type == "apk") { + url2='https://raw.githubusercontent.com/vernesong/OpenClash/package/'+r+'/luci-app-openclash-'+oplvis+'.apk'; + } + else { + url2='https://raw.githubusercontent.com/vernesong/OpenClash/package/'+r+'/luci-app-openclash_'+oplvis+'_all.ipk'; + } window.location.href=url2; } else { diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index 2d452bfaad..b59cba69b4 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -3051,6 +3051,9 @@ msgstr "警告:TUN 接口启动失败,请检查依赖情况或稍后重试 msgid "Warning: TUN Interface Start Failed, Try to Restart Again..." msgstr "警告:TUN 接口启动失败,尝试重启内核..." +msgid "Error: Core Start Failed, Please Check The Log Infos!" +msgstr "错误:内核启动失败,请查看《内核日志》排查失败原因!" + msgid "Forced Sniff Pure IP Connections" msgstr "强制探测(嗅探)所有纯 IP 的连接" @@ -3427,4 +3430,10 @@ msgid "Direct" msgstr "直连" msgid "Error: Config File Overwrite Failed," -msgstr "错误:配置文件覆写失败," \ No newline at end of file +msgstr "错误:配置文件覆写失败," + +msgid "Test Config Before Core Start" +msgstr "启动前调用内核测试配置文件" + +msgid "Test Before Start" +msgstr "启动前测试" \ No newline at end of file diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index 9e8250163c..2e4991c26f 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -662,7 +662,7 @@ do_run_file() config_test() { - if [ -f "$CLASH" ]; then + if [ -f "$CLASH" ] && [ "$test_before_start" -eq 1 ]; then LOG_OUT "Test The Config File First..." test_info=$(nohup $CLASH -t -d $CLASH_CONFIG -f "$CONFIG_FILE") local IFS=$'\n' @@ -783,6 +783,7 @@ check_core_status() { TUN_WAIT=0 TUN_RESTART=1 + CORE_HTTP_CODE=0 if [ -n "$en_mode_tun" ] || [ "$ipv6_mode" -eq 2 ] || [ "$ipv6_mode" -eq 3 ]; then if [ -n "$en_mode_tun" ]; then ip_="ip" @@ -824,6 +825,17 @@ check_core_status() ip route add default dev utun table "$PROXY_ROUTE_TABLE" ip rule add fwmark "$PROXY_FWMARK" ipproto icmp table main pref 8000 ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" pref 8001 + else + while ( [ -n "$(pidof clash)" ] && [ "$CORE_HTTP_CODE" != "200" ] && [ "$TUN_RESTART" -le 120 ] ) + do + CORE_HTTP_CODE=$(curl -m 5 -o /dev/null -s -w '%{http_code}' -H 'Content-Type: application/json' -H "Authorization: Bearer ${da_password}" -XGET http://${lan_ip}:${cn_port}/group) + let TUN_WAIT++ + sleep 1 + done >/dev/null 2>&1 + if [ -z "$(pidof clash)" ]; then + LOG_OUT "Error: Core Start Failed, Please Check The Log Infos!" + start_fail + fi fi } @@ -2924,6 +2936,7 @@ get_config() intranet_allowed_wan_name=$(uci -q get openclash.config.intranet_allowed_wan_name || echo 0) custom_fakeip_filter_mode=$(uci -q get openclash.config.custom_fakeip_filter_mode || echo "blacklist") iptables_compat=$(iptables -m owner -h 2>/dev/null | grep "owner match options" || echo 0) + test_before_start=$(uci -q get openclash.config.test_before_start || echo 0) [ -z "$dns_port" ] && dns_port=7874 && uci -q set openclash.config.dns_port=7874 uci -q commit openclash } diff --git a/luci-app-openclash/root/usr/share/openclash/yml_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_change.sh index 2c21fbfe03..e46220bce9 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_change.sh @@ -345,6 +345,8 @@ threads << Thread.new { Value['secret']='$2'; Value['bind-address']='*'; Value['external-ui']='/usr/share/openclash/ui'; + Value['keep-alive-interval']=15; + Value['keep-alive-idle']=600; if $6 == 1 then Value['ipv6']=true; else From 8194e7c4c6a248ee9a5cd5ae08f9403078661dd1 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:19:01 +0800 Subject: [PATCH 29/53] 0.46.057 --- luci-app-openclash/Makefile | 2 +- luci-app-openclash/luasrc/controller/openclash.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index e8fa311932..d3a8c88030 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.056 +PKG_VERSION:=0.46.057 PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index d9b5c83eaa..36bf3aa622 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -203,7 +203,7 @@ local function startlog() return line_trans end -local funciton pkg_type() +local function pkg_type() if fs.access("/usr/bin/apk") then return "apk" else From 200707ff0fa13e90f8fb26405998cbd8f5f5bb52 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:26:55 +0800 Subject: [PATCH 30/53] chore: delete old geosite database before installed restoring --- luci-app-openclash/root/etc/uci-defaults/luci-openclash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/luci-app-openclash/root/etc/uci-defaults/luci-openclash b/luci-app-openclash/root/etc/uci-defaults/luci-openclash index daf4cfb434..5776004497 100644 --- a/luci-app-openclash/root/etc/uci-defaults/luci-openclash +++ b/luci-app-openclash/root/etc/uci-defaults/luci-openclash @@ -98,6 +98,8 @@ uci -q commit openclash #Restore if [ -f "/tmp/openclash.bak" ]; then + #delete old geosite database first + rm -rf "/tmp/openclash/GeoSite.dat" >/dev/null 2>&1 mv -f "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1 cp -rf "/tmp/openclash/." "/etc/openclash/" >/dev/null 2>&1 if [ -d "/tmp/openclash_dashboard/" ]; then From 4adeb2732dfacd3acf26b73e95dfdc1c4e1cf7c7 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Fri, 6 Dec 2024 08:24:30 +0800 Subject: [PATCH 31/53] chore: update lhie1 rule --- .../usr/share/openclash/openclash_rule.sh | 4 +- .../root/usr/share/openclash/res/lhie1.yaml | 124 +++++++++--------- .../usr/share/openclash/yml_rules_change.sh | 62 ++++----- 3 files changed, 95 insertions(+), 95 deletions(-) diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh b/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh index a75af2d14a..b43fbd2c8e 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh @@ -79,8 +79,8 @@ elif ! "$(ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " Value = YAML.load_file('/usr/share/openclash/res/${rule_name}.yaml'); Value_1 = YAML.load_file('/tmp/rules.yaml'); - OLD_GROUP = Value['rules'].collect{|x| x.split(',')[2] or x.split(',')[1]}.uniq; - NEW_GROUP = Value_1['rules'].collect{|x| x.split(',')[2] or x.split(',')[1]}.uniq; + OLD_GROUP = Value['rules'].collect{|x| x.split(',')[2] or x.split(',')[1]}.uniq.map(&:strip); + NEW_GROUP = Value_1['rules'].collect{|x| x.split(',')[2] or x.split(',')[1]}.uniq.map(&:strip); if (OLD_GROUP | NEW_GROUP).eql?(OLD_GROUP) then if (OLD_GROUP | NEW_GROUP).eql?(NEW_GROUP) then puts true diff --git a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml index 75aa6d897b..b5570efca8 100644 --- a/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml +++ b/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml @@ -1,66 +1,66 @@ rules: -- RULE-SET, AdBlock, AdBlock -- RULE-SET, HTTPDNS, HTTPDNS -- RULE-SET, Special, DIRECT -- RULE-SET, Netflix, Netflix -- RULE-SET, Disney Plus, Disney -- RULE-SET, YouTube, YouTube -- RULE-SET, Max, Max -- RULE-SET, Spotify, Spotify -- RULE-SET, Bilibili, CN Mainland TV -- RULE-SET, IQ, CN Mainland TV -- RULE-SET, IQIYI, CN Mainland TV -- RULE-SET, Letv, CN Mainland TV -- RULE-SET, Netease Music, CN Mainland TV -- RULE-SET, Tencent Video, CN Mainland TV -- RULE-SET, WeTV, CN Mainland TV -- RULE-SET, Youku, CN Mainland TV -- RULE-SET, Abema TV, Asian TV -- RULE-SET, Bahamut, Asian TV -- RULE-SET, Fox+, Asian TV -- RULE-SET, Hulu Japan, Asian TV -- RULE-SET, Japonx, Asian TV -- RULE-SET, JOOX, Asian TV -- RULE-SET, KKBOX, Asian TV -- RULE-SET, KKTV, Asian TV -- RULE-SET, Line TV, Asian TV -- RULE-SET, myTV SUPER, Asian TV -- RULE-SET, Niconico, Asian TV -- RULE-SET, ViuTV, Asian TV -- RULE-SET, ABC, Global TV -- RULE-SET, Amazon, Global TV -- RULE-SET, BBC iPlayer, Global TV -- RULE-SET, DAZN, Global TV -- RULE-SET, Discovery Plus, Global TV -- RULE-SET, encoreTVB, Global TV -- RULE-SET, F1 TV, Global TV -- RULE-SET, Fox Now, Global TV -- RULE-SET, Hulu, Global TV -- RULE-SET, Pandora, Global TV -- RULE-SET, PBS, Global TV -- RULE-SET, Pornhub, Global TV -- RULE-SET, Soundcloud, Global TV -- RULE-SET, Apple Music, Apple TV -- RULE-SET, Apple News, Apple TV -- RULE-SET, Apple TV, Apple TV -- RULE-SET, Apple, Apple -- RULE-SET, Telegram, Telegram -- RULE-SET, Crypto, Crypto -- RULE-SET, Discord, Discord -- RULE-SET, Google FCM, Google FCM -- RULE-SET, Microsoft, Microsoft -- RULE-SET, AI Suite, AI Suite -- RULE-SET, PayPal, PayPal -- RULE-SET, Scholar, Scholar -- RULE-SET, Speedtest, Speedtest -- RULE-SET, Steam, Steam -- RULE-SET, miHoYo, miHoYo -- RULE-SET, PROXY, Proxy -- RULE-SET, Domestic, Domestic -- RULE-SET, Domestic IPs, Domestic -- RULE-SET, LAN, DIRECT -- GEOIP, CN, Domestic -- MATCH, Others +- RULE-SET,AdBlock,AdBlock +- RULE-SET,HTTPDNS,HTTPDNS +- RULE-SET,Special,DIRECT +- RULE-SET,Netflix,Netflix +- RULE-SET,Disney Plus,Disney +- RULE-SET,YouTube,YouTube +- RULE-SET,Max,Max +- RULE-SET,Spotify,Spotify +- RULE-SET,Bilibili,CN Mainland TV +- RULE-SET,IQ,CN Mainland TV +- RULE-SET,IQIYI,CN Mainland TV +- RULE-SET,Letv,CN Mainland TV +- RULE-SET,Netease Music,CN Mainland TV +- RULE-SET,Tencent Video,CN Mainland TV +- RULE-SET,WeTV,CN Mainland TV +- RULE-SET,Youku,CN Mainland TV +- RULE-SET,Abema TV,Asian TV +- RULE-SET,Bahamut,Asian TV +- RULE-SET,Fox+,Asian TV +- RULE-SET,Hulu Japan,Asian TV +- RULE-SET,Japonx,Asian TV +- RULE-SET,JOOX,Asian TV +- RULE-SET,KKBOX,Asian TV +- RULE-SET,KKTV,Asian TV +- RULE-SET,Line TV,Asian TV +- RULE-SET,myTV SUPER,Asian TV +- RULE-SET,Niconico,Asian TV +- RULE-SET,ViuTV,Asian TV +- RULE-SET,ABC,Global TV +- RULE-SET,Amazon,Global TV +- RULE-SET,BBC iPlayer,Global TV +- RULE-SET,DAZN,Global TV +- RULE-SET,Discovery Plus,Global TV +- RULE-SET,encoreTVB,Global TV +- RULE-SET,F1 TV,Global TV +- RULE-SET,Fox Now,Global TV +- RULE-SET,Hulu,Global TV +- RULE-SET,Pandora,Global TV +- RULE-SET,PBS,Global TV +- RULE-SET,Pornhub,Global TV +- RULE-SET,Soundcloud,Global TV +- RULE-SET,Apple Music,Apple TV +- RULE-SET,Apple News,Apple TV +- RULE-SET,Apple TV,Apple TV +- RULE-SET,Apple,Apple +- RULE-SET,Telegram,Telegram +- RULE-SET,Crypto,Crypto +- RULE-SET,Discord,Discord +- RULE-SET,Google FCM,Google FCM +- RULE-SET,Microsoft,Microsoft +- RULE-SET,AI Suite,AI Suite +- RULE-SET,PayPal,PayPal +- RULE-SET,Scholar,Scholar +- RULE-SET,Speedtest,Speedtest +- RULE-SET,Steam,Steam +- RULE-SET,miHoYo,miHoYo +- RULE-SET,PROXY,Proxy +- RULE-SET,Domestic,Domestic +- RULE-SET,Domestic IPs,Domestic +- RULE-SET,LAN,DIRECT +- GEOIP,CN,Domestic +- MATCH,Others rule-providers: AdBlock: type: http diff --git a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index 586d2d8566..a46a3d5fb4 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -314,37 +314,37 @@ yml_other_set() end; Value['rules']=Value_1['rules']; Value['rules'].to_a.collect!{|x| - x.to_s.gsub(/,[\s]?Bilibili,[\s]?CN Mainland TV$/, ', Bilibili, $Bilibili#delete_') - .gsub(/,[\s]?Bahamut,[\s]?Asian TV$/, ', Bahamut, $Bahamut#delete_') - .gsub(/,[\s]?Max,[\s]?Max$/, ', Max, $HBOMax#delete_') - .gsub(/,[\s]?Discovery Plus,[\s]?Global TV$/, ', Discovery Plus, $Discovery#delete_') - .gsub(/,[\s]?DAZN,[\s]?Global TV$/, ', DAZN, $DAZN#delete_') - .gsub(/,[\s]?Pornhub,[\s]?Global TV$/, ', Pornhub, $Pornhub#delete_') - .gsub(/,[\s]?Global TV$/, ', $GlobalTV#delete_') - .gsub(/,[\s]?Asian TV$/, ', $AsianTV#delete_') - .gsub(/,[\s]?CN Mainland TV$/, ', $MainlandTV#delete_') - .gsub(/,[\s]?Proxy$/, ', $Proxy#delete_') - .gsub(/,[\s]?YouTube$/, ', $Youtube#delete_') - .gsub(/,[\s]?Apple$/, ', $Apple#delete_') - .gsub(/,[\s]?Apple TV$/, ', $AppleTV#delete_') - .gsub(/,[\s]?Scholar$/, ', $Scholar#delete_') - .gsub(/,[\s]?Netflix$/, ', $Netflix#delete_') - .gsub(/,[\s]?Disney$/, ', $Disney#delete_') - .gsub(/,[\s]?Spotify$/, ', $Spotify#delete_') - .gsub(/,[\s]?AI Suite$/, ', $AI_Suite#delete_') - .gsub(/,[\s]?Steam$/, ', $Steam#delete_') - .gsub(/,[\s]?miHoYo$/, ', $miHoYo#delete_') - .gsub(/,[\s]?AdBlock$/, ', $AdBlock#delete_') - .gsub(/,[\s]?HTTPDNS$/, ', $HTTPDNS#delete_') - .gsub(/,[\s]?Speedtest$/, ', $Speedtest#delete_') - .gsub(/,[\s]?Telegram$/, ', $Telegram#delete_') - .gsub(/,[\s]?Crypto$/, ', $Crypto#delete_') - .gsub(/,[\s]?Discord$/, ', $Discord#delete_') - .gsub(/,[\s]?Microsoft$/, ', $Microsoft#delete_') - .to_s.gsub(/,[\s]?PayPal$/, ', $PayPal#delete_') - .gsub(/,[\s]?Domestic$/, ', $Domestic#delete_') - .gsub(/,[\s]?Others$/, ', $Others#delete_') - .gsub(/,[\s]?Google FCM$/, ', $GoogleFCM#delete_') + x.to_s.gsub(/,[\s]?Bilibili,[\s]?CN Mainland TV$/, ',Bilibili,$Bilibili#delete_') + .gsub(/,[\s]?Bahamut,[\s]?Asian TV$/, ',Bahamut,$Bahamut#delete_') + .gsub(/,[\s]?Max,[\s]?Max$/, ',Max,$HBOMax#delete_') + .gsub(/,[\s]?Discovery Plus,[\s]?Global TV$/, ',Discovery Plus,$Discovery#delete_') + .gsub(/,[\s]?DAZN,[\s]?Global TV$/, ',DAZN,$DAZN#delete_') + .gsub(/,[\s]?Pornhub,[\s]?Global TV$/, ',Pornhub,$Pornhub#delete_') + .gsub(/,[\s]?Global TV$/, ',$GlobalTV#delete_') + .gsub(/,[\s]?Asian TV$/, ',$AsianTV#delete_') + .gsub(/,[\s]?CN Mainland TV$/, ',$MainlandTV#delete_') + .gsub(/,[\s]?Proxy$/, ',$Proxy#delete_') + .gsub(/,[\s]?YouTube$/, ',$Youtube#delete_') + .gsub(/,[\s]?Apple$/, ',$Apple#delete_') + .gsub(/,[\s]?Apple TV$/, ',$AppleTV#delete_') + .gsub(/,[\s]?Scholar$/, ',$Scholar#delete_') + .gsub(/,[\s]?Netflix$/, ',$Netflix#delete_') + .gsub(/,[\s]?Disney$/, ',$Disney#delete_') + .gsub(/,[\s]?Spotify$/, ',$Spotify#delete_') + .gsub(/,[\s]?AI Suite$/, ',$AI_Suite#delete_') + .gsub(/,[\s]?Steam$/, ',$Steam#delete_') + .gsub(/,[\s]?miHoYo$/, ',$miHoYo#delete_') + .gsub(/,[\s]?AdBlock$/, ',$AdBlock#delete_') + .gsub(/,[\s]?HTTPDNS$/, ',$HTTPDNS#delete_') + .gsub(/,[\s]?Speedtest$/, ',$Speedtest#delete_') + .gsub(/,[\s]?Telegram$/, ',$Telegram#delete_') + .gsub(/,[\s]?Crypto$/, ',$Crypto#delete_') + .gsub(/,[\s]?Discord$/, ',$Discord#delete_') + .gsub(/,[\s]?Microsoft$/, ',$Microsoft#delete_') + .to_s.gsub(/,[\s]?PayPal$/, ',$PayPal#delete_') + .gsub(/,[\s]?Domestic$/, ',$Domestic#delete_') + .gsub(/,[\s]?Others$/, ',$Others#delete_') + .gsub(/,[\s]?Google FCM$/, ',$GoogleFCM#delete_') .gsub(/#delete_/, '') }; end; From 9764e5b5248d85a34647e094e9ab158ce8a44fde Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 7 Dec 2024 00:10:08 +0800 Subject: [PATCH 32/53] 0.46.058 --- luci-app-openclash/Makefile | 2 +- .../model/cbi/openclash/config-overwrite.lua | 3 +- .../cbi/openclash/config-subscribe-edit.lua | 5 +-- .../luasrc/model/cbi/openclash/settings.lua | 4 --- .../luasrc/view/openclash/select_git_cdn.htm | 3 +- .../po/zh-cn/openclash.zh-cn.po | 8 +---- luci-app-openclash/root/etc/config/openclash | 1 - luci-app-openclash/root/etc/init.d/openclash | 31 ++++--------------- .../root/etc/uci-defaults/luci-openclash | 20 +++++++----- .../root/usr/share/openclash/clash_version.sh | 2 -- .../usr/share/openclash/openclash_core.sh | 2 -- .../openclash/openclash_download_rule_list.sh | 4 --- .../usr/share/openclash/openclash_geoip.sh | 2 -- .../usr/share/openclash/openclash_geosite.sh | 2 -- .../usr/share/openclash/openclash_ipdb.sh | 2 -- .../usr/share/openclash/openclash_rule.sh | 2 -- .../usr/share/openclash/openclash_update.sh | 6 ---- .../usr/share/openclash/openclash_version.sh | 2 -- .../usr/share/openclash/openclash_watchdog.sh | 4 +-- .../usr/share/openclash/yml_rules_change.sh | 6 ---- 20 files changed, 27 insertions(+), 84 deletions(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index d3a8c88030..f41eb5e999 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.057 +PKG_VERSION:=0.46.058 PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua b/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua index 16e49c9c74..4bbf0a71e2 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua @@ -69,11 +69,10 @@ o:value("http://captive.apple.com/generate_204") o.default = "0" o = s:taboption("settings", Value, "github_address_mod", translate("Github Address Modify")) -o.description = translate("Modify The Github Address In The Config And OpenClash With Proxy(CDN) To Prevent File Download Faild. Format Reference:").." ".."https://mirror.ghproxy.com/" +o.description = translate("Modify The Github Address In The Config And OpenClash With Proxy(CDN) To Prevent File Download Faild. Format Reference:").." ".."https://ghp.ci/" o:value("0", translate("Disable")) o:value("https://fastly.jsdelivr.net/") o:value("https://testingcf.jsdelivr.net/") -o:value("https://raw.fastgit.org/") o:value("https://cdn.jsdelivr.net/") o.default = "0" diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe-edit.lua b/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe-edit.lua index fb834b8417..8f2488e025 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe-edit.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe-edit.lua @@ -86,9 +86,10 @@ end ---- UA o = s:option(Value, "sub_ua", "User-Agent") o.description = font_red..bold_on..translate("Used for Downloading Subscriptions, Defaults to Clash")..bold_off..font_off -o:value("Clash") o:value("clash.meta") -o.default = "Clash" +o:value("clash-verge/v1.5.1") +o:value("Clash") +o.default = "clash.meta" o.rmempty = true ---- subconverter diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua index f21fc8da11..130f735819 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua @@ -95,10 +95,6 @@ o = s:taboption("op_mode", Value, "log_size", translate("Log Size (KB)")) o.description = translate("Set Log File Size (KB)") o.default = "1024" -o = s:taboption("op_mode", Flag, "test_before_start", translate("Test Before Start")) -o.description = translate("Test Config Before Core Start") -o.default = 0 - o = s:taboption("op_mode", Flag, "bypass_gateway_compatible", translate("Bypass Gateway Compatible")) o.description = translate("If The Network Cannot be Connected in Bypass Gateway Mode, Please Try to Enable.")..font_red..bold_on..translate("Suggestion: If The Device Does Not Have WLAN, Please Disable The Lan Interface's Bridge Option")..bold_off..font_off o.default = 0 diff --git a/luci-app-openclash/luasrc/view/openclash/select_git_cdn.htm b/luci-app-openclash/luasrc/view/openclash/select_git_cdn.htm index 3acbaf9e34..d1432eaaba 100644 --- a/luci-app-openclash/luasrc/view/openclash/select_git_cdn.htm +++ b/luci-app-openclash/luasrc/view/openclash/select_git_cdn.htm @@ -82,10 +82,9 @@
https://fastly.jsdelivr.net/
https://testingcf.jsdelivr.net/
-
https://raw.fastgit.org/
https://cdn.jsdelivr.net/
<%:Custom Your CDN URL%>
- +
diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index b59cba69b4..a0532cb76d 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -3430,10 +3430,4 @@ msgid "Direct" msgstr "直连" msgid "Error: Config File Overwrite Failed," -msgstr "错误:配置文件覆写失败," - -msgid "Test Config Before Core Start" -msgstr "启动前调用内核测试配置文件" - -msgid "Test Before Start" -msgstr "启动前测试" \ No newline at end of file +msgstr "错误:配置文件覆写失败," \ No newline at end of file diff --git a/luci-app-openclash/root/etc/config/openclash b/luci-app-openclash/root/etc/config/openclash index 5b54dcc38f..797e16ce6f 100644 --- a/luci-app-openclash/root/etc/config/openclash +++ b/luci-app-openclash/root/etc/config/openclash @@ -12,7 +12,6 @@ config openclash 'config' option auto_update '0' option auto_update_time '0' option cn_port '9090' - option dashboard_password '123456' option dashboard_forward_ssl '0' option rule_source '0' option enable_custom_dns '0' diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index 2e4991c26f..a09b1e3d6c 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -660,27 +660,6 @@ do_run_file() } -config_test() -{ - if [ -f "$CLASH" ] && [ "$test_before_start" -eq 1 ]; then - LOG_OUT "Test The Config File First..." - test_info=$(nohup $CLASH -t -d $CLASH_CONFIG -f "$CONFIG_FILE") - local IFS=$'\n' - for i in $test_info; do - if [ -n "$(echo "$i" |grep "configuration file")" ]; then - local info=$(echo "$i" |sed "s# ${CONFIG_FILE} #【${CONFIG_FILE}】#g") - LOG_OUT "$info" - else - echo "$i" >> "$LOG_FILE" - fi - done - if [ -n "$(echo "$test_info" |grep "test failed")" ]; then - LOG_OUT "Error: Config File Tested Faild, Please Check The Log Infos!" - start_fail - fi - fi -} - start_run_core() { ulimit -SHn 65535 2>/dev/null @@ -690,7 +669,6 @@ start_run_core() if ! $quick_start; then mv "$TMP_CONFIG_FILE" "$CONFIG_FILE" 2>/dev/null rm -rf "$TMP_CONFIG_FILE" 2>/dev/null - config_test fi chown root:root /etc/openclash/core/* 2>/dev/null kill_clash @@ -826,12 +804,16 @@ check_core_status() ip rule add fwmark "$PROXY_FWMARK" ipproto icmp table main pref 8000 ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" pref 8001 else - while ( [ -n "$(pidof clash)" ] && [ "$CORE_HTTP_CODE" != "200" ] && [ "$TUN_RESTART" -le 120 ] ) + reg4='^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$' + while ( [ -n "$(pidof clash)" ] && [ "$CORE_HTTP_CODE" != "200" ] && [ "$TUN_RESTART" -le 120 ] && [[ "$lan_ip" =~ $reg4 ]] ) do CORE_HTTP_CODE=$(curl -m 5 -o /dev/null -s -w '%{http_code}' -H 'Content-Type: application/json' -H "Authorization: Bearer ${da_password}" -XGET http://${lan_ip}:${cn_port}/group) let TUN_WAIT++ sleep 1 done >/dev/null 2>&1 + if ! [[ "$lan_ip" =~ $reg4 ]]; then + sleep 10 + fi if [ -z "$(pidof clash)" ]; then LOG_OUT "Error: Core Start Failed, Please Check The Log Infos!" start_fail @@ -2890,8 +2872,8 @@ get_config() fakeip_range=$(uci -q get openclash.config.fakeip_range) fi [ -z "$fakeip_range" ] && fakeip_range="198.18.0.1/16" - lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo 0) + lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo 0) if [ "$lan_interface_name" = "0" ]; then lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' |head -1 || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1) else @@ -2936,7 +2918,6 @@ get_config() intranet_allowed_wan_name=$(uci -q get openclash.config.intranet_allowed_wan_name || echo 0) custom_fakeip_filter_mode=$(uci -q get openclash.config.custom_fakeip_filter_mode || echo "blacklist") iptables_compat=$(iptables -m owner -h 2>/dev/null | grep "owner match options" || echo 0) - test_before_start=$(uci -q get openclash.config.test_before_start || echo 0) [ -z "$dns_port" ] && dns_port=7874 && uci -q set openclash.config.dns_port=7874 uci -q commit openclash } diff --git a/luci-app-openclash/root/etc/uci-defaults/luci-openclash b/luci-app-openclash/root/etc/uci-defaults/luci-openclash index 5776004497..afc4268751 100644 --- a/luci-app-openclash/root/etc/uci-defaults/luci-openclash +++ b/luci-app-openclash/root/etc/uci-defaults/luci-openclash @@ -44,14 +44,18 @@ cat > "/lib/upgrade/keep.d/luci-app-openclash" <<-EOF EOF #Set Dashboard Secret -uci -q set openclash.config.dashboard_password="$(tr -cd 'a-zA-Z0-9' /dev/null| head -c8 || date +%N| md5sum |head -c8)" - -#Set authentication -uci_name_tmp=$(uci -q add openclash authentication) -uci_set="uci -q set openclash.$uci_name_tmp." -${uci_set}enabled="1" -${uci_set}username="Clash" -${uci_set}password="$(tr -cd 'a-zA-Z0-9' /dev/null| head -c8 || date +%N| md5sum |head -c8)" +if [ -z "$(uci -q get openclash.config.dashboard_password)" ]; then + uci -q set openclash.config.dashboard_password="$(tr -cd 'a-zA-Z0-9' /dev/null| head -c8 || date +%N| md5sum |head -c8)" +fi + +#Set Authentication +if [ -z "$(uci -q get openclash.@authentication[0])" ]; then + uci_name_tmp=$(uci -q add openclash authentication) + uci_set="uci -q set openclash.$uci_name_tmp." + ${uci_set}enabled="1" + ${uci_set}username="Clash" + ${uci_set}password="$(tr -cd 'a-zA-Z0-9' /dev/null| head -c8 || date +%N| md5sum |head -c8)" +fi #Set Core Model source "/etc/openwrt_release" diff --git a/luci-app-openclash/root/usr/share/openclash/clash_version.sh b/luci-app-openclash/root/usr/share/openclash/clash_version.sh index a855ccbb75..17bba88d44 100644 --- a/luci-app-openclash/root/usr/share/openclash/clash_version.sh +++ b/luci-app-openclash/root/usr/share/openclash/clash_version.sh @@ -25,8 +25,6 @@ if [ "$TIME" != "$CHTIME" ]; then if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then curl -SsL -m 60 "$github_address_mod"gh/vernesong/OpenClash@core/"$RELEASE_BRANCH"/core_version -o $LAST_OPVER 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$LAST_OPVER" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL -m 60 https://raw.fastgit.org/vernesong/OpenClash/core/"$RELEASE_BRANCH"/core_version -o $LAST_OPVER 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$LAST_OPVER" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" else curl -SsL -m 60 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/core_version -o $LAST_OPVER 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$LAST_OPVER" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh index ef35ed9a9e..f96eb5b90c 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_core.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_core.sh @@ -52,8 +52,6 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@core/"$RELEASE_BRANCH"/meta/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_meta.tar.gz 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/clash_meta.tar.gz" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/core/"$RELEASE_BRANCH"/meta/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_meta.tar.gz 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/clash_meta.tar.gz" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" else curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/meta/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_meta.tar.gz 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/clash_meta.tar.gz" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh b/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh index 93fbbfc46f..11d4a9b684 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh @@ -36,8 +36,6 @@ urlencode() { if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/FQrabbit/SSTap-Rule@master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$TMP_RULE_DIR" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$TMP_RULE_DIR" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" else curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$TMP_RULE_DIR" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi @@ -48,8 +46,6 @@ urlencode() { if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/"$(echo "$DOWNLOAD_PATH" |awk -F '/master' '{print $1}' 2>/dev/null)"@master"$(echo "$DOWNLOAD_PATH" |awk -F 'master' '{print $2}')" -o "$TMP_RULE_DIR" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$TMP_RULE_DIR" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod""$(echo "$DOWNLOAD_PATH" |awk -F '/master' '{print $1}' 2>/dev/null)"/master"$(echo "$DOWNLOAD_PATH" |awk -F 'master' '{print $2}')" -o "$TMP_RULE_DIR" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$TMP_RULE_DIR" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" else curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$TMP_RULE_DIR" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_geoip.sh b/luci-app-openclash/root/usr/share/openclash/openclash_geoip.sh index ebd84850d1..0140e0ff00 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_geoip.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_geoip.sh @@ -31,8 +31,6 @@ if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "${github_address_mod}gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat" -o /tmp/GeoIP.dat 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/GeoIP.dat" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "https://raw.fastgit.org/Loyalsoldier/v2ray-rules-dat/release/geoip.dat" -o /tmp/GeoIP.dat 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/GeoIP.dat" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" else curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat -o /tmp/GeoIP.dat 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/GeoIP.dat" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_geosite.sh b/luci-app-openclash/root/usr/share/openclash/openclash_geosite.sh index 030bf9ee2b..64a20cfbad 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_geosite.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_geosite.sh @@ -31,8 +31,6 @@ if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat -o /tmp/GeoSite.dat 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/GeoSite.dat" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/Loyalsoldier/v2ray-rules-dat/release/geosite.dat -o /tmp/GeoSite.dat 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/GeoSite.dat" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" else curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat -o /tmp/GeoSite.dat 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/GeoSite.dat" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_ipdb.sh b/luci-app-openclash/root/usr/share/openclash/openclash_ipdb.sh index 5bde49010c..aa74324a43 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_ipdb.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_ipdb.sh @@ -31,8 +31,6 @@ if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/alecthw/mmdb_china_ip_list@release/lite/Country.mmdb -o /tmp/Country.mmdb 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/Country.mmdb" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/alecthw/mmdb_china_ip_list/release/lite/Country.mmdb -o /tmp/Country.mmdb 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/Country.mmdb" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" else curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/alecthw/mmdb_china_ip_list/release/lite/Country.mmdb -o /tmp/Country.mmdb 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/Country.mmdb" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh b/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh index b43fbd2c8e..a494563c59 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh @@ -37,8 +37,6 @@ if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/dler-io/Rules@master/Clash/Rule.yaml -o /tmp/rules.yaml 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/rules.yaml" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/dler-io/Rules/master/Clash/Rule.yaml -o /tmp/rules.yaml 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/rules.yaml" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" else curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/dler-io/Rules/master/Clash/Rule.yaml -o /tmp/rules.yaml 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/rules.yaml" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index 8f93705f4a..20bac74a15 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -69,12 +69,6 @@ if [ -n "$OP_CV" ] && [ -n "$OP_LV" ] && [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 elif [ -x "/usr/bin/apk" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - if [ -x "/bin/opkg" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ -x "/usr/bin/apk" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - fi else if [ -x "/bin/opkg" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh index ad2175e3ad..37258303da 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh @@ -20,8 +20,6 @@ if [ "$TIME" != "$CHTIME" ]; then if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@package/"$RELEASE_BRANCH"/version -o $LAST_OPVER 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$LAST_OPVER" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/package/"$RELEASE_BRANCH"/version -o $LAST_OPVER 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$LAST_OPVER" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" else curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/version -o $LAST_OPVER 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="$LAST_OPVER" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh b/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh index 4f687213b8..065b789b62 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh @@ -37,8 +37,8 @@ begin threadsp = []; set_commands = []; reg = /([0-9a-zA-Z-]{1,}\.)+([a-zA-Z]{2,})/; - reg4 = /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/; - reg6 = /^(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))|\[(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))\](?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/i; + reg4 = /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/; + reg6 = /^(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))|\[(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))\]$/i; if Value.key?('proxies') or Value.key?('proxy-providers') then firewall_v = '$FW4'; if firewall_v.empty? then diff --git a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index a46a3d5fb4..2f05a03bc2 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -133,8 +133,6 @@ yml_gen_rule_provider_file() else if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then RULE_PROVIDER_FILE_URL="${github_address_mod}gh/"$(echo "$RULE_PROVIDER_FILE_URL_PATH" |awk -F '/master' '{print $1}' 2>/dev/null)"@master"$(echo "$RULE_PROVIDER_FILE_URL_PATH" |awk -F 'master' '{print $2}')"" - elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - RULE_PROVIDER_FILE_URL="https://raw.fastgit.org/"$(echo "$RULE_PROVIDER_FILE_URL_PATH" |awk -F '/master' '{print $1}' 2>/dev/null)"/master"$(echo "$RULE_PROVIDER_FILE_URL_PATH" |awk -F 'master' '{print $2}')"" else RULE_PROVIDER_FILE_URL="${github_address_mod}https://raw.githubusercontent.com/${RULE_PROVIDER_FILE_URL_PATH}" fi @@ -718,10 +716,6 @@ yml_other_set() if x['url'] and x['url'] =~ /^https:\/\/raw.githubusercontent.com/ then x['url'] = '$github_address_mod' + 'gh/' + x['url'].split('/')[3] + '/' + x['url'].split('/')[4] + '@' + x['url'].split(x['url'].split('/')[2] + '/' + x['url'].split('/')[3] + '/' + x['url'].split('/')[4] + '/')[1]; end; - elsif '$github_address_mod' == 'https://raw.fastgit.org/' then - if x['url'] and x['url'] =~ /^https:\/\/raw.githubusercontent.com/ then - x['url'] = 'https://raw.fastgit.org/' + x['url'].split('/')[3] + '/' + x['url'].split('/')[4] + '/' + x['url'].split(x['url'].split('/')[2] + '/' + x['url'].split('/')[3] + '/' + x['url'].split('/')[4] + '/')[1]; - end; else if x['url'] and x['url'] =~ /^https:\/\/(raw.|gist.)(githubusercontent.com|github.com)/ then x['url'] = '$github_address_mod' + x['url']; From eb716c12faeedff705a96de43bf4e0a326fef0c4 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:21:32 +0800 Subject: [PATCH 33/53] chore: refine apk upgrade codes --- .../usr/share/openclash/openclash_update.sh | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index 20bac74a15..ceb3308090 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -85,10 +85,9 @@ if [ -n "$OP_CV" ] && [ -n "$OP_LV" ] && [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 fi if [ "${PIPESTATUS[0]}" -eq 0 ]; then + LOG_OUT "【OpenClash - v$LAST_VER】Download Successful, Start Pre Update Test..." if [ -x "/bin/opkg" ]; then if [ -s "/tmp/openclash.ipk" ]; then - LOG_OUT "【OpenClash - v$LAST_VER】Download Successful, Start Pre Update Test..." - if [ -z "$(opkg install /tmp/openclash.ipk --noaction 2>/dev/null |grep 'Upgrading luci-app-openclash on root' 2>/dev/null)" ]; then LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then @@ -102,8 +101,24 @@ if [ -n "$OP_CV" ] && [ -n "$OP_LV" ] && [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 exit 0 fi fi - LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Passed, Ready to Update and Please Do not Refresh The Page and Other Operations..." + elif [ -x "/usr/bin/apk" ]; then + if [ -s "/tmp/openclash.apk" ]; then + apk add -s -q --clean-protected --allow-untrusted /tmp/openclash.apk >/dev/null 2>&1 + if [ "$?" != "0" ]; then + LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.apk, Please Try to Update Manually!" + if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then + uci -q set openclash.config.config_reload=0 + uci -q commit openclash + /etc/init.d/openclash restart >/dev/null 2>&1 & + else + SLOG_CLEAN + fi + del_lock + exit 0 + fi + fi fi + LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Passed, Ready to Update and Please Do not Refresh The Page and Other Operations..." cat > /tmp/openclash_update.sh <<"EOF" #!/bin/sh START_LOG="/tmp/openclash_start.log" @@ -133,7 +148,7 @@ LOG_OUT "Installing The New Version, Please Do Not Refresh The Page or Do Other if [ -x "/bin/opkg" ]; then opkg install /tmp/openclash.ipk elif [ -x "/usr/bin/apk" ]; then - apk add --allow-untrusted /tmp/openclash.apk + apk add -q --clean-protected --allow-untrusted /tmp/openclash.apk fi if [ -x "/bin/opkg" ]; then if [ "$?" != "0" ] || [ -z "$(opkg info *openclash |grep Installed-Time)" ]; then @@ -151,7 +166,7 @@ if [ -x "/bin/opkg" ]; then fi elif [ -x "/usr/bin/apk" ]; then if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash 2>/dev/null |grep 'installed')" ]; then - apk add --allow-untrusted /tmp/openclash.apk + apk add -q --clean-protected --allow-untrusted /tmp/openclash.apk fi if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash 2>/dev/null |grep 'installed')" ]; then rm -rf /tmp/openclash.apk >/dev/null 2>&1 From 0fff4975a8aa88a9fabc38e7dfd7dbcd43aaa80f Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:22:13 +0800 Subject: [PATCH 34/53] 0.46.059 --- luci-app-openclash/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index f41eb5e999..82faf9578f 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.46.058 +PKG_VERSION:=0.46.059 PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) From 28de0adefe74f8417585a1afb9d0a04c4c413c5a Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 8 Dec 2024 09:21:41 +0800 Subject: [PATCH 35/53] #4214 --- luci-app-openclash/root/etc/uci-defaults/luci-openclash | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/luci-app-openclash/root/etc/uci-defaults/luci-openclash b/luci-app-openclash/root/etc/uci-defaults/luci-openclash index afc4268751..c7605649f8 100644 --- a/luci-app-openclash/root/etc/uci-defaults/luci-openclash +++ b/luci-app-openclash/root/etc/uci-defaults/luci-openclash @@ -103,7 +103,9 @@ uci -q commit openclash #Restore if [ -f "/tmp/openclash.bak" ]; then #delete old geosite database first - rm -rf "/tmp/openclash/GeoSite.dat" >/dev/null 2>&1 + if [ "/etc/openclash/GeoSite.dat" -nt "/tmp/openclash/GeoSite.dat" ]; then + rm -rf "/tmp/openclash/GeoSite.dat" >/dev/null 2>&1 + fi mv -f "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1 cp -rf "/tmp/openclash/." "/etc/openclash/" >/dev/null 2>&1 if [ -d "/tmp/openclash_dashboard/" ]; then @@ -129,7 +131,6 @@ if [ -f "/tmp/openclash.bak" ]; then rm -rf "/etc/openclash/custom/openclash_sniffing_ports_filter.yaml" >/dev/null 2>&1 rm -rf "/etc/openclash/custom/openclash_sniffing_port_filter.yaml" >/dev/null 2>&1 rm -rf "/etc/openclash/custom/openclash_sniffing_domain_filter.yaml" >/dev/null 2>&1 - rm -rf "/etc/config/openclash.apk-new" >/dev/null 2>&1 fi uci -q set openclash.config.enable=0 From d49f3b383d1b48165ac19cfb18cd580057d47da9 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 8 Dec 2024 12:10:01 +0800 Subject: [PATCH 36/53] chore: refine --- .../luasrc/model/cbi/openclash/servers.lua | 2 -- .../luasrc/view/openclash/tblsection.htm | 14 ++++++++++++-- .../luasrc/view/openclash/tblsection_dns.htm | 14 ++++++++++++-- luci-app-openclash/po/zh-cn/openclash.zh-cn.po | 5 ++++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua b/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua index 00a16cf337..1962f602c1 100644 --- a/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua +++ b/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua @@ -29,8 +29,6 @@ o = s:option(ListValue, "rule_sources", translate("Choose Template For Create Co o.description = translate("Use Other Rules To Create Config") o:depends("create_config", 1) o:value("lhie1", translate("lhie1 Rules")) -o:value("ConnersHua", translate("ConnersHua(Provider-type) Rules")) -o:value("ConnersHua_return", translate("ConnersHua Return Rules")) o = s:option(Flag, "mix_proxies", translate("Mix Proxies")) o.description = font_red .. bold_on .. translate("Mix This Page's Proxies") .. bold_off .. font_off diff --git a/luci-app-openclash/luasrc/view/openclash/tblsection.htm b/luci-app-openclash/luasrc/view/openclash/tblsection.htm index a376a1ceeb..0002b1b5d7 100644 --- a/luci-app-openclash/luasrc/view/openclash/tblsection.htm +++ b/luci-app-openclash/luasrc/view/openclash/tblsection.htm @@ -66,6 +66,14 @@ ul{ list-style: none; } + + h3{ + margin-top: 0; + } + + .cbi-value-field .cbi-dropdown, .cbi-value-field .cbi-input-select, .cbi-value input[type="text"], .cbi-value input[type="password"] { + min-width: auto; + } #tab-header-<%=self.config%>-<%=self.sectiontype%>{ min-height: 35px; @@ -123,7 +131,7 @@
<% if self.title and #self.title > 0 then -%> - <%=self.title%> +

<%=self.title%>

<%- end %> <%- if self.sortable then -%> @@ -184,7 +192,7 @@ <%- count = count + 1; end; end; if self.sortable then -%> <%:Sort%> <%- end; if self.extedit or self.addremove then -%> -   + <%:Edit%> <%- count = count + 1; end -%> @@ -194,6 +202,8 @@ <%- else -%> <%- end -%> + <%- end; if self.extedit or self.addremove then -%> + <%- end -%> <%- for i, k in pairs(self.children) do if not k.optional then -%> ><%=k.description%> diff --git a/luci-app-openclash/luasrc/view/openclash/tblsection_dns.htm b/luci-app-openclash/luasrc/view/openclash/tblsection_dns.htm index 51aff8a532..05aaabc497 100644 --- a/luci-app-openclash/luasrc/view/openclash/tblsection_dns.htm +++ b/luci-app-openclash/luasrc/view/openclash/tblsection_dns.htm @@ -33,6 +33,14 @@ ul{ list-style: none; } + + h3{ + margin-top: 0; + } + + .cbi-value-field .cbi-dropdown, .cbi-value-field .cbi-input-select, .cbi-value input[type="text"], .cbi-value input[type="password"] { + min-width: auto; + } #tab-header-<%=self.config%>-<%=self.sectiontype%>{ min-height: 35px; @@ -90,7 +98,7 @@
<% if self.title and #self.title > 0 then -%> - <%=self.title%> +

<%=self.title%>

<%- end %> <%- if self.sortable then -%> @@ -133,7 +141,7 @@ <%- count = count + 1; end; end; if self.sortable then -%> <%:Sort%> <%- end; if self.extedit or self.addremove then -%> -   + <%:Edit%> <%- count = count + 1; end -%> @@ -143,6 +151,8 @@ <%- else -%> <%- end -%> + <%- end; if self.extedit or self.addremove then -%> + <%- end -%> <%- for i, k in pairs(self.children) do if not k.optional then -%> ><%=k.description%> diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index a0532cb76d..bf908a5a5f 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -3430,4 +3430,7 @@ msgid "Direct" msgstr "直连" msgid "Error: Config File Overwrite Failed," -msgstr "错误:配置文件覆写失败," \ No newline at end of file +msgstr "错误:配置文件覆写失败," + +msgid "Edit" +msgstr "编辑" \ No newline at end of file From d30d285b4d9b135021043ef95839a972ecf0d337 Mon Sep 17 00:00:00 2001 From: zxl hhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Sun, 8 Dec 2024 14:00:19 +0800 Subject: [PATCH 37/53] luci-app-openclash: Optimized acquire `dnsmasq` configuration file path code. (#4215) * luci-app-openclash: Optimized acquire `dnsmasq` configuration file path code. --- luci-app-openclash/Makefile | 9 ++++++--- luci-app-openclash/root/etc/init.d/openclash | 16 +++++++++------- .../openclash/openclash_custom_domain_dns.sh | 18 ++++++++++-------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 82faf9578f..53f49f6846 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -122,9 +122,12 @@ endef define Package/$(PKG_NAME)/postrm #!/bin/sh - DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | awk -F '=' '{print $1}' | head -1) - DNSMASQ_CONF_PATH=$(grep -l "^conf-dir=" "/tmp/etc/dnsmasq.conf.${DEFAULT_DNSMASQ_CFGID}") - DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) + DEFAULT_DNSMASQ_CFGID="$(uci -q show "dhcp.@dnsmasq[0]" | awk 'NR==1 {split($0, conf, /[.=]/); print conf[2]}')" + if [ -f "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID" ]; then + DNSMASQ_CONF_DIR="$(awk -F '=' '/^conf-dir=/ {print $2}' "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID")" + else + DNSMASQ_CONF_DIR="/tmp/dnsmasq.d" + fi DNSMASQ_CONF_DIR=${DNSMASQ_CONF_DIR%*/} rm -rf /etc/openclash >/dev/null 2>&1 rm -rf /etc/config/openclash >/dev/null 2>&1 diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index a09b1e3d6c..c96e302bb0 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -14,13 +14,15 @@ BACKUP_FILE="/etc/openclash/backup/$(uci -q get openclash.config.config_path |aw CONFIG_FILE="/etc/openclash/$(uci -q get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)" TMP_CONFIG_FILE="/tmp/yaml_config_tmp_$(uci -q get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)" FW4=$(command -v fw4) -# Get the default DNSMasq config ID from the UCI configuration -DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | awk -F '=' '{print $1}' | head -1) -# Locate the dnsmasq.conf file that contains the conf-dir option -DNSMASQ_CONF_PATH=$(grep -l "^conf-dir=" "/tmp/etc/dnsmasq.conf.${DEFAULT_DNSMASQ_CFGID}") -# Extract the directory path from the conf-dir line -DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) -# Check if a conf-dir value was found and set variables accordingly +# 获取默认的 DNSMASQ 配置 ID +DEFAULT_DNSMASQ_CFGID="$(uci -q show "dhcp.@dnsmasq[0]" | awk 'NR==1 {split($0, conf, /[.=]/); print conf[2]}')" +# 从 conf-dir 行中提取配置目录路径 +if [ -f "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID" ]; then + DNSMASQ_CONF_DIR="$(awk -F '=' '/^conf-dir=/ {print $2}' "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID")" +else + DNSMASQ_CONF_DIR="/tmp/dnsmasq.d" +fi +# 设置 DNSMASQ_CONF_DIR,并去除路径末尾的斜杠 DNSMASQ_CONF_DIR=${DNSMASQ_CONF_DIR%*/} } CLASH="/etc/openclash/clash" diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh b/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh index c3962e1647..22b353ff46 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh @@ -13,13 +13,15 @@ del_lock() { set_lock -# Get the default DNSMasq config ID from the UCI configuration -DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | awk -F '=' '{print $1}' | head -1) -# Locate the dnsmasq.conf file that contains the conf-dir option -DNSMASQ_CONF_PATH=$(grep -l "^conf-dir=" "/tmp/etc/dnsmasq.conf.${DEFAULT_DNSMASQ_CFGID}") -# Extract the directory path from the conf-dir line -DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) -# Check if a conf-dir value was found and set variables accordingly +# 获取默认的 DNSMASQ 配置 ID +DEFAULT_DNSMASQ_CFGID="$(uci -q show "dhcp.@dnsmasq[0]" | awk 'NR==1 {split($0, conf, /[.=]/); print conf[2]}')" +# 从 conf-dir 行中提取配置目录路径 +if [ -f "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID" ]; then + DNSMASQ_CONF_DIR="$(awk -F '=' '/^conf-dir=/ {print $2}' "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID")" +else + DNSMASQ_CONF_DIR="/tmp/dnsmasq.d" +fi +# 设置 DNSMASQ_CONF_DIR,并去除路径末尾的斜杠 DNSMASQ_CONF_DIR=${DNSMASQ_CONF_DIR%*/} rm -rf ${DNSMASQ_CONF_DIR}/dnsmasq_openclash_custom_domain.conf >/dev/null 2>&1 if [ "$(uci get openclash.config.enable_custom_domain_dns_server 2>/dev/null)" = "1" ] && [ "$(uci get openclash.config.enable_redirect_dns 2>/dev/null)" = "1" ]; then @@ -36,4 +38,4 @@ if [ "$(uci get openclash.config.enable_custom_domain_dns_server 2>/dev/null)" = fi fi -del_lock \ No newline at end of file +del_lock From 72847cccfff1dedd04f139dcef94bfdae5b44b13 Mon Sep 17 00:00:00 2001 From: vernesong <42875168+vernesong@users.noreply.github.com> Date: Sun, 8 Dec 2024 16:54:39 +0800 Subject: [PATCH 38/53] chore: refine --- .../po/zh-cn/openclash.zh-cn.po | 3 -- luci-app-openclash/root/etc/init.d/openclash | 2 +- .../usr/share/openclash/yml_rules_change.sh | 43 +++---------------- 3 files changed, 8 insertions(+), 40 deletions(-) diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index bf908a5a5f..fa92ab79b0 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -2298,9 +2298,6 @@ msgstr "错误:设置自定义规则失败," msgid "Error: Set BT/P2P DIRECT Rules Failed," msgstr "错误:设置仅代理命中规则流量(BT/P2P直连)失败," -msgid "Error: Set Loop Protect Rules Failed," -msgstr "错误:设置防回环规则失败," - msgid "Error: Set lhie1 Rules Failed," msgstr "错误:设置第三方规则(lhie1)失败," diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index c96e302bb0..435f22c6ea 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -2946,7 +2946,7 @@ start() LOG_OUT "Step 3: Modify The Config File..." config_check /usr/share/openclash/yml_change.sh 2>/dev/null "$en_mode" "$da_password" "$cn_port" "$proxy_port" "$TMP_CONFIG_FILE" "$ipv6_enable" "$http_port" "$socks_port" "$log_level" "$proxy_mode" "$en_mode_tun" "$stack_type" "$dns_port" "$mixed_port" "$tproxy_port" "$ipv6_dns" "$store_fakeip" "$enable_meta_sniffer" "$enable_geoip_dat" "$geodata_loader" "$enable_meta_sniffer_custom" "$interface_name" "$enable_tcp_concurrent" "$core_type" "$append_default_dns" "$enable_meta_sniffer_pure_ip" "$find_process_mode" "$fakeip_range" "$global_client_fingerprint" "$ipv6_mode" "$stack_type_v6" "$enable_unified_delay" "$enable_respect_rules" "$custom_fakeip_filter_mode" "$iptables_compat" - /usr/share/openclash/yml_rules_change.sh 2>/dev/null "$rule_source" "$enable_custom_clash_rules" "$TMP_CONFIG_FILE" "$enable_rule_proxy" "$CONFIG_NAME" "$router_self_proxy" "$lan_ip" "$proxy_port" "$tproxy_port" "$enable_redirect_dns" "$fakeip_range" "$en_mode" + /usr/share/openclash/yml_rules_change.sh 2>/dev/null "$rule_source" "$enable_custom_clash_rules" "$TMP_CONFIG_FILE" "$enable_rule_proxy" "$CONFIG_NAME" "$router_self_proxy" "$lan_ip" "$enable_redirect_dns" "$en_mode" #Custom overwrite if [ -f "/etc/openclash/custom/openclash_custom_overwrite.sh" ]; then chmod +x /etc/openclash/custom/openclash_custom_overwrite.sh >/dev/null 2>&1 diff --git a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index 2f05a03bc2..e498e16088 100644 --- a/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh +++ b/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -286,7 +286,6 @@ yml_other_set() config_foreach yml_rule_group_get "rule_provider_config" "$3" config_foreach yml_rule_group_get "rule_providers" "$3" config_foreach yml_rule_group_get "game_config" "$3" - local fake_ip="$(echo "${11}" |awk -F '/' '{print $1}')" ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e " begin Value = YAML.load_file('$3'); @@ -402,19 +401,15 @@ yml_other_set() #Router Self Proxy Rule begin - if $6 == 0 and ${10} != 2 and '${12}' == 'fake-ip' then + if $6 == 0 and $8 != 2 and '$9' == 'fake-ip' then if Value.has_key?('rules') and not Value['rules'].to_a.empty? then - if Value['rules'].to_a.grep(/(?=.*SRC-IP-CIDR,'${fake_ip}')/).empty? then - Value['rules']=Value['rules'].to_a.insert(0,'SRC-IP-CIDR,${11},DIRECT'); - end if Value['rules'].to_a.grep(/(?=.*SRC-IP-CIDR,'$7')/).empty? and not '$7'.empty? then Value['rules']=Value['rules'].to_a.insert(0,'SRC-IP-CIDR,$7/32,DIRECT'); end; else - Value['rules']=['SRC-IP-CIDR,${11},DIRECT','SRC-IP-CIDR,$7/32,DIRECT']; + Value['rules']=['SRC-IP-CIDR,$7/32,DIRECT']; end; elsif Value.has_key?('rules') and not Value['rules'].to_a.empty? then - Value['rules'].delete('SRC-IP-CIDR,${11},DIRECT'); Value['rules'].delete('SRC-IP-CIDR,$7/32,DIRECT'); end; rescue Exception => e @@ -445,12 +440,7 @@ yml_other_set() end; if File::exist?('/tmp/yaml_rule_set_top_custom.yaml') then Value_1 = YAML.load_file('/tmp/yaml_rule_set_top_custom.yaml'); - if Value['rules'].to_a.grep(/(?=.*'${fake_ip}')(?=.*REJECT)/).empty? then - Value_1['rules'].uniq.reverse.each{|x| Value['rules'].insert(0,x)}; - else - ruby_add_index = Value['rules'].index(Value['rules'].grep(/(?=.*'${fake_ip}')(?=.*REJECT)/).first); - Value_1['rules'].uniq.reverse.each{|x| Value['rules'].insert(ruby_add_index + 1,x)}; - end; + Value_1['rules'].uniq.reverse.each{|x| Value['rules'].insert(0,x)}; end; else if File::exist?('/tmp/yaml_rule_set_top_custom.yaml') then @@ -624,25 +614,6 @@ yml_other_set() rescue Exception => e YAML.LOG('Error: Set Custom Rules Failed,【' + e.message + '】'); end; - - #loop prevent - begin - if Value.has_key?('rules') and not Value['rules'].to_a.empty? then - if Value['rules'].to_a.grep(/(?=.*'${fake_ip}')(?=.*REJECT)/).empty? then - Value['rules']=Value['rules'].to_a.insert(0,'IP-CIDR,${11},REJECT,no-resolve'); - end; - if Value['rules'].to_a.grep(/(?=.*DST-PORT,'$8',REJECT)/).empty? then - Value['rules']=Value['rules'].to_a.insert(0,'DST-PORT,$8,REJECT'); - end; - if Value['rules'].to_a.grep(/(?=.*DST-PORT,'$9',REJECT)/).empty? then - Value['rules']=Value['rules'].to_a.insert(0,'DST-PORT,$9,REJECT'); - end; - else - Value['rules']=['IP-CIDR,${11},REJECT,no-resolve','DST-PORT,$8,REJECT','DST-PORT,$9,REJECT']; - end; - rescue Exception => e - YAML.LOG('Error: Set Loop Protect Rules Failed,【' + e.message + '】'); - end; }; t2=Thread.new{ @@ -875,7 +846,7 @@ if [ "$1" != "0" ]; then config_foreach yml_other_rules_get "other_rules" "$5" if [ -z "$rule_name" ]; then SKIP_CUSTOM_OTHER_RULES=1 - yml_other_set "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "${10}" "${11}" "${12}" + yml_other_set "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" exit 0 #判断策略组是否存在 elif [ "$rule_name" = "lhie1" ]; then @@ -912,16 +883,16 @@ if [ "$1" != "0" ]; then || [ -z "$(grep -F "$Domestic" /tmp/Proxy_Group)" ]; then LOG_OUT "Warning: Because of The Different Porxy-Group's Name, Stop Setting The Other Rules!" SKIP_CUSTOM_OTHER_RULES=1 - yml_other_set "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "${10}" "${11}" "${12}" + yml_other_set "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" exit 0 fi fi if [ -z "$Proxy" ]; then LOG_OUT "Error: Missing Porxy-Group's Name, Stop Setting The Other Rules!" SKIP_CUSTOM_OTHER_RULES=1 - yml_other_set "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "${10}" "${11}" "${12}" + yml_other_set "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" exit 0 fi fi -yml_other_set "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "${10}" "${11}" "${12}" +yml_other_set "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" From bbbcde48dafefcddcb07a673c74b5e6c4e4d2ce3 Mon Sep 17 00:00:00 2001 From: zxl hhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Mon, 9 Dec 2024 09:37:55 +0800 Subject: [PATCH 39/53] luci-app-openclash: Fix `$` sign not escaping correctly. (#4217) --- luci-app-openclash/Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 53f49f6846..448ecffd1f 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -122,13 +122,13 @@ endef define Package/$(PKG_NAME)/postrm #!/bin/sh - DEFAULT_DNSMASQ_CFGID="$(uci -q show "dhcp.@dnsmasq[0]" | awk 'NR==1 {split($0, conf, /[.=]/); print conf[2]}')" + DEFAULT_DNSMASQ_CFGID="$$(uci -q show "dhcp.@dnsmasq[0]" | awk 'NR==1 {split($0, conf, /[.=]/); print conf[2]}')" if [ -f "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID" ]; then - DNSMASQ_CONF_DIR="$(awk -F '=' '/^conf-dir=/ {print $2}' "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID")" + DNSMASQ_CONF_DIR="$$(awk -F '=' '/^conf-dir=/ {print $2}' "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID")" else DNSMASQ_CONF_DIR="/tmp/dnsmasq.d" fi - DNSMASQ_CONF_DIR=${DNSMASQ_CONF_DIR%*/} + DNSMASQ_CONF_DIR=$${DNSMASQ_CONF_DIR%*/} rm -rf /etc/openclash >/dev/null 2>&1 rm -rf /etc/config/openclash >/dev/null 2>&1 rm -rf /tmp/openclash.log >/dev/null 2>&1 @@ -152,8 +152,10 @@ define Package/$(PKG_NAME)/postrm sed -i '/.*kB maximum content size*/c\export let HTTP_MAX_CONTENT = 1024*100; // 100 kB maximum content size' /usr/share/ucode/luci/http.uc >/dev/null 2>&1 uci -q delete firewall.openclash uci -q commit firewall + [ -f "/etc/config/ucitrack" ] && { uci -q delete ucitrack.@openclash[-1] uci -q commit ucitrack + } rm -rf /tmp/luci-* exit 0 endef From 4379563e5218c2bd7b7ad0caf70793a54fb40caa Mon Sep 17 00:00:00 2001 From: why654123 <84281220+why654123@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:09:30 +0800 Subject: [PATCH 40/53] Update openclash.lua (#4224) update sub_info_get function User-Agent --------- Co-authored-by: sangyishuje1123 <152784766+sangyishuje1123@users.noreply.github.com> --- luci-app-openclash/luasrc/controller/openclash.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index 36bf3aa622..c2505276ff 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -621,10 +621,18 @@ function set_subinfo_url() end function sub_info_get() - local filepath, filename, sub_url, sub_info, info, upload, download, total, expire, http_code, len, percent, day_left, day_expire, surplus, used + local sub_ua, filepath, filename, sub_url, sub_info, info, upload, download, total, expire, http_code, len, percent, day_left, day_expire, surplus, used local info_tb = {} filename = luci.http.formvalue("filename") sub_info = "" + sub_ua = "Clash" + uci:foreach("openclash", "config_subscribe", + function(s) + if s.name == filename and s.sub_ua then + sub_ua = s.sub_ua + end + end + ) if filename and not is_start() then uci:foreach("openclash", "subscribe_info", function(s) @@ -647,7 +655,7 @@ function sub_info_get() if not sub_url then sub_info = "No Sub Info Found" else - info = luci.sys.exec(string.format("curl -sLI -X GET -m 10 -w 'http_code='%%{http_code} -H 'User-Agent: Clash' '%s'", sub_url)) + info = luci.sys.exec(string.format("curl -sLI -X GET -m 10 -w 'http_code='%%{http_code} -H 'User-Agent: %s' '%s'", sub_ua, sub_url)) if not info or tonumber(string.sub(string.match(info, "http_code=%d+"), 11, -1)) ~= 200 then info = luci.sys.exec(string.format("curl -sLI -X GET -m 10 -w 'http_code='%%{http_code} -H 'User-Agent: Quantumultx' '%s'", sub_url)) end From 3b2567e2c1ee7ba20d0217d07a5f08fd2fddd5f7 Mon Sep 17 00:00:00 2001 From: jelly21fish <131505153+jelly21fish@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:17:27 +0800 Subject: [PATCH 41/53] Enhance nft firewall rules; add support for IPv6 suffix matching (#4219) * Enhance nft firewall rules; add support for IPv6 suffix matching Enhance the conversion of nftables firewall rules including support for IPv6 suffix matching. * Revert the change regarding the port range --- luci-app-openclash/root/etc/init.d/openclash | 29 ++++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index 435f22c6ea..4c4fb07f43 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -826,7 +826,7 @@ check_core_status() firewall_rule_exclude() { local section="$1" - local name src dest dest_port proto target enabled family + local name src dest dest_port dest_ip proto target enabled family config_get "name" "$section" "name" "" config_get "src" "$section" "src" "" @@ -838,6 +838,18 @@ firewall_rule_exclude() config_get "enabled" "$section" "enabled" "" config_get "family" "$section" "family" "" + ipv6_suffix_to_nft_format() { + local ipv6_with_prefix="$1" + if [[ "$ipv6_with_prefix" =~ / ]]; then + local suffix="${ipv6_with_prefix%%/*}" + local prefix="${ipv6_with_prefix##*/}" + echo "& $prefix == $suffix" + else + echo "$ipv6_with_prefix" + fi + } + nft_ipv6=$(ipv6_suffix_to_nft_format "$dest_ip") + if [ a"$target" != aACCEPT ] || [ a"$enabled" == a0 ]; then return fi @@ -862,6 +874,8 @@ firewall_rule_exclude() fi if [ -n "$FW4" ]; then + dest_ip=$(echo $dest_ip |sed "s/ /,/g" 2>/dev/null) + if [ -z "$family" ] || [ "$family" == "ipv4" ]; then if [ -z "$en_mode_tun" ] || [ "$en_mode_tun" -eq 2 ]; then for i in $dest_port; do @@ -911,7 +925,11 @@ firewall_rule_exclude() if [ -z "$dest_ip" ]; then nft insert rule inet fw4 openclash_mangle_v6 position 0 meta nfproto {ipv6} tcp sport "$i" counter return >/dev/null 2>&1 else - nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr { "$dest_ip" } tcp sport "$i" counter return >/dev/null 2>&1 + if [[ "$dest_ip" =~ , ]]; then + nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr { "$dest_ip" } tcp sport "$i" counter return >/dev/null 2>&1 + else + nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr "$nft_ipv6" tcp sport "$i" counter return >/dev/null 2>&1 + fi fi nft insert rule inet fw4 openclash_mangle_output_v6 position 0 meta nfproto {ipv6} tcp sport "$i" counter return >/dev/null 2>&1 fi @@ -919,13 +937,18 @@ firewall_rule_exclude() if [ -z "$dest_ip" ]; then nft insert rule inet fw4 openclash_mangle_v6 position 0 meta nfproto {ipv6} udp sport "$i" counter return >/dev/null 2>&1 else - nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr { "$dest_ip" } udp sport "$i" counter return >/dev/null 2>&1 + if [[ "$dest_ip" =~ , ]]; then + nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr { "$dest_ip" } udp sport "$i" counter return >/dev/null 2>&1 + else + nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr "$nft_ipv6" udp sport "$i" counter return >/dev/null 2>&1 + fi fi nft insert rule inet fw4 openclash_mangle_output_v6 position 0 meta nfproto {ipv6} udp sport "$i" counter return >/dev/null 2>&1 fi done fi fi + else dest_port=$(echo $dest_port |sed "s/-/:/g" 2>/dev/null) dest_ip=$(echo $dest_ip |sed "s/ /,/g" 2>/dev/null) From 56830957d4782380ca8904e0c23d780d2ff26f8d Mon Sep 17 00:00:00 2001 From: LovinYarn Date: Thu, 12 Dec 2024 22:18:00 +0800 Subject: [PATCH 42/53] chore: update metacubexd v1.173.3 (#4218) --- .../ui/metacubexd/assets/Config-CcYWVyqe.js | 1 - .../ui/metacubexd/assets/Config-k-_AAs0r.js | 1 + .../metacubexd/assets/Connections-B_UhsQEk.js | 16 + .../metacubexd/assets/Connections-CVJiJJwm.js | 16 - .../assets/DocumentTitle-D55F_IfB.js | 1 + .../assets/FiraSans-Regular-BN6hITtY.ttf | Bin 0 -> 440984 bytes ...oad-C5Iuvpd-.js => IconReload-BcVpy2bP.js} | 4 +- .../ui/metacubexd/assets/Logs-D62sWxG3.js | 1 + .../ui/metacubexd/assets/Logs-LisT8FTz.js | 1 - .../ui/metacubexd/assets/Overview-DiEjGL5X.js | 797 ----------------- .../ui/metacubexd/assets/Overview-Ehg23R_n.js | 838 ++++++++++++++++++ .../ui/metacubexd/assets/Proxies-A8q5R6Aj.js | 1 - .../ui/metacubexd/assets/Proxies-DXWwoSHR.js | 11 + .../ui/metacubexd/assets/Rules-BskxbInP.js | 9 - .../ui/metacubexd/assets/Rules-DQjAoqop.js | 9 + .../ui/metacubexd/assets/Setup-B_j3QECB.js | 1 + .../ui/metacubexd/assets/Setup-e28eI3Pt.js | 1 - .../ui/metacubexd/assets/global-Cq-x4U7Q.js | 1 - .../ui/metacubexd/assets/index-BJiRnjBB.css | 1 + .../ui/metacubexd/assets/index-DACeLBg-.js | 104 --- .../ui/metacubexd/assets/index-DNc1N1Rv.js | 104 +++ .../ui/metacubexd/assets/index-D_QrDGkm.css | 1 - .../{index-GtOz1sEE.js => index-XbeMqmJa.js} | 10 +- .../ui/metacubexd/assets/time-C4gqnMrH.js | 1 + .../share/openclash/ui/metacubexd/index.html | 7 +- .../ui/metacubexd/manifest.webmanifest | 2 +- .../usr/share/openclash/ui/metacubexd/sw.js | 2 +- 27 files changed, 996 insertions(+), 945 deletions(-) delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Config-CcYWVyqe.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Config-k-_AAs0r.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Connections-B_UhsQEk.js delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Connections-CVJiJJwm.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/DocumentTitle-D55F_IfB.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/FiraSans-Regular-BN6hITtY.ttf rename luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/{IconReload-C5Iuvpd-.js => IconReload-BcVpy2bP.js} (76%) create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Logs-D62sWxG3.js delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Logs-LisT8FTz.js delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Overview-DiEjGL5X.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Overview-Ehg23R_n.js delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Proxies-A8q5R6Aj.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Proxies-DXWwoSHR.js delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Rules-BskxbInP.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Rules-DQjAoqop.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Setup-B_j3QECB.js delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Setup-e28eI3Pt.js delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/global-Cq-x4U7Q.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/index-BJiRnjBB.css delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/index-DACeLBg-.js create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/index-DNc1N1Rv.js delete mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/index-D_QrDGkm.css rename luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/{index-GtOz1sEE.js => index-XbeMqmJa.js} (99%) create mode 100644 luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/time-C4gqnMrH.js diff --git a/luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Config-CcYWVyqe.js b/luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Config-CcYWVyqe.js deleted file mode 100644 index c16a4aef23..0000000000 --- a/luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Config-CcYWVyqe.js +++ /dev/null @@ -1 +0,0 @@ -import{A as j,D as ne,b0 as re,b as X,y as se,u as B,i as e,f as t,ac as E,S as L,t as f,z as w,b1 as ie,c as W,d as Z,B as D,F as A,b2 as ce,r as J,b3 as _,a4 as oe,g as v,aa as N,b4 as de,b5 as ue,b6 as ge,b7 as be,b8 as he,b9 as pe,ba as ve,bb as fe,bc as me,bd as xe,be as $e,bf as _e,bg as O,bh as ke,bi as Ce,a$ as ye,k as Se,bj as we,bk as Ee,bl as z,bm as Ie,bn as H,bo as De,bp as Ae,bq as Le,br as Te,bs as Pe,v as K,h as Ne,bt as Fe}from"./index-DACeLBg-.js";const[Y,Be]=j(""),U=ne(()=>Y().includes("sing-box")),Ue=()=>{re().then(Be)};var je=f('
'),Re=f('
'),qe=f('
'),F=f("