diff --git a/package/ctcgfw/luci-app-openclash/Makefile b/package/ctcgfw/luci-app-openclash/Makefile index 72fe27e393..32bab84eb1 100644 --- a/package/ctcgfw/luci-app-openclash/Makefile +++ b/package/ctcgfw/luci-app-openclash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash -PKG_VERSION:=0.40.4 +PKG_VERSION:=0.40.6 PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong @@ -23,22 +23,23 @@ define Package/$(PKG_NAME)/description endef define Build/Prepare - $(CP) $(CURDIR)/files $(PKG_BUILD_DIR) - $(foreach po,$(wildcard ${CURDIR}/i18n/zh-cn/*.po), \ + $(CP) $(CURDIR)/root $(PKG_BUILD_DIR) + $(CP) $(CURDIR)/luasrc $(PKG_BUILD_DIR) + $(foreach po,$(wildcard ${CURDIR}/po/zh-cn/*.po), \ po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));) - chmod 0755 $(PKG_BUILD_DIR)/files/etc/init.d/openclash - chmod -R 0755 $(PKG_BUILD_DIR)/files/usr/share/openclash/ - mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/config >/dev/null 2>&1 - mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/rule_provider >/dev/null 2>&1 - mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/backup >/dev/null 2>&1 - mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/core >/dev/null 2>&1 - mkdir -p $(PKG_BUILD_DIR)/files/usr/share/openclash/backup >/dev/null 2>&1 - cp "$(PKG_BUILD_DIR)/files/etc/config/openclash" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash" >/dev/null 2>&1 - cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_rules.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1 - cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_rules_2.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1 - cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_hosts.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1 - cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_fake_filter.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1 - cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_domain_dns.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/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 >/dev/null 2>&1 + mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/rule_provider >/dev/null 2>&1 + mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/backup >/dev/null 2>&1 + mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/core >/dev/null 2>&1 + mkdir -p $(PKG_BUILD_DIR)/root/usr/share/openclash/backup >/dev/null 2>&1 + cp "$(PKG_BUILD_DIR)/root/etc/config/openclash" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash" >/dev/null 2>&1 + cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1 + cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules_2.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1 + cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_hosts.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1 + cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_fake_filter.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1 + cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_domain_dns.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1 endef define Build/Configure @@ -47,165 +48,51 @@ endef define Build/Compile endef +define Package/$(PKG_NAME)/conffiles +endef + define Package/$(PKG_NAME)/preinst #!/bin/sh if [ -f "/etc/config/openclash" ]; then cp "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1 - cp "/etc/config/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1 - cp "/etc/config/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1 - cp "/etc/config/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1 - cp "/etc/config/openclash_custom_fake_filter.list" "/tmp/openclash_custom_fake_filter.list.bak" >/dev/null 2>&1 - cp -r "/etc/openclash/history" "/tmp/openclash_history" >/dev/null 2>&1 -fi -if [ -f "/etc/openclash/custom/openclash_custom_rules.list" ]; then - cp "/etc/openclash/custom/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1 - cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1 - cp "/etc/openclash/custom/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1 - cp "/etc/openclash/custom/openclash_custom_fake_filter.list" "/tmp/openclash_custom_fake_filter.list.bak" >/dev/null 2>&1 - cp "/etc/openclash/custom/openclash_custom_domain_dns.list" "/tmp/openclash_custom_domain_dns.list.bak" >/dev/null 2>&1 + cp -r "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1 fi endef define Package/$(PKG_NAME)/postinst -#!/bin/sh -uci delete ucitrack.@openclash[-1] >/dev/null 2>&1 -uci add ucitrack openclash >/dev/null 2>&1 -uci set ucitrack.@openclash[-1].init=openclash >/dev/null 2>&1 -uci commit ucitrack >/dev/null 2>&1 -uci delete firewall.openclash >/dev/null 2>&1 -uci set firewall.openclash=include >/dev/null 2>&1 -uci set firewall.openclash.type=script >/dev/null 2>&1 -uci set firewall.openclash.path=/var/etc/openclash.include >/dev/null 2>&1 -uci set firewall.openclash.reload=1 >/dev/null 2>&1 -uci commit firewall >/dev/null 2>&1 -mkdir -p /etc/openclash/config >/dev/null 2>&1 -mkdir -p /etc/openclash/proxy_provider >/dev/null 2>&1 -mkdir -p /etc/openclash/backup >/dev/null 2>&1 -mkdir -p /etc/openclash/core >/dev/null 2>&1 -mkdir -p /etc/openclash/history >/dev/null 2>&1 -mkdir -p /usr/share/openclash/backup >/dev/null 2>&1 - -cp "/etc/config/openclash" "/usr/share/openclash/backup/openclash" >/dev/null 2>&1 -cp "/etc/openclash/custom/openclash_custom_rules.list" "/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1 -cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1 -cp "/etc/openclash/custom/openclash_custom_hosts.list" "/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1 -cp "/etc/openclash/custom/openclash_custom_fake_filter.list" "/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1 -cp "/etc/openclash/custom/openclash_custom_domain_dns.list" "/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1 - -if [ -f "/tmp/openclash.bak" ]; then - mv "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1 - mv "/tmp/openclash_custom_rules.list.bak" "/etc/openclash/custom/openclash_custom_rules.list" >/dev/null 2>&1 - mv "/tmp/openclash_custom_rules_2.list.bak" "/etc/openclash/custom/openclash_custom_rules_2.list" >/dev/null 2>&1 - mv "/tmp/openclash_custom_hosts.list.bak" "/etc/openclash/custom/openclash_custom_hosts.list" >/dev/null 2>&1 - mv "/tmp/openclash_custom_fake_filter.list.bak" "/etc/openclash/custom/openclash_custom_fake_filter.list" >/dev/null 2>&1 - mv "/tmp/openclash_custom_domain_dns.list.bak" "/etc/openclash/custom/openclash_custom_domain_dns.list" >/dev/null 2>&1 - if [ -d "/tmp/openclash_history/" ]; then - cp -a "/tmp/openclash_history/." "/etc/openclash/history" >/dev/null 2>&1 - rm -rf "/tmp/openclash_history" >/dev/null 2>&1 - fi -fi -if [ -f "/tmp/config.yaml" ]; then - mv "/tmp/config.yaml" "/etc/openclash/config/config.yaml" >/dev/null 2>&1 -elif [ -f "/tmp/config.yml" ]; then - mv "/tmp/config.yml" "/etc/openclash/config/config.yaml" >/dev/null 2>&1 -elif [ -d "/tmp/openclash_config/" ]; then - rm -rf "/etc/openclash/config" >/dev/null 2>&1 - mv "/tmp/openclash_config" "/etc/openclash/config" >/dev/null 2>&1 -fi -if [ -d "/tmp/openclash_proxy_provider/" ]; then - rm -rf "/etc/openclash/proxy_provider" >/dev/null 2>&1 - mv "/tmp/openclash_proxy_provider" "/etc/openclash/proxy_provider" >/dev/null 2>&1 -fi -if [ -d "/tmp/openclash_rule_provider/" ]; then - cp -a "/tmp/openclash_rule_provider/." "/etc/openclash/rule_provider" >/dev/null 2>&1 - rm -rf "/tmp/openclash_rule_provider" >/dev/null 2>&1 -fi -if [ -d "/tmp/openclash_game_rules/" ]; then - rm -rf "/etc/openclash/game_rules" >/dev/null 2>&1 - mv "/tmp/openclash_game_rules" "/etc/openclash/game_rules" >/dev/null 2>&1 -fi -if [ -f "/tmp/clash" ]; then - mv "/tmp/clash" "/etc/openclash/core/clash" >/dev/null 2>&1 -fi -if [ -f "/etc/openclash/clash" ]; then - mv "/etc/openclash/clash" "/etc/openclash/core/clash" >/dev/null 2>&1 -fi -if [ -d "/tmp/openclash_core/" ]; then - rm -rf "/etc/openclash/core" >/dev/null 2>&1 - mv "/tmp/openclash_core" "/etc/openclash/core" >/dev/null 2>&1 -fi -mkdir -p /lib/upgrade/keep.d >/dev/null 2>&1 -cat > "/lib/upgrade/keep.d/luci-app-openclash" <<-EOF -/etc/openclash/core/ -/etc/openclash/custom/ -/etc/openclash/config/ -/etc/openclash/game_rules/ -/etc/openclash/proxy_provider/ -/etc/openclash/rule_provider/ -EOF -uci set openclash.config.enable=0 >/dev/null 2>&1 -uci commit openclash >/dev/null 2>&1 -chmod 0755 /etc/init.d/openclash >/dev/null 2>&1 -chmod -R 0755 /usr/share/openclash/ >/dev/null 2>&1 -rm -rf /tmp/luci* endef define Package/$(PKG_NAME)/prerm #!/bin/sh uci set openclash.config.enable=0 >/dev/null 2>&1 uci commit openclash >/dev/null 2>&1 - mv "/etc/openclash/core" "/tmp/openclash_core" >/dev/null 2>&1 - mv "/etc/openclash/config.yaml" "/tmp/config.yaml" >/dev/null 2>&1 - mv "/etc/openclash/config" "/tmp/openclash_config" >/dev/null 2>&1 - mv "/etc/openclash/proxy_provider" "/tmp/openclash_proxy_provider" >/dev/null 2>&1 - mv "/etc/openclash/rule_provider" "/tmp/openclash_rule_provider" >/dev/null 2>&1 - mv "/etc/openclash/game_rules" "/tmp/openclash_game_rules" >/dev/null 2>&1 - mv "/etc/openclash/history" "/tmp/openclash_history" >/dev/null 2>&1 cp "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1 - cp "/etc/config/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1 - cp "/etc/config/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1 - cp "/etc/config/openclash_custom_fake_filter.list" "/tmp/openclash_custom_fake_filter.list.bak" >/dev/null 2>&1 - cp "/etc/openclash/custom/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1 - cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1 - cp "/etc/openclash/custom/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1 - cp "/etc/openclash/custom/openclash_custom_fake_filter.list" "/tmp/openclash_custom_fake_filter.list.bak" >/dev/null 2>&1 - cp "/etc/openclash/custom/openclash_custom_domain_dns.list" "/tmp/openclash_custom_domain_dns.list.bak" >/dev/null 2>&1 + cp -r "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1 endef define Package/$(PKG_NAME)/postrm #!/bin/sh -if [ -f "/tmp/openclash_update.sh" ]; then - rm -rf /etc/openclash/config >/dev/null 2>&1 - rm -rf /etc/openclash/backup >/dev/null 2>&1 - rm -rf /etc/openclash/proxy_provider >/dev/null 2>&1 - rm -rf /etc/openclash/rule_provider >/dev/null 2>&1 - rm -rf /etc/openclash/game_rules >/dev/null 2>&1 - rm -rf /etc/openclash/history >/dev/null 2>&1 -else rm -rf /etc/openclash >/dev/null 2>&1 -fi - rm -rf /lib/upgrade/keep.d/luci-app-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 rm -rf /tmp/Proxy_Group >/dev/null 2>&1 rm -rf /tmp/rules_name >/dev/null 2>&1 rm -rf /tmp/rule_providers_name >/dev/null 2>&1 - rm -rf /tmp/openclash_last_version >/dev/null 2>&1 rm -rf /tmp/clash_last_version >/dev/null 2>&1 - rm -rf /etc/openclash/dnsmasq_fake_block.conf >/dev/null 2>&1 - rm -rf /etc/openclash/clash >/dev/null 2>&1 rm -rf /usr/share/openclash/backup >/dev/null 2>&1 uci delete firewall.openclash >/dev/null 2>&1 uci commit firewall >/dev/null 2>&1 uci delete ucitrack.@openclash[-1] >/dev/null 2>&1 uci commit ucitrack >/dev/null 2>&1 - rm -rf /tmp/luci* + rm -rf /tmp/luci* >/dev/null 2>&1 endef define Package/$(PKG_NAME)/install $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n $(INSTALL_DATA) $(PKG_BUILD_DIR)/*.*.lmo $(1)/usr/lib/lua/luci/i18n/ - $(CP) $(PKG_BUILD_DIR)/files/* $(1)/ + $(CP) $(PKG_BUILD_DIR)/root/* $(1)/ + $(CP) $(PKG_BUILD_DIR)/luasrc/* $(1)/usr/lib/lua/luci/ endef $(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/Country.mmdb b/package/ctcgfw/luci-app-openclash/files/etc/openclash/Country.mmdb deleted file mode 100644 index fc8c625b0d..0000000000 Binary files a/package/ctcgfw/luci-app-openclash/files/etc/openclash/Country.mmdb and /dev/null differ diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/openclash_version b/package/ctcgfw/luci-app-openclash/files/etc/openclash/openclash_version deleted file mode 100644 index f0464ca85f..0000000000 --- a/package/ctcgfw/luci-app-openclash/files/etc/openclash/openclash_version +++ /dev/null @@ -1,2 +0,0 @@ -v0.40.4-beta -data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXMAAAAqCAMAAAB2kksrAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ4IDc5LjE2NDAzNiwgMjAxOS8wOC8xMy0wMTowNjo1NyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIxLjAgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkNDMzcyRUM4RjVEMzExRUE4M0FGRDhGNEJDMkQyNjBGIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkNDMzcyRUM5RjVEMzExRUE4M0FGRDhGNEJDMkQyNjBGIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6Q0MzNzJFQzZGNUQzMTFFQTgzQUZEOEY0QkMyRDI2MEYiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6Q0MzNzJFQzdGNUQzMTFFQTgzQUZEOEY0QkMyRDI2MEYiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5LmPhGAAADAFBMVEVFmsqTvNO6uroGZp1FgKIJca2iwNJ2tdpYpdIJaqGCgoKenp5Tiqra2tqlpaUGXpFknbx4eHgFbaljlbHf398kapLn5+c/Pz/GxsahoaHOzs6Gvt/R5vJpaWksfKoGcKyizOWRkZFxcXG/v79GRkasrKy1tbUwk8tHi7NmrNU1dZrKyspiYmIHW4uEhIRLS0tDQ0Pg4OCLi4uDs85zobuSuM4EU4Dw9fd2dnbAwMCcnJwXYowFWIgFYJXCwsJBQUGx0OGz1uqStchCQkImcJsGdLKUxuJsbGy2trYIZJmjxdkFZZtHnM2Xl5cGXI6DrsbB1eDS0tLQ0NBlZWVFkbyNjY2yy9kJaJ4micJJns6TxOCDqsHR4uwFaaI2kMUrjsavr69gYGAahMEKdbJvb28ZdaqUlJQhhL1Kn88HbKXB2ecFcrA7l8sdh8M3k8gEXI4EYphyn7h0dHQXgb5FhamJweJDfqB0sdUJWIU1h7URgsMCc7QBcrNRUVFUVFRVVVVSUlIFdrcLfL1WVlYHeLkKe7wGd7gOf8AOgMADdLUEdrYDdLQDdbUEdbYSg8MSg8RXV1cShMQThMUAcrIOf78Nfr8Nfr4Mfb4Mfb0JersJe7sJeroIebkIebo6OjqqqqrU1NTV1dWrq6tISEg9PT2pqanC3u7w9/s7OzuAgIB+fn48PDwHVoTB3u4GVYJJSUmEvd0GVYGEvN2BgYHq6urz8/P19fVMTEz09PTh7/eFvt6CqcB/f3/B3e2DvNzv9PeJiYng6u/o6OjB3e6EtNBVos9kq9MEVYPg7vaDq8IFZ6DA1N9Hm8zW1tZInc0JeLjR3+ihv9AlhLqCutrg6vDB1+MFa6aGhoYUXolortcLerk5lco6lcoEVYQHYpWDr8iFvd6jzuYIV4UnhrwKebgGdbSiyN6Fvd0KbqjC3+/D3+8VaJcZg8Dv9voGXY9TU1MPgMEQgcJZWVlaWlpfX19bW1tcXFxNTU1eXl5PT09QUFBYWFhdXV1OTk7///////8bi5SAAAABAHRSTlP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AU/cHJQAAC/1JREFUeNrsWAlUVNcZfm4RGQEHlFHAIDrgRpgBdYx1wQ3REBOsVkVjYsSYxRjXJKatiAzQvaVt0tZtWAYYwxJcWDWK+56tiSbGxMSsZnNaawNi+Oh/71vmvQENp8nxnJnjd07e/Zfvfv973x3ejBFaWqoX9r3qDfiLB2Dg046WFqEldtVV78CfPQIDw1qE6v6NXoI/eQYGOoSF3mJ54x89BE8L/b/zFvzcQzBQ+O6257caXuT5vz0Fwrdeg9ue33r8y1Mg/NdrcNvzW49fewqE/3gNfuUpaNNz38jIyJ8t/vFdmenrO1NJFvv6tmeP3lffTvXnb4gnu4Z2fbLt1mOPLZOiZT6hoT7L2t7/2ENulVCEPv9/Q7jijuip1eCInR595QfCN9JXk1djuhKPwtD2SLyCV9o57IUbYNmX/HG+XNZGbwqQIkbnHIzkONcGyQcIdSuFtqq4kBKa8sJN0cpzfSXgV6DThdAd+P5QzyMRqU6tAxCrHC0Q8eN6/rcb4As80GNQjwfwRevWOXrIFB6lAB0GDeogp2q8R6cR6lYLbVVpX49DuK5FdCyqFhsYTLoq3+s/EOS5Ju8PJErhdFSlt0fCaDC2c9jf28Y5vDV67dq1o0finHvLByPJZB7WYTiR1p5AnTvpIQexQt2Koa0q7etxCK1cqoo2mCtMJqPBYO3bXm/1vprj8fVNbNtzezD6SGE+pjZLZH3bitFunidqh0TLDBn/aBsTMDzgUuqlgBOY4NY57xg5hDznIUaunZOaOodO5ryWtCgMQcnY7bZ1N6s8lPKeqpQiZ7tV7JQUDUeEu+fV0BnW8chqYkE+dvFsF/Kl6/RYoOB6AQqiC+g1xLoF7AuguoDzgGie5kfzRISivk6HSslAYLGVjBvF+pVx1zXi1/tU8jKTLIAoHMdLo6IlZiLfOFV96xkSfFAnRXXwychwYM27FL+7Bo4MDRY5ELQWeJXFXZH8OFu7JaOrllWMOz46g93aYgb56lNHN1DnI2ldhJzJD52Rcb6OBw73zUKOBruAnHQ5SUvLySHPpUY+v8bmM5mCnAIM5SbsyqG3UXVH/47VGMV45BSqQ/zoG5iS/EpU5hNc+lcAPQ/6INiYk6OvRuVC/97AdI34VKCjv39PupccGlTA+NOB3v4LKxEbzZnV1TgYEkymq+5deaY60ceM88z8RcAjPHsEWKSxPIxeJ6mS51MwghffHYEpGn8uYvZHl4rb8Jxe8k8kQ9p+3oG6DofHA4PpkOpQV0zIyHgVdfccPvyZw03S3XOywqQpuHuO2j41hRXRZAUO7jcUrv82Jwp+FYWFhRVVuJt7zsqF0Twr1EFHrUKXnMkPUTyIRW4Tu05l/URUq8XpbyCRldeHKJ5T6W02xI+fLDFn9Kf0bb5PRpaELidwkQcXcaJL1r1AF7EM3JulwgTcUXYpSyoW47BYPYxiNakrXh89jbofZmnxIRzDRpeVjX4ddSwNIy1CZziysspO4ARLsrI+7szWMnp/LdJsFqwaFCDEqSnk40W+voh8fj3YUEqoIGJvA4ua6PdHmsFYYTREIIoYgKnUYI4vHYcCq9XcB33MBJecMwa1bL2bXjhWaxyCS2mvmdhxKvEXgVJjRUV8aSm/IxKyjsK4UjMNYcfBmH4GmmIorZLujkN5psnA17R87cDkLOb5J7z6idbzi0gu65bl8nyfWN6n8Xww6kdfYN3P3Tz/HPeXlQUElPUCnsrK8sFbZXd16nahbDZ8sgI+wAcBBDrlsrumdes2bUyy9rBbez7DelPPQwwVadY0JxF1hhryMC0OfvFp1EpbzBkAK1vpxV2gGKZGA5i9VvrjMLJrrpEVmzhbEe8LDEhkB2RWJHoigsmmxVeJpxNibqK0JkTt+SYZc2ZjMC2DMXvOpk3kuVQmexUKNV8ffcFVLMZ2sb4dxS7SU476Ife95uoWi+C0++dQ47X73mKjpmDiNNbvMp8Rt8taqV023bt9+4Qn6tWDCcJ6DXLRU1sgz/lKnvPrDKdM9JcDBYwBiAR/5PJmrlZufc04DKClEhHpTFxBrkr8Gr3P0XOAru96RQK4W2yFSExR7afS3XFslJEahDBaitE9dePG04BUBk4rlI0Y2StAVSRXxTp57iKRwkevqbrSvXKaWElNZkGx6zm2u3oUOaSqajDBzXM98PBNPc9XDidXDipzOfx1cdwcdb+15049ah8mHTRw8Xx5r14lnl4a48dvVafyXG+VXM5VMfPVnm9WMLYeT22eiwNjKf4YkKrAxy4KVCjfvPkz7BTrO/GZi1SuZlHeWQSnSfwnWFCO8p0cw+bPUvXmAff0WDM54AxOb1ZDSNMCWKLJ8/AyX19GnnJlICvkwG+bhHi+X91XWC6Yq2jCAIyr4OJF8l67WtxMhcQI+lmySpaown6x1RM6FVO+O46tCh6fiH5bd2J+IMX01XmaF+kD38VFST5TzgGElc/bunUYysV6OYYpnI0dkkWSA8fLWf8lERSRryInDM+yTROl1kudXL3VwModrJYs3YEMN8+bp6Lyqpxc7cueav/NPae/jO/sIkzt8bxmKoam1SImnWJ/BEtb7c1q8TSTgZ1DMNstSoQgSrwl+sDfyPMtLvSCY/VxTGZhQjKO8hr9BE9wMXZIADrvuLxlyyAcF+sODNqqkC5LpGTM37GD8nARFO3DPs6YCzy3ZcswHOgkIdzVE4AdFx4PT9hSDmGLGoJTg3QnvUkbxXh/bYnT2REDWNw4AHm0lPArQxGKxMAYjKFSbRX9R+9zVV8n7taAfujoUDWJhfRrXScWG/uqxFfRXGeDvdCPdUWht1HbKMoG21XMPJS4hDNdSDqFCZjdiccrcYivYVjJlqOHDj1Iy2UJwJrLSZmZneohsO4R1PNdhw7NYzIS6Qzuv3w5Uw3yla/9cGBB5lb6ofSsWF89NzPzWfTjMXl+J1sfPC5qK3Dz3GmOoV/JUftLSoronyQl7PFQVFISVYsbed5AH/ShRFylqyxq5Xki6Nwal2gnBKMWUSZ+XkWkTidF+iUqcQr2Nzr7FqHqqixk8ENPUiK+vqEdnicE0Qu4ewKPvzqAfnMz5/ZD/VeiWxoHpCx8JRxHyHIH5oeL5b0q0l7JYbXnjnlHhKOH6M+kC53YRGAfnaQwz0Fqz4Guq49mhh9A2FHhSD/gezy/ZksMlr40qnRXyKEoHh9cciPPnYX6KmnDT1p5bhd3ayY0R1DlYWmYTv6G6q8S7y8JVsXYZaEKo/itiphC5408z1bhvnocCBDDk0Pq+c76ISdZyjxXEeXs/TdE/Tfel8p7VSTyPFuLfdJt1weNoSzBskd+jgdpoCiVHSgN7vCAZmJ2tpDuhgqbTa8LCQkp0ttsNenpJlvMqJBxMaVOXRw1Z/Irg16nlyKTzRjTcUZexyVOI2U6nbrfbIsZl9e7j3aCVafTmcXQaHNG9J6RFxljrFGJ1xhjImfk9Y4wll5TBhlsNGSGzmkzqW8jTjfTpat+rAXd93Q/K4afjnln+Pi944e/8/6nLJ21Z88/VUQ5O2l5ZsTevSOesSRJ5R4qUo89s9w8n7Wnc/c7kk9N7GUJZOkKSy+asbdD0DuUhluCZh8a/0F29pheE0+dGnGnJUgzsQ3P02sKbSK2GZsoNfO40GgzsB6/im4Z5Q2mbdIGVrHZNH1xt3aAkSoNqpijQSXeIAluq3AJNRnEWkW6+jYM7GMhY4Maxyxj5DD8mIXhWDjPkiyWQBVPycZykmWsXF6uIi23JG3QIklkW44t0OaWcEVKGbziLs3EDRuEda3B/j+uwWySMnu8Id6+rtlop1i8ihyTwm+yTzIYJhmbWWw0avtst1Er32w0GlVJPM2yN2nEm+xmA21r0gxiQ8QZLqZdKnBonuts0lklTjgZsDzgZIKYBCYlLVWbp2SBK5YvXxGolBeoSAuSAt08D0wKPDuW+IrUUpqxfMUCccgCmsdOaSmTDKftS7/Xcw/Fbz0FQpPX4A+eAi/y/PeeAuGa1+A3ngIv8vx3ngJhZrO34BcegkcF/9ue32K8KdR6zQf9l56BR78RWnpGN3gHPMTysBahpaXW3ztc/6sH4NE3v2lp+Z8AAwBqGYBHXyli7QAAAABJRU5ErkJggg== \ No newline at end of file diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/state.htm b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/state.htm deleted file mode 100644 index 1bf0200552..0000000000 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/state.htm +++ /dev/null @@ -1,52 +0,0 @@ - -
- - - - - -
-

- 组件的状态显示,运行前请确保各项目显示正常,需要更新请到全局设置页面操作 -

-
策略组节点选择 备份日期 <%:Collecting data...%> lhie1 规则更新日期 <%:Collecting data...%>
ConnersHua 规则更新日期 <%:Collecting data...%> ConnersHua 回国规则更新日期 <%:Collecting data...%>
大陆IP白名单 更新日期 <%:Collecting data...%> GEOIP(By MaxMind)数据库日期 <%:Collecting data...%>
-
- - \ No newline at end of file diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh deleted file mode 100755 index cca7f3a683..0000000000 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh +++ /dev/null @@ -1,241 +0,0 @@ -#!/bin/bash -. /lib/functions.sh -. /usr/share/openclash/openclash_ps.sh - -status=$(unify_ps_status "openclash.sh") -[ "$status" -gt 3 ] && exit 0 - -START_LOG="/tmp/openclash_start.log" -LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") -LOG_FILE="/tmp/openclash.log" -CFG_FILE="/tmp/config.yaml" -CRON_FILE="/etc/crontabs/root" -CONFIG_PATH=$(uci get openclash.config.config_path 2>/dev/null) -servers_update=$(uci get openclash.config.servers_update 2>/dev/null) -dns_port=$(uci get openclash.config.dns_port 2>/dev/null) -enable_redirect_dns=$(uci get openclash.config.enable_redirect_dns 2>/dev/null) -disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null) -if_restart=0 - -urlencode() { - local data - if [ "$#" -eq 1 ]; then - data=$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$1" "") - if [ ! -z "$data" ]; then - echo "${data##/?}" - fi - fi -} - -kill_watchdog() { - - watchdog_pids=$(unify_ps_pids "openclash_watchdog.sh") - for watchdog_pid in $watchdog_pids; do - kill -9 "$watchdog_pid" >/dev/null 2>&1 - done -} - -config_download() -{ -if [ "$URL_TYPE" == "v2rayn" ]; then - subscribe_url=$(urlencode "$subscribe_url") - curl -sL --connect-timeout 10 --retry 2 https://tgbot.lbyczf.com/v2rayn2clash?url="$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1 -elif [ "$URL_TYPE" == "surge" ]; then - subscribe_url=$(urlencode "$subscribe_url") - curl -sL --connect-timeout 10 --retry 2 https://tgbot.lbyczf.com/surge2clash?url="$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1 -else - curl -sL --connect-timeout 10 --retry 2 --user-agent "clash" "$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1 -fi -} - -config_cus_up() -{ - if [ -z "$CONFIG_PATH" ]; then - CONFIG_PATH="/etc/openclash/config/$(ls -lt /etc/openclash/config/ | grep -E '.yaml|.yml' | head -n 1 |awk '{print $9}')" - uci set openclash.config.config_path="$CONFIG_PATH" - uci commit openclash - fi - if [ "$servers_update" -eq 1 ] || [ ! -z "$keyword" ] || [ ! -z "$ex_keyword" ]; then - echo "配置文件【$name】替换成功,开始挑选节点..." >$START_LOG - uci set openclash.config.config_update_path="/etc/openclash/config/$name.yaml" - uci set openclash.config.servers_if_update=1 - uci commit openclash - /usr/share/openclash/yml_groups_get.sh - uci set openclash.config.servers_if_update=1 - uci commit openclash - /usr/share/openclash/yml_groups_set.sh - if [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then - if_restart=1 - fi - echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE - echo "配置文件【$name】更新成功!" >$START_LOG - sleep 3 - echo "" >$START_LOG - elif [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then - echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE - echo "配置文件【$name】更新成功!" >$START_LOG - sleep 3 - if_restart=1 - else - echo "配置文件【$name】更新成功!" >$START_LOG - echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE - sleep 3 - echo "" >$START_LOG - fi - rm -rf /tmp/Proxy_Group 2>/dev/null -} - -config_su_check() -{ - echo "配置文件下载成功,检查是否有更新..." >$START_LOG - if [ -f "$CONFIG_FILE" ]; then - cmp -s "$BACKPACK_FILE" "$CFG_FILE" - if [ "$?" -ne 0 ]; then - echo "配置文件【$name】有更新,开始替换..." >$START_LOG - mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null - cp "$CONFIG_FILE" "$BACKPACK_FILE" - config_cus_up - else - echo "配置文件【$name】没有任何更新,停止继续操作..." >$START_LOG - rm -rf "$CFG_FILE" - echo "${LOGTIME} Updated Config【$name】 No Change, Do Nothing" >>$LOG_FILE - sleep 5 - echo "" >$START_LOG - fi - else - echo "配置文件下载成功,本地没有配置文件,开始创建 ..." >$START_LOG - mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null - cp "$CONFIG_FILE" "$BACKPACK_FILE" - config_cus_up - fi -} - -config_encode() -{ - /usr/share/openclash/yml_field_name_ch.sh "$CFG_FILE" -} - -config_error() -{ - echo "配置文件【$name】下载失败,请检查网络或稍后再试!" >$START_LOG - echo "${LOGTIME} Config 【$name】Update Error" >>$LOG_FILE - rm -rf "$CFG_FILE" 2>/dev/null - sleep 5 - echo "" >$START_LOG -} - -change_dns() -{ - if pidof clash >/dev/null; then - if [ "$enable_redirect_dns" -ne 0 ]; then - uci del dhcp.@dnsmasq[-1].server >/dev/null 2>&1 - uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1 - uci delete dhcp.@dnsmasq[0].resolvfile >/dev/null 2>&1 - uci set dhcp.@dnsmasq[0].noresolv=1 >/dev/null 2>&1 - [ "$disable_masq_cache" -eq 1 ] && { - uci set dhcp.@dnsmasq[0].cachesize=0 >/dev/null 2>&1 - } - uci commit dhcp - /etc/init.d/dnsmasq restart >/dev/null 2>&1 - fi - nohup /usr/share/openclash/openclash_watchdog.sh & - fi -} - -config_download_direct() -{ - if pidof clash >/dev/null; then - echo "配置文件【$name】下载失败,尝试不使用代理下载配置文件..." >$START_LOG - - kill_watchdog - - uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1 - uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto >/dev/null 2>&1 - uci set dhcp.@dnsmasq[0].noresolv=0 >/dev/null 2>&1 - uci delete dhcp.@dnsmasq[0].cachesize >/dev/null 2>&1 - uci commit dhcp - /etc/init.d/dnsmasq restart >/dev/null 2>&1 - sleep 3 - - config_download - - if [ "$?" -eq 0 ] && [ -s "$CFG_FILE" ]; then - change_dns - config_su_check - else - change_dns - config_error - fi - else - config_error - fi -} - -sub_info_get() -{ - local section="$1" - config_get_bool "enabled" "$section" "enabled" "1" - config_get "name" "$section" "name" "" - config_get "type" "$section" "type" "" - config_get "address" "$section" "address" "" - config_get "keyword" "$section" "keyword" "" - config_get "ex_keyword" "$section" "ex_keyword" "" - - if [ "$enabled" -eq 0 ]; then - return - fi - - if [ -z "$address" ]; then - return - else - subscribe_url="$address" - fi - - if [ -z "$name" ]; then - name="config" - CONFIG_FILE="/etc/openclash/config/config.yaml" - BACKPACK_FILE="/etc/openclash/backup/config.yaml" - else - CONFIG_FILE="/etc/openclash/config/$name.yaml" - BACKPACK_FILE="/etc/openclash/backup/$name.yaml" - fi - - URL_TYPE="$type" - - echo "开始更新配置文件【$name】..." >$START_LOG - - config_download - - if [ "$?" -eq 0 ] && [ -s "$CFG_FILE" ]; then - config_encode - if [ -n "$(grep "^ \{0,\}proxy-groups:" "$CFG_FILE")" ]; then - if [ -n "$(grep "^ \{0,\}Proxy:" "$CFG_FILE" 2>/dev/null)" ] || [ -n "$(grep "^ \{0,\}proxy-providers:" "$CFG_FILE" 2>/dev/null)" ]; then - if [ -n "$(grep "^ \{0,\}rules:" "$CFG_FILE" 2>/dev/null)" ] || [ -n "$(grep "^ \{0,\}script:" "$CFG_FILE" 2>/dev/null)" ]; then - config_su_check - else - config_download_direct - fi - else - config_download_direct - fi - else - config_download_direct - fi - else - config_download_direct - fi -} - -#分别获取订阅信息进行处理 -config_load "openclash" -config_foreach sub_info_get "config_subscribe" -uci delete openclash.config.config_update_path >/dev/null 2>&1 -uci commit openclash - -if [ "$if_restart" -eq 1 ]; then - /etc/init.d/openclash restart >/dev/null 2>&1 -else - sed -i '/openclash.sh/d' $CRON_FILE 2>/dev/null - [ "$(uci get openclash.config.auto_update 2>/dev/null)" -eq 1 ] && [ "$(uci get openclash.config.config_auto_update_mode 2>/dev/null)" -ne 1 ] && echo "0 $(uci get openclash.config.auto_update_time 2>/dev/null) * * $(uci get openclash.config.config_update_week_time 2>/dev/null) /usr/share/openclash/openclash.sh" >> $CRON_FILE - /etc/init.d/cron restart -fi diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua b/package/ctcgfw/luci-app-openclash/luasrc/controller/openclash.lua similarity index 90% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua rename to package/ctcgfw/luci-app-openclash/luasrc/controller/openclash.lua index 85fdbe32b1..1200635f54 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua +++ b/package/ctcgfw/luci-app-openclash/luasrc/controller/openclash.lua @@ -16,6 +16,11 @@ function index() entry({"admin", "services", "openclash", "startlog"},call("action_start")).leaf=true entry({"admin", "services", "openclash", "close_all_connection"},call("action_close_all_connection")) entry({"admin", "services", "openclash", "restore_history"},call("action_restore_history")) + entry({"admin", "services", "openclash", "get_history"},call("action_get_history")) + entry({"admin", "services", "openclash", "reload_firewall"},call("action_reload_firewall")) + entry({"admin", "services", "openclash", "update_subscribe"},call("action_update_subscribe")) + entry({"admin", "services", "openclash", "update_other_rules"},call("action_update_other_rules")) + entry({"admin", "services", "openclash", "update_geoip"},call("action_update_geoip")) entry({"admin", "services", "openclash", "currentversion"},call("action_currentversion")) entry({"admin", "services", "openclash", "lastversion"},call("action_lastversion")) entry({"admin", "services", "openclash", "update"},call("action_update")) @@ -39,6 +44,7 @@ function index() entry({"admin", "services", "openclash", "proxy-provider-file-manage"},form("openclash/proxy-provider-file-manage"), nil).leaf = true entry({"admin", "services", "openclash", "rule-providers-file-manage"},form("openclash/rule-providers-file-manage"), nil).leaf = true entry({"admin", "services", "openclash", "config-subscribe"},cbi("openclash/config-subscribe"),_("Config Update"), 60).leaf = true + entry({"admin", "services", "openclash", "config-subscribe-edit"},cbi("openclash/config-subscribe-edit"), nil).leaf = true entry({"admin", "services", "openclash", "servers-config"},cbi("openclash/servers-config"), nil).leaf = true entry({"admin", "services", "openclash", "groups-config"},cbi("openclash/groups-config"), nil).leaf = true entry({"admin", "services", "openclash", "proxy-provider-config"},cbi("openclash/proxy-provider-config"), nil).leaf = true @@ -79,15 +85,15 @@ local function ipdb() end local function lhie1() - return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/etc/openclash/lhie1.yaml")) + return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/usr/share/openclash/res/lhie1.yaml")) end local function ConnersHua() - return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/etc/openclash/ConnersHua.yaml")) + return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/usr/share/openclash/res/ConnersHua.yaml")) end local function ConnersHua_return() - return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/etc/openclash/ConnersHua_return.yaml")) + return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/usr/share/openclash/res/ConnersHua_return.yaml")) end local function chnroute() @@ -119,7 +125,7 @@ local function check_lastversion() end local function check_currentversion() - return luci.sys.exec("sed -n '/^data:image/,$p' /etc/openclash/openclash_version 2>/dev/null") + return luci.sys.exec("sed -n '/^data:image/,$p' /usr/share/openclash/res/openclash_version 2>/dev/null") end local function startlog() @@ -169,7 +175,7 @@ local function corelv() end local function opcv() - return luci.sys.exec("sed -n 1p /etc/openclash/openclash_version 2>/dev/null") + return luci.sys.exec("sed -n 1p /usr/share/openclash/res/openclash_version 2>/dev/null") end local function oplv() @@ -386,6 +392,27 @@ function action_restore_history() return luci.sys.call("sh /usr/share/openclash/openclash_history_set.sh") end +function action_get_history() + return luci.sys.call("sh /usr/share/openclash/openclash_history_get.sh") +end + +function action_reload_firewall() + return luci.sys.call("/etc/init.d/openclash reload") +end + +function action_update_subscribe() + fs.unlink("/tmp/Proxy_Group") + return luci.sys.call("/usr/share/openclash/openclash.sh >/dev/null 2>&1") +end + +function action_update_other_rules() + return luci.sys.call("/usr/share/openclash/openclash_rule.sh >/dev/null 2>&1") +end + +function action_update_geoip() + return luci.sys.call("/usr/share/openclash/openclash_ipdb.sh >/dev/null 2>&1") +end + function act_ping() local e={} e.index=luci.http.formvalue("index") diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/client.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/client.lua similarity index 98% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/client.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/client.lua index cd6305b823..2a513a01bf 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/client.lua +++ b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/client.lua @@ -13,7 +13,6 @@ m.description = translate("A Clash Client For OpenWrt") m.pageaction = false m:section(SimpleSection).template = "openclash/status" -m:section(SimpleSection).template = "openclash/state" function IsYamlFile(e) e=e or"" diff --git a/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe-edit.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe-edit.lua new file mode 100644 index 0000000000..23dd026c03 --- /dev/null +++ b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe-edit.lua @@ -0,0 +1,147 @@ + +local m, s, o +local openclash = "openclash" +local uci = luci.model.uci.cursor() +local fs = require "luci.openclash" +local sys = require "luci.sys" +local sid = arg[1] + +font_red = [[]] +font_off = [[]] +bold_on = [[]] +bold_off = [[]] + + +m = Map(openclash, translate("Config Subscribe Edit")) +m.pageaction = false +m.description=translate("Convert Subscribe function of Online is Supported By subconverter Written By tindy X") .. translate("
\ +
API By tindy X & lhie1 \ +
\ +
subconverter 外部配置(订阅转换模板)说明:https://github.com/tindy2013/subconverter#external-configuration-file \ +
\ +
如需自定义外部配置文件(订阅转换模板),请按照说明编写后上传至外部网络可访问的位置,并在使用时正确填写地址 \ +
\ +
如您有值得推荐的外部配置文件(订阅转换模板),可以按照 /usr/share/openclash/res/sub_ini.list 的文件格式修改后提交PR") +m.redirect = luci.dispatcher.build_url("admin/services/openclash/config-subscribe") +if m.uci:get(openclash, sid) ~= "config_subscribe" then + luci.http.redirect(m.redirect) + return +end + +-- [[ Config Subscribe Setting ]]-- +s = m:section(NamedSection, sid, "config_subscribe") +s.anonymous = true +s.addremove = false + +---- name +o = s:option(Value, "name", translate("Config Alias")) +o.description = font_red..bold_on..translate("(Name For Distinguishing)")..bold_off..font_off +o.placeholder = translate("config") +o.rmempty = true + +---- address +o = s:option(Value, "address", translate("Subscribe Address")) +o.description = font_red..bold_on..translate("(Not Null)")..bold_off..font_off +o.placeholder = translate("Not Null") +o.datatype = "or(host, string)" +o.rmempty = false + +---- subconverter +o = s:option(ListValue, "sub_convert", translate("Subscribe Convert Online")) +o.description = translate("Convert Subscribe Online With Template, Mix Proxies and Keep Settings options Will Not Effect") +o:value("0", translate("Disable")) +o:value("1", translate("Enable")) +o.default=0 + +---- Template +o = s:option(ListValue, "template", translate("Template Name")) +o.rmempty = true +o:depends("sub_convert", "1") +file = io.open("/usr/share/openclash/res/sub_ini.list", "r"); +for l in file:lines() do + if l ~= "" and l ~= nil then + o:value(string.sub(luci.sys.exec(string.format("echo '%s' |awk -F ',' '{print $1}' 2>/dev/null",l)),1,-2)) + end +end +file:close() +o:value("0", translate("Custom Template")) + +---- Custom Template +o = s:option(Value, "custom_template_url", translate("Custom Template URL")) +o.rmempty = true +o.placeholder = translate("Not Null") +o.datatype = "or(host, string)" +o:depends("template", "0") + +---- emoji +o = s:option(ListValue, "emoji", translate("Emoji")) +o.rmempty = false +o:value("false", translate("Disable")) +o:value("true", translate("Enable")) +o.default=0 +o:depends("sub_convert", "1") + +---- udp +o = s:option(ListValue, "udp", translate("UDP Enable")) +o.rmempty = false +o:value("false", translate("Disable")) +o:value("true", translate("Enable")) +o.default=0 +o:depends("sub_convert", "1") + +---- skip-cert-verify +o = s:option(ListValue, "skip_cert_verify", translate("skip-cert-verify")) +o.rmempty = false +o:value("false", translate("Disable")) +o:value("true", translate("Enable")) +o.default=0 +o:depends("sub_convert", "1") + +---- sort +o = s:option(ListValue, "sort", translate("Sort")) +o.rmempty = false +o:value("false", translate("Disable")) +o:value("true", translate("Enable")) +o.default=0 +o:depends("sub_convert", "1") + +---- node type +o = s:option(ListValue, "node_type", translate("Append Node Type")) +o.rmempty = false +o:value("false", translate("Disable")) +o:value("true", translate("Enable")) +o.default=0 +o:depends("sub_convert", "1") + +---- key +o = s:option(DynamicList, "keyword", font_red..bold_on..translate("Keyword Match")..bold_off..font_off) +o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off +o.rmempty = true + +---- exkey +o = s:option(DynamicList, "ex_keyword", font_red..bold_on..translate("Exclude Keyword Match")..bold_off..font_off) +o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off +o.rmempty = true + +local t = { + {Commit, Back} +} +a = m:section(Table, t) + +o = a:option(Button,"Commit") +o.inputtitle = translate("Commit Configurations") +o.inputstyle = "apply" +o.write = function() + m.uci:commit(openclash) + luci.http.redirect(m.redirect) +end + +o = a:option(Button,"Back") +o.inputtitle = translate("Back Configurations") +o.inputstyle = "reset" +o.write = function() + m.uci:revert(openclash) + luci.http.redirect(m.redirect) +end + +return m diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config-subscribe.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe.lua similarity index 70% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config-subscribe.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe.lua index ad38dfbeb2..1e12dc9889 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config-subscribe.lua +++ b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/config-subscribe.lua @@ -62,15 +62,22 @@ o:depends("config_auto_update_mode", "1") o.rmempty = true -- [[ Edit Server ]] -- -s = m:section(TypedSection, "config_subscribe") +s = m:section(TypedSection, "config_subscribe", translate("Config Subscribe Edit")) s.anonymous = true s.addremove = true -s.sortable = false +s.sortable = true s.template = "cbi/tblsection" -s.rmempty = false +s.extedit = luci.dispatcher.build_url("admin/services/openclash/config-subscribe-edit/%s") +function s.create(...) + local sid = TypedSection.create(...) + if sid then + luci.http.redirect(s.extedit % sid) + return + end +end ---- enable flag -o = s:option(Flag, "enabled", translate("Enable"), font_red..bold_on..translate("(Enable or Disable Subscribe)")..bold_off..font_off) +o = s:option(Flag, "enabled", translate("Enable")) o.rmempty = false o.default = o.enabled o.cfgvalue = function(...) @@ -78,36 +85,26 @@ o.cfgvalue = function(...) end ---- name -o = s:option(Value, "name", translate("Config Alias")) -o.description = font_red..bold_on..translate("(Name For Distinguishing)")..bold_off..font_off -o.placeholder = translate("config") -o.rmempty = true - ----- type -o = s:option(ListValue, "type", translate("Subscribe Type")) -o.description = font_red..bold_on..translate("(Power By fndroid)")..bold_off..font_off -o:value("clash", translate("Clash")) -o:value("v2rayn", translate("V2rayN")) -o:value("surge", translate("Surge")) -o.default="clash" -o.rempty = false +o = s:option(DummyValue, "name", translate("Config Alias")) +function o.cfgvalue(...) + return Value.cfgvalue(...) or translate("config") +end ---- address o = s:option(Value, "address", translate("Subscribe Address")) -o.description = font_red..bold_on..translate("(Not Null)")..bold_off..font_off -o.placeholder = translate("Not Null") -o.datatype = "or(host, string)" -o.rmempty = false +function o.cfgvalue(...) + return Value.cfgvalue(...) or translate("None") +end ----- key -o = s:option(DynamicList, "keyword", font_red..bold_on..translate("Keyword Match")..bold_off..font_off) -o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off -o.rmempty = true - ----- exkey -o = s:option(DynamicList, "ex_keyword", font_red..bold_on..translate("Exclude Keyword Match")..bold_off..font_off) -o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off -o.rmempty = true +---- template +o = s:option(DummyValue, "template", translate("Template Name")) +function o.cfgvalue(...) + if Value.cfgvalue(...) ~= "0" then + return Value.cfgvalue(...) or translate("None") + else + return translate("Custom Template") + end +end local t = { {Commit, Apply} diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/config.lua similarity index 80% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/config.lua index f5d5f05418..3d915ad13e 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua +++ b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/config.lua @@ -24,6 +24,26 @@ function IsYmlFile(e) return e == ".yml" end +function default_config_set(f) + local cf=string.sub(luci.sys.exec("uci get openclash.config.config_path 2>/dev/null"), 1, -2) + if cf == "/etc/openclash/config/"..f or not cf or cf == "" or not fs.isfile(cf) then + if CHIF == "1" and cf == "/etc/openclash/config/"..f then + return + end + local fis = fs.glob("/etc/openclash/config/*")[1] + if fis ~= nil then + fcf = fs.basename(fis) + if fcf then + luci.sys.exec(string.format('uci set openclash.config.config_path="/etc/openclash/config/%s"',fcf)) + uci:commit("openclash") + end + else + luci.sys.exec("uci set openclash.config.config_path=/etc/openclash/config/config.yaml") + uci:commit("openclash") + end + end +end + function config_check(CONFIG_FILE) local yaml = fs.isfile(CONFIG_FILE) local proxy,group,rule @@ -106,11 +126,11 @@ HTTP.setfilehandler( if not meta then return end if fp == "config" then - if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end + if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end elseif fp == "proxy-provider" then - if meta and chunk then fd = nixio.open(proxy_pro_dir .. meta.file, "w") end + if meta and chunk then fd = nixio.open(proxy_pro_dir .. meta.file, "w") end elseif fp == "rule-provider" then - if meta and chunk then fd = nixio.open(rule_pro_dir .. meta.file, "w") end + if meta and chunk then fd = nixio.open(rule_pro_dir .. meta.file, "w") end end if not fd then @@ -124,23 +144,26 @@ HTTP.setfilehandler( if eof and fd then fd:close() fd = nil - if IsYamlFile(meta.file) and fp == "config" then - local yamlbackup="/etc/openclash/backup/" .. meta.file - local c=fs.copy(dir .. meta.file,yamlbackup) - end - if IsYmlFile(meta.file) and fp == "config" then - local ymlname=string.lower(string.sub(meta.file,0,-5)) - local ymlbackup="/etc/openclash/backup/".. ymlname .. ".yaml" - local c=fs.rename(dir .. meta.file,"/etc/openclash/config/".. ymlname .. ".yaml") - local c=fs.copy("/etc/openclash/config/".. ymlname .. ".yaml",ymlbackup) - end if fp == "config" then - um.value = translate("File saved to") .. ' "/etc/openclash/config/"' - CHIF = "1" + CHIF = "1" + if IsYamlFile(meta.file) then + local yamlbackup="/etc/openclash/backup/" .. meta.file + local c=fs.copy(dir .. meta.file,yamlbackup) + default_config_set(meta.file) + end + if IsYmlFile(meta.file) then + local ymlname=string.lower(string.sub(meta.file,0,-5)) + local ymlbackup="/etc/openclash/backup/".. ymlname .. ".yaml" + local c=fs.rename(dir .. meta.file,"/etc/openclash/config/".. ymlname .. ".yaml") + local c=fs.copy("/etc/openclash/config/".. ymlname .. ".yaml",ymlbackup) + local yamlname=ymlname .. ".yaml" + default_config_set(yamlname) + end + um.value = translate("File saved to") .. ' "/etc/openclash/config/"' elseif fp == "proxy-provider" then - um.value = translate("File saved to") .. ' "/etc/openclash/proxy_provider/"' + um.value = translate("File saved to") .. ' "/etc/openclash/proxy_provider/"' elseif fp == "rule-provider" then - um.value = translate("File saved to") .. ' "/etc/openclash/rule_provider/"' + um.value = translate("File saved to") .. ' "/etc/openclash/rule_provider/"' end fs.unlink("/tmp/Proxy_Group") end @@ -259,11 +282,12 @@ Button.render(e,t,a) end btnrm.write=function(a,t) fs.unlink("/tmp/Proxy_Group") - fs.unlink("/etc/openclash/backup/"..luci.openclash.basename(e[t].name)) - fs.unlink("/etc/openclash/history/"..luci.openclash.basename(e[t].name)) - local a=fs.unlink("/etc/openclash/config/"..luci.openclash.basename(e[t].name)) -if a then table.remove(e,t)end -return a + fs.unlink("/etc/openclash/backup/"..fs.basename(e[t].name)) + fs.unlink("/etc/openclash/history/"..fs.basename(e[t].name)) + local a=fs.unlink("/etc/openclash/config/"..fs.basename(e[t].name)) + default_config_set(fs.basename(e[t].name)) + if a then table.remove(e,t)end + HTTP.redirect(DISP.build_url("admin", "services", "openclash","config")) end p = SimpleForm("provider_file_manage",translate("Provider File Manage")) @@ -301,7 +325,7 @@ local tab = { s = m:section(Table, tab) local conf = string.sub(luci.sys.exec("uci get openclash.config.config_path 2>/dev/null"), 1, -2) -local dconf = "/etc/openclash/default.yaml" +local dconf = "/usr/share/openclash/res/default.yaml" local conf_name = fs.basename(conf) if not conf_name or conf == "" then conf_name = "config.yaml" end diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/game-rules-manage.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/game-rules-manage.lua similarity index 89% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/game-rules-manage.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/game-rules-manage.lua index 54bb681fcd..061aea51c1 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/game-rules-manage.lua +++ b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/game-rules-manage.lua @@ -35,7 +35,7 @@ o.write = function() end if not NXFS.access("/tmp/rules_name") then - SYS.call("awk -F ',' '{print $1}' /etc/openclash/game_rules.list > /tmp/rules_name 2>/dev/null") + SYS.call("awk -F ',' '{print $1}' /usr/share/openclash/res/game_rules.list > /tmp/rules_name 2>/dev/null") end file = io.open("/tmp/rules_name", "r"); @@ -49,9 +49,9 @@ for t,o in ipairs(e) do e[t]={} e[t].num=string.format(t) e[t].name=o -e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /etc/openclash/game_rules.list |awk -F ',' '{print $3}' 2>/dev/null",e[t].name)),1,-2) +e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $3}' 2>/dev/null",e[t].name)),1,-2) if e[t].filename == "" then -e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /etc/openclash/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null",e[t].name)),1,-2) +e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null",e[t].name)),1,-2) end RULE_FILE="/etc/openclash/game_rules/".. e[t].filename if fs.mtime(RULE_FILE) then diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/groups-config.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/groups-config.lua similarity index 89% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/groups-config.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/groups-config.lua index a7f592382c..0cbcff00b6 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/groups-config.lua +++ b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/groups-config.lua @@ -95,6 +95,15 @@ o:depends("type", "select") o:depends("type", "relay") o.rmempty = true +o = s:option(DynamicList, "other_group_dr", translate("Other Group")) +o.description = font_red..bold_on..translate("The Added Proxy Groups Must Exist Except 'DIRECT' & 'REJECT'")..bold_off..font_off +o:value("DIRECT") +o:value("REJECT") +o:depends("type", "url-test") +o:depends("type", "fallback") +o:depends("type", "load-balance") +o.rmempty = true + local t = { {Commit, Back} } @@ -117,4 +126,4 @@ o.write = function() luci.http.redirect(m.redirect) end -return m +return m \ No newline at end of file diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/log.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/log.lua similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/log.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/log.lua diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/proxy-provider-config.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/proxy-provider-config.lua similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/proxy-provider-config.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/proxy-provider-config.lua diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/proxy-provider-file-manage.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/proxy-provider-file-manage.lua similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/proxy-provider-file-manage.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/proxy-provider-file-manage.lua diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-config.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-config.lua similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-config.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-config.lua diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-file-manage.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-file-manage.lua similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-file-manage.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-file-manage.lua diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-manage.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-manage.lua similarity index 83% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-manage.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-manage.lua index 5305392069..3137bdb989 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-manage.lua +++ b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-manage.lua @@ -35,7 +35,7 @@ o.write = function() end if not NXFS.access("/tmp/rule_providers_name") then - SYS.call("awk -v d=',' -F ',' '{print $4d$5}' /etc/openclash/rule_providers.list > /tmp/rule_providers_name 2>/dev/null") + SYS.call("awk -v d=',' -F ',' '{print $4d$5}' /usr/share/openclash/res/rule_providers.list > /tmp/rule_providers_name 2>/dev/null") end file = io.open("/tmp/rule_providers_name", "r"); @@ -58,14 +58,14 @@ end for t,o in ipairs(e) do e[t]={} e[t].num=string.format(t) -e[t].name=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",o)),1,-2) -e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $6}' 2>/dev/null",o)),1,-2) +e[t].name=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",o)),1,-2) +e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $6}' 2>/dev/null",o)),1,-2) if e[t].lfilename == "" then -e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $5}' 2>/dev/null",o)),1,-2) +e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $5}' 2>/dev/null",o)),1,-2) end e[t].filename=o -e[t].author=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $2}' 2>/dev/null",o)),1,-2) -e[t].rule_type=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $3}' 2>/dev/null",o)),1,-2) +e[t].author=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $2}' 2>/dev/null",o)),1,-2) +e[t].rule_type=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $3}' 2>/dev/null",o)),1,-2) RULE_FILE="/etc/openclash/rule_provider/".. e[t].lfilename if fs.mtime(RULE_FILE) then e[t].size=i(fs.stat(RULE_FILE).size) diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-settings.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-settings.lua similarity index 96% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-settings.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-settings.lua index 5b0f9ee96e..7d5937777f 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/rule-providers-settings.lua +++ b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-settings.lua @@ -87,7 +87,7 @@ for t,f in ipairs(fs.glob("/etc/openclash/game_rules/*"))do e[t]={} e[t].filename=fs.basename(f) if IsRuleFile(e[t].filename) then - e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /etc/openclash/game_rules.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "") + e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "") if e[t].name ~= "" and e[t].name ~= nil then o:value(e[t].name) end @@ -149,7 +149,7 @@ for t,f in ipairs(fs.glob("/etc/openclash/rule_provider/*"))do e[t]={} e[t].filename=fs.basename(f) if IsYamlFile(e[t].filename) or IsYmlFile(e[t].filename) then - e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /etc/openclash/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "") + e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "") if e[t].name ~= "" and e[t].name ~= nil then o:value(e[t].name) end diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/servers-config.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/servers-config.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/servers.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/servers.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/servers.lua diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/settings.lua b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua similarity index 95% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/settings.lua rename to package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua index 7bb1eeb54b..956324b1eb 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/settings.lua +++ b/package/ctcgfw/luci-app-openclash/luasrc/model/cbi/openclash/settings.lua @@ -194,7 +194,7 @@ o.inputstyle = "reload" o.write = function() m.uci:set("openclash", "config", "enable", 1) m.uci:commit("openclash") - SYS.call("/usr/share/openclash/openclash_fake_filter.sh >/dev/null 2>&1 && /etc/init.d/openclash restart >/dev/null 2>&1 &") + SYS.call("rm -rf /etc/openclash/fake_filter.list >/dev/null 2>&1 && /etc/init.d/openclash restart >/dev/null 2>&1 &") HTTP.redirect(DISP.build_url("admin", "services", "openclash")) end @@ -248,22 +248,31 @@ o:value("0", translate("Black List Mode")) o:value("1", translate("White List Mode")) o.default=0 -o = s:taboption("lan_ac", DynamicList, "lan_ac_black_ips", translate("LAN Bypassed Host List")) -o:depends("lan_ac_mode", "0") -o.datatype = "ipaddr" -luci.ip.neighbors({ family = 4 }, function(entry) - if entry.reachable then - o:value(entry.dest:string()) - end -end) +ip_b = s:taboption("lan_ac", DynamicList, "lan_ac_black_ips", translate("LAN Bypassed Host List")) +ip_b:depends("lan_ac_mode", "0") +ip_b.datatype = "ipaddr" -o = s:taboption("lan_ac", DynamicList, "lan_ac_white_ips", translate("LAN Proxied Host List")) -o:depends("lan_ac_mode", "1") -o.datatype = "ipaddr" -luci.ip.neighbors({ family = 4 }, function(entry) - if entry.reachable then - o:value(entry.dest:string()) - end +mac_b = s:taboption("lan_ac", DynamicList, "lan_ac_black_macs", translate("LAN Bypassed Mac List")) +mac_b.datatype = "list(macaddr)" +mac_b.rmempty = true +mac_b:depends("lan_ac_mode", "0") + +ip_w = s:taboption("lan_ac", DynamicList, "lan_ac_white_ips", translate("LAN Proxied Host List")) +ip_w:depends("lan_ac_mode", "1") +ip_w.datatype = "ipaddr" + +mac_w = s:taboption("lan_ac", DynamicList, "lan_ac_white_macs", translate("LAN Proxied Mac List")) +mac_w.datatype = "list(macaddr)" +mac_w.rmempty = true +mac_w:depends("lan_ac_mode", "1") + +luci.ip.neighbors({ family = 4 }, function(n) + if n.mac and n.dest then + ip_b:value(n.dest:string()) + ip_w:value(n.dest:string()) + mac_b:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() }) + mac_w:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() }) + end end) end diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/openclash.lua b/package/ctcgfw/luci-app-openclash/luasrc/openclash.lua similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/openclash.lua rename to package/ctcgfw/luci-app-openclash/luasrc/openclash.lua diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/cfg_check.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/cfg_check.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/cfg_check.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/cfg_check.htm diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/developer.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/developer.htm similarity index 80% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/developer.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/developer.htm index 26eb321871..a56778b5b3 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/developer.htm +++ b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/developer.htm @@ -1,17 +1,18 @@
- - - - - - - - - - - + + + + + + + + + + + +
<%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%>
@@ -28,6 +29,7 @@ var FQrabbit = document.getElementById('_FQrabbit'); var Fndroid = document.getElementById('_Fndroid'); var Alecthw = document.getElementById('_Alecthw'); + var Tindy_X = document.getElementById('_Tindy_X'); Dreamacro.innerHTML = 'Dreamacro'; vernesong.innerHTML = 'vernesong'; frainzy1477.innerHTML = 'frainzy1477'; @@ -39,7 +41,8 @@ FQrabbit.innerHTML = 'FQrabbit'; Fndroid.innerHTML = 'Fndroid'; Alecthw.innerHTML = 'Alecthw'; - + Tindy_X.innerHTML = 'Tindy X'; + function Dreamacro_rediret() { url1='https://github.com/Dreamacro'; @@ -96,6 +99,12 @@ window.open(url13); }; + function Tindy_X_rediret() + { + url14='https://github.com/tindy2013'; + window.open(url14); + }; + function imgerrorfun(imgobj,imgSrc){ setTimeout(function(){ imgobj.src=imgSrc; diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/download_rule.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/download_rule.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/download_rule.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/download_rule.htm diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/dvalue.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/dvalue.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/dvalue.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/dvalue.htm diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/myip.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/myip.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/myip.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/myip.htm diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/other_button.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/other_button.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/other_button.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/other_button.htm diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/ping.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/ping.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/ping.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/ping.htm diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/server_list.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/server_list.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/server_list.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/server_list.htm diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/status.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/status.htm similarity index 68% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/status.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/status.htm index 7870fea865..920e9a182b 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/status.htm +++ b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/status.htm @@ -1,3 +1,44 @@ +
@@ -31,10 +72,31 @@ - + + + + + + + + + + + +
OpenClash 守护程序 <%:Collecting data...%> 控制面板登录端口 <%:Collecting data...%>
OpenClash 运行模式 <%:Collecting data...%> 控制面板登录密钥 <%:Collecting data...%>
Yacd 控制面板 <%:Collecting data...%> Dashboard 控制面板 <%:Collecting data...%>

Show More

常用操作快捷按钮

<%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%>
<%:Collecting data...%><%:Collecting data...%><%:Collecting data...%><%:Collecting data...%>
+
+
+ + + + +
+

+ 组件的状态显示,运行前请确保各项目显示正常,需要更新请到全局设置页面操作 +

+
策略组节点选择 备份日期 <%:Collecting data...%> lhie1 规则更新日期 <%:Collecting data...%>
ConnersHua 规则更新日期 <%:Collecting data...%> ConnersHua 回国规则更新日期 <%:Collecting data...%>
大陆IP白名单 更新日期 <%:Collecting data...%> GEOIP(By MaxMind)数据库日期 <%:Collecting data...%>
- + diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/switch_mode.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/switch_mode.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/switch_mode.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/switch_mode.htm diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/update.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/update.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/update.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/update.htm diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/upload.htm b/package/ctcgfw/luci-app-openclash/luasrc/view/openclash/upload.htm similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/upload.htm rename to package/ctcgfw/luci-app-openclash/luasrc/view/openclash/upload.htm diff --git a/package/ctcgfw/luci-app-openclash/i18n/zh-cn/openclash.zh-cn.po b/package/ctcgfw/luci-app-openclash/po/zh-cn/openclash.zh-cn.po similarity index 95% rename from package/ctcgfw/luci-app-openclash/i18n/zh-cn/openclash.zh-cn.po rename to package/ctcgfw/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index 5f3dba02ad..36ebf10b19 100644 --- a/package/ctcgfw/luci-app-openclash/i18n/zh-cn/openclash.zh-cn.po +++ b/package/ctcgfw/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -41,6 +41,9 @@ msgstr "DNS设置" msgid "Config Update" msgstr "配置文件订阅" +msgid "Config Subscribe Edit" +msgstr "编辑配置文件订阅信息" + msgid "Rules Update" msgstr "第三方规则订阅" @@ -840,12 +843,6 @@ msgstr "(用于区分,请勿重名)" msgid "Subscribe Address" msgstr "订阅地址" -msgid "Subscribe Type" -msgstr "订阅地址类型" - -msgid "(Power By fndroid)" -msgstr "(API提供:Fndroid)" - msgid "(Not Null)" msgstr "(空值无效)" @@ -982,14 +979,20 @@ msgid "White List Mode" msgstr "白名单模式" msgid "LAN Bypassed Host List" -msgstr "不走代理的局域网LAN IP" +msgstr "不走代理的局域网设备 IP" msgid "LAN Proxied Host List" -msgstr "走代理的局域网LAN IP" +msgstr "走代理的局域网设备 IP" msgid "WAN Bypassed Host List" msgstr "不走代理的WAN IP" +msgid "LAN Bypassed Mac List" +msgstr "不走代理的局域网设备 Mac" + +msgid "LAN Proxied Mac List" +msgstr "走代理的局域网设备 Mac" + msgid "In The Fake-IP Mode, Only Pure IP Requests Are Supported" msgstr "在Fake-IP模式下,只支持过滤纯IP类型的请求" @@ -1006,4 +1009,34 @@ msgid "Config File Edit" msgstr "配置文件编辑" msgid "Delete All File" -msgstr "删除所有文件" \ No newline at end of file +msgstr "删除所有文件" + +msgid "Template Name" +msgstr "订阅转换模板" + +msgid "Subscribe Convert Online" +msgstr "在线订阅转换" + +msgid "Custom Template URL" +msgstr "自定义模板地址" + +msgid "Custom Template" +msgstr "自定义模板" + +msgid "Emoji" +msgstr "添加Emoji" + +msgid "skip-cert-verify" +msgstr "跳过证书验证" + +msgid "Sort" +msgstr "排序" + +msgid "Append Node Type" +msgstr "插入节点类型" + +msgid "Convert Subscribe Online With Template, Mix Proxies and Keep Settings options Will Not Effect" +msgstr "根据模板在线转换配置文件,混合节点和保留配置功能将不可用" + +msgid "Convert Subscribe function of Online is Supported By subconverter Written By tindy X" +msgstr "在线订阅转换功能由tindy X通过subconverter提供支持" \ No newline at end of file diff --git a/package/ctcgfw/luci-app-openclash/files/etc/config/openclash b/package/ctcgfw/luci-app-openclash/root/etc/config/openclash similarity index 92% rename from package/ctcgfw/luci-app-openclash/files/etc/config/openclash rename to package/ctcgfw/luci-app-openclash/root/etc/config/openclash index 5d0856b8b4..0e2c7f6aab 100644 --- a/package/ctcgfw/luci-app-openclash/files/etc/config/openclash +++ b/package/ctcgfw/luci-app-openclash/root/etc/config/openclash @@ -27,6 +27,7 @@ config openclash 'config' option lan_ac_mode '0' option operation_mode 'redir-host' option enable_rule_proxy '0' + option redirect_dns '0' config dns_servers option group 'nameserver' @@ -52,6 +53,12 @@ config dns_servers option ip '223.5.5.5' option enabled '1' +config dns_servers + option enabled '1' + option group 'nameserver' + option ip 'doh.rixcloud.dev/dns-query' + option type 'https' + config dns_servers option type 'https' option group 'fallback' diff --git a/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash b/package/ctcgfw/luci-app-openclash/root/etc/init.d/openclash old mode 100755 new mode 100644 similarity index 68% rename from package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash rename to package/ctcgfw/luci-app-openclash/root/etc/init.d/openclash index e9151823a4..be239cbafe --- a/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash +++ b/package/ctcgfw/luci-app-openclash/root/etc/init.d/openclash @@ -1,6 +1,6 @@ #!/bin/sh /etc/rc.common -. /usr/share/openclash/openclash_ps.sh # Copyright (c) 2019 vernesong +. /usr/share/openclash/openclash_ps.sh START=99 STOP=15 @@ -61,16 +61,16 @@ del_cron() } change_dns() { - if [ "$1" -eq "1" ]; then + if [ "$1" -eq 1 ]; then uci del dhcp.@dnsmasq[-1].server >/dev/null 2>&1 uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" uci delete dhcp.@dnsmasq[0].resolvfile 2>/dev/null uci set dhcp.@dnsmasq[0].noresolv=1 2>/dev/null uci set openclash.config.redirect_dns=1 else - uci delete openclash.config.redirect_dns 2>/dev/null + uci set openclash.config.redirect_dns=0 2>/dev/null fi - if [ "$2" -eq "1" ]; then + if [ "$2" -eq 1 ]; then uci set dhcp.@dnsmasq[0].cachesize=0 2>/dev/null fi @@ -81,16 +81,13 @@ change_dns() { } revert_dns() { - [ "$1" -eq "0" ] && { - if [ "$(uci get openclash.config.dns_revert 2>/dev/null)" != "1" ]; then - uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$3" >/dev/null 2>&1 - uci set openclash.config.dns_revert=1 2>/dev/null - fi + + [ "$1" -eq 1 ] && { + uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$3" >/dev/null 2>&1 } - [ "$1" -eq "1" ] && { - uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$3" >/dev/null 2>&1 - uci set openclash.config.dns_revert=0 2>/dev/null + [ "$1" -eq 1 ] && [ "$4" -eq 0 ] && { + uci set openclash.config.redirect_dns=0 2>/dev/nulls } [ "$(uci get dhcp.@dnsmasq[0].cachesize 2>/dev/null)" = "0" ] && { @@ -112,17 +109,28 @@ revert_dns() { kill_clash() { - clash_pids=$(pidof clash|sed 's/$//g') + clash_pids=$(pidof clash |sed 's/$//g') for clash_pid in $clash_pids; do kill -9 "$clash_pid" 2>/dev/null - done + done >/dev/null 2>&1 sleep 1 } +start_fail() +{ + kill_clash + stop + exit 0 +} + yml_merge() { #合并文件 -sed -i "s/^ \{0,\}Proxy:/proxies:/g" "$PROXY_FILE" 2>/dev/null +if [ -z "$(grep "^Proxy:#d" "$PROXY_FILE")" ]; then + sed -i "s/^Proxy:/proxies:/g" "$PROXY_FILE" 2>/dev/null +else + sed -i "s/^Proxy:#d/proxies:/g" "$PROXY_FILE" 2>/dev/null +fi cat "$CHANGE_FILE" "$DNS_FILE" "$PROXY_PROVIDER_FILE" "$PROXY_FILE" "$GROUP_FILE" "$RULE_PROVIDER_FILE" "$SCRIPT_FILE" "$RULE_FILE" > "$CONFIG_FILE" 2>/dev/null } @@ -143,10 +151,10 @@ yml_check() #检查关键字避免后续操作出错 /usr/share/openclash/yml_field_name_ch.sh "$3" 2>/dev/null - - #创建启动备份 + + #创建启动备份 cp "$3" "$5" - + #创建原始备份 if [ ! -f "$4" ]; then cp "$3" "$4" @@ -162,85 +170,92 @@ yml_check() fi 2>/dev/null #取出proxy部分 - proxy_len=$(sed -n '/^Proxy:/=' "$3" 2>/dev/null) - if [ -n "$proxy_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$proxy_len" "$PROXY_FILE" "$3" - fi 2>/dev/null + proxy_lens=$(sed -n '/^Proxy:/=' "$3" 2>/dev/null) + proxy_len_num=1 + for proxy_len in $proxy_lens; do + if [ -n "$proxy_len" ]; then + /usr/share/openclash/yml_field_cut.sh "$proxy_len" "/tmp/yaml_proxy_$proxy_len_num.yaml" "$3" + fi 2>/dev/null + proxy_len_num=$(expr "$proxy_len_num" + 1) + done 2>/dev/null + for i in $(seq "$proxy_len_num"); do + cat "/tmp/yaml_proxy_$i.yaml" >> $PROXY_FILE + done 2>/dev/null #取出proxy-providers部分 provider_len=$(sed -n '/^proxy-providers:/=' "$3" 2>/dev/null) if [ -n "$provider_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$provider_len" "$PROXY_PROVIDER_FILE" "$3" + /usr/share/openclash/yml_field_cut.sh "$provider_len" "$PROXY_PROVIDER_FILE" "$3" fi 2>/dev/null #取出group部分 group_len=$(sed -n '/^proxy-groups:/=' "$3" 2>/dev/null) if [ -n "$group_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$group_len" "$GROUP_FILE" "$3" + /usr/share/openclash/yml_field_cut.sh "$group_len" "$GROUP_FILE" "$3" fi 2>/dev/null #取出rule_provider部分 rule_provider_len=$(sed -n '/^rule-providers:/=' "$3" 2>/dev/null) if [ -n "$rule_provider_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$rule_provider_len" "$RULE_PROVIDER_FILE" "$3" + /usr/share/openclash/yml_field_cut.sh "$rule_provider_len" "$RULE_PROVIDER_FILE" "$3" fi 2>/dev/null #取出script部分 script_len=$(sed -n '/^script:/=' "$3" 2>/dev/null) if [ -n "$script_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$script_len" "$SCRIPT_FILE" "$3" + /usr/share/openclash/yml_field_cut.sh "$script_len" "$SCRIPT_FILE" "$3" fi 2>/dev/null #取出rule部分 rule_len=$(sed -n '/^rules:/=' "$3" 2>/dev/null) if [ -n "$rule_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$rule_len" "$RULE_FILE" "$3" + /usr/share/openclash/yml_field_cut.sh "$rule_len" "$RULE_FILE" "$3" fi 2>/dev/null #取出cfw部分 cfw_bypass_len=$(sed -n '/^ \{0,\}cfw-bypass:/=' "$DNS_FILE" 2>/dev/null) if [ -n "$cfw_bypass_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$cfw_bypass_len" "$CFW_LATE_FILE" "$DNS_FILE" "dns" + /usr/share/openclash/yml_field_cut.sh "$cfw_bypass_len" "$CFW_LATE_FILE" "$DNS_FILE" "dns" fi 2>/dev/null #取出cfw部分 cfw_latency_timeout_len=$(sed -n '/^ \{0,\}cfw-latency-timeout:/=' "$DNS_FILE" 2>/dev/null) if [ -n "$cfw_latency_timeout_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$cfw_latency_timeout_len" "$CFW_LATE_FILE" "$DNS_FILE" "dns" + /usr/share/openclash/yml_field_cut.sh "$cfw_latency_timeout_len" "$CFW_LATE_FILE" "$DNS_FILE" "dns" fi 2>/dev/null #取出fallback-filter部分 fallback_filter_len=$(sed -n '/^ \{0,\}fallback-filter:/=' "$DNS_FILE" 2>/dev/null) if [ -n "$fallback_filter_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$fallback_filter_len" "$FALLBACK_FILTER_FILE" "$DNS_FILE" "dns" + /usr/share/openclash/yml_field_cut.sh "$fallback_filter_len" "$FALLBACK_FILTER_FILE" "$DNS_FILE" "dns" fi 2>/dev/null #备份rule_provider部分 rule_provider_bak_len=$(sed -n '/^rule-providers:/=' "$4" 2>/dev/null) if [ -n "$rule_provider_bak_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$rule_provider_bak_len" "$RULE_PROVIDER_BAK_FILE" "$4" + /usr/share/openclash/yml_field_cut.sh "$rule_provider_bak_len" "$RULE_PROVIDER_BAK_FILE" "$4" fi 2>/dev/null #备份script部分 script_bak_len=$(sed -n '/^script:/=' "$4" 2>/dev/null) if [ -n "$script_bak_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$script_bak_len" "$SCRIPT_BAK_FILE" "$4" + /usr/share/openclash/yml_field_cut.sh "$script_bak_len" "$SCRIPT_BAK_FILE" "$4" fi 2>/dev/null #备份rule部分 rule_bak_len=$(sed -n '/^rules:/=' "$4" 2>/dev/null) if [ -n "$rule_bak_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$rule_bak_len" "$RULE_BAK_FILE" "$4" + /usr/share/openclash/yml_field_cut.sh "$rule_bak_len" "$RULE_BAK_FILE" "$4" fi 2>/dev/null #自定义DNS还原 if [ "$(grep -c '##Custom DNS##' "$CHANGE_FILE")" -gt 0 ] || [ "$(grep -c '##Custom DNS##' "$DNS_FILE")" -gt 0 ]; then if [ "$2" = 0 ] && [ -f "$4" ]; then - #取出dns备份 - nameserver_len=$(sed -n '/^ \{0,\}nameserver:/=' "$4" 2>/dev/null) - if [ -n "$nameserver_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$nameserver_len" "/tmp/backdns.config" "$4" "dns" - fi 2>/dev/null + #取出dns备份 + nameserver_len=$(sed -n '/^ \{0,\}nameserver:/=' "$4" 2>/dev/null) + if [ -n "$nameserver_len" ]; then + /usr/share/openclash/yml_field_cut.sh "$nameserver_len" "/tmp/backdns.config" "$4" "dns" + fi 2>/dev/null sed -i '/^ \{0,\}nameserver:/,$d' "$DNS_FILE" 2>/dev/null sed -i '/##Custom DNS##/d' "$CHANGE_FILE" 2>/dev/null cat "/tmp/backdns.config" >> "$DNS_FILE" @@ -248,21 +263,6 @@ yml_check() fi fi 2>/dev/null - yml_dns_check - - if [ -n "$(grep "^ \{1,\}port:" "$CHANGE_FILE")" ] || [ -n "$(grep "^ \{1,\}mode:" "$CHANGE_FILE")" ] || [ -n "$(grep "^ \{1,\}log-level:" "$CHANGE_FILE")" ]; then - cp "$CHANGE_FILE" /tmp/config.check 2>/dev/null - sed -i '/^dns:/,$d' /tmp/config.check 2>/dev/null - sed -i 's/^[ \t]*//' /tmp/config.check 2>/dev/null - sed -n '/^dns:/,$p' "$CHANGE_FILE" >> /tmp/config.check 2>/dev/null - mv /tmp/config.check "$CHANGE_FILE" 2>/dev/null - fi - - #添加标识 - sed -i '/OpenClash-General/d' "$DNS_FILE" 2>/dev/null - sed -i '/OpenClash-General/d' "$FALLBACK_FILTER_FILE" 2>/dev/null - echo '#===================== OpenClash-General-Settings =====================#' >> "$FALLBACK_FILTER_FILE" 2>/dev/null - } #检查DNS设置 @@ -274,8 +274,8 @@ yml_dns_check() fi if [ -z "$(grep '^ \{0,\}nameserver:' "$DNS_FILE")" ]; then - echo " nameserver:" > "$DNS_FILE" 2>/dev/null - cat >> "$DNS_FILE" <<-EOF + echo " nameserver:" > "$DNS_FILE" 2>/dev/null + cat >> "$DNS_FILE" <<-EOF - 114.114.114.114 - 119.29.29.29 fallback: @@ -304,9 +304,23 @@ EOF sed -i "/^dns:/a\ listen: 0.0.0.0:${dns_port}" "$CHANGE_FILE" 2>/dev/null fi fi 2>/dev/null - + + #保存DNS端口方便后续调用 uci set openclash.config.dns_port="$dns_port" && uci commit openclash + + #检查general部分的缩进 + if [ -n "$(grep "^ \{1,\}port:" "$CHANGE_FILE")" ] || [ -n "$(grep "^ \{1,\}mode:" "$CHANGE_FILE")" ] || [ -n "$(grep "^ \{1,\}log-level:" "$CHANGE_FILE")" ]; then + cp "$CHANGE_FILE" /tmp/config.check 2>/dev/null + sed -i '/^dns:/,$d' /tmp/config.check 2>/dev/null + sed -i 's/^[ \t]*//' /tmp/config.check 2>/dev/null + sed -n '/^dns:/,$p' "$CHANGE_FILE" >> /tmp/config.check 2>/dev/null + mv /tmp/config.check "$CHANGE_FILE" 2>/dev/null + fi + #添加标识 + sed -i '/OpenClash-General/d' "$DNS_FILE" 2>/dev/null + sed -i '/OpenClash-General/d' "$FALLBACK_FILTER_FILE" 2>/dev/null + echo '#===================== OpenClash-General-Settings =====================#' >> "$FALLBACK_FILTER_FILE" 2>/dev/null } #修改集路径 @@ -314,10 +328,10 @@ yml_provider_path() { provider_path_line=$(sed -n '/ \{0,\}path/=' "$1" 2>/dev/null) if [ -n "$provider_path_line" ]; then - for n in $provider_path_line; do - if [ -n "$(sed -n "${n}p" "$1" |grep "^ \{0,\}#")" ]; then - continue - fi + for n in $provider_path_line; do + if [ -n "$(sed -n "${n}p" "$1" |grep "^ \{0,\}#")" ]; then + continue + fi provider_path=$(sed -n "${n}p" "$1" |sed "s/\'//g" |sed 's/\"//g' |awk -F 'path:' '{print $2}' 2>/dev/null |awk -F '#' '{print $1}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null) if [ -z "$(echo "$provider_path" |grep "$2")" ]; then provider_name=$(echo "$provider_path" |awk -F '/' '{print $NF}') @@ -343,9 +357,9 @@ if [ -n "$provider_path_line" ]; then do provider_path_exist=1 for n in $provider_path_line; do - if [ -n "$(sed -n "${n}p" "$1" |grep "^ \{0,\}#")" ]; then - continue - fi + if [ -n "$(sed -n "${n}p" "$1" |grep "^ \{0,\}#")" ]; then + continue + fi provider_path=$(sed -n "${n}p" "$1" |sed "s/\'//g" |sed 's/\"//g' |awk -F 'path:' '{print $2}' 2>/dev/null |awk -F '#' '{print $1}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null) if [ "$(echo "${provider_path:0:1}")" = "." ]; then provider_path_check="/etc/openclash/$(echo ${provider_path:2})" @@ -387,9 +401,7 @@ if [ -n "$provider_path_line" ]; then fi if [ -z "$(pidof clash)" ] && [ "$provider_path_exist" = 0 ]; then - kill_clash - stop - if [ "$2" = "proxy_provider" ]; then + if [ "$2" = "proxy_provider" ]; then echo "错误: 代理集文件下载失败,请到日志页面查看详细错误信息!" >$START_LOG echo "${LOGTIME} Faild to Download Proxy-Provider File, Please Check The Error Info And Try Again" >> $LOG_FILE else @@ -397,8 +409,7 @@ if [ -z "$(pidof clash)" ] && [ "$provider_path_exist" = 0 ]; then echo "${LOGTIME} Faild to Download Rule-Provider File, Please Check The Error Info And Try Again" >> $LOG_FILE fi sleep 10 - echo "" >$START_LOG - exit 0 + start_fail elif [ "$provider_path_check_num" -gt 5 ]; then echo "警告: 代理集文件检查超时,如启动失败请到日志页面查看详细信息!" >$START_LOG sleep 3 @@ -421,7 +432,7 @@ yml_dns_get() if [ "$enabled" = "0" ]; then return fi - + if [ -z "$ip" ]; then return fi @@ -561,10 +572,10 @@ get_rule_file() return fi - GAME_RULE_FILE_NAME=$(grep "^$1," /etc/openclash/game_rules.list |awk -F ',' '{print $3}' 2>/dev/null) + GAME_RULE_FILE_NAME=$(grep "^$1," /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $3}' 2>/dev/null) if [ -z "$GAME_RULE_FILE_NAME" ]; then - GAME_RULE_FILE_NAME=$(grep "^$1," /etc/openclash/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null) + GAME_RULE_FILE_NAME=$(grep "^$1," /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null) fi GAME_RULE_PATH="/etc/openclash/game_rules/$GAME_RULE_FILE_NAME" @@ -598,8 +609,8 @@ yml_game_rule_get() yml_rule_group_get() { - local section="$1" - local enabled group config + local section="$1" + local enabled group config config_get_bool "enabled" "$section" "enabled" "1" config_get "group" "$section" "group" "" config_get "config" "$section" "config" "" @@ -631,7 +642,7 @@ fi sed -i '/OpenClash-Game-Rules/d' "$RULE_FILE" 2>/dev/null sed -i '/OpenClash-Game-Rules-End/d' "$RULE_FILE" 2>/dev/null [ "$set_rule_file" = 1 ] && { - if [ -n "$(grep "##Custom Rules 2##" "$RULE_FILE")" ]; then + if [ -n "$(grep "##Custom Rules 2##" "$RULE_FILE")" ]; then sed -i "/##Custom Rules 2##/i\#===================== OpenClash-Game-Rules =====================#" "$RULE_FILE" 2>/dev/null elif [ -n "$(grep "^ \{0,\}- GEOIP" "$RULE_FILE")" ]; then sed -i '1,/^ \{0,\}- GEOIP,/{/^ \{0,\}- GEOIP,/s/^ \{0,\}- GEOIP,/#===================== OpenClash-Game-Rules =====================#\n&/}' "$RULE_FILE" 2>/dev/null @@ -669,26 +680,26 @@ fi yml_rule_set_add() { - if [ -z "$(grep "rules:" "$RULE_FILE" 2>/dev/null)" ]; then - echo "rules:" > "$RULE_FILE" - fi - if [ "$3" -eq 1 ]; then - if [ -z "$(grep "OpenClash-Rule-Set-Extended-End" "$RULE_FILE" 2>/dev/null)" ]; then - if [ -n "$(grep "##Custom Rules 2##" "$RULE_FILE")" ]; then - sed -i "/##Custom Rules 2##/i\#===================== OpenClash-Rule-Set-Extended-End =====================#" "$RULE_FILE" 2>/dev/null - sed -i "/OpenClash-Rule-Set-Extended-End/i\#===================== OpenClash-Rule-Set-Extended =====================#" "$RULE_FILE" 2>/dev/null - elif [ -n "$(grep "^ \{0,\}- GEOIP" "$RULE_FILE")" ]; then - sed -i '1,/^ \{0,\}- GEOIP,/{/^ \{0,\}- GEOIP,/s/^ \{0,\}- GEOIP,/#===================== OpenClash-Rule-Set-Extended-End =====================#\n&/}' "$RULE_FILE" 2>/dev/null - sed -i "/OpenClash-Rule-Set-Extended-End/i\#===================== OpenClash-Rule-Set-Extended =====================#" "$RULE_FILE" 2>/dev/null - elif [ -n "$(grep "^ \{0,\}- MATCH," "$RULE_FILE")" ]; then - sed -i '1,/^ \{0,\}- MATCH,/{/^ \{0,\}- MATCH,/s/^ \{0,\}- MATCH,/#===================== OpenClash-Rule-Set-Extended-End =====================#\n&/}' "$RULE_FILE" 2>/dev/null - sed -i "/OpenClash-Rule-Set-Extended-End/i\#===================== OpenClash-Rule-Set-Extended =====================#" "$RULE_FILE" 2>/dev/null - else - echo "#===================== OpenClash-Rule-Set-Extended =====================#" >> "$RULE_FILE" 2>/dev/null - echo "#===================== OpenClash-Rule-Set-Extended-End =====================#" >> "$RULE_FILE" 2>/dev/null - fi - fi - sed -i "/OpenClash-Rule-Set-Extended-End/i\- RULE-SET,${1},${2}" "$RULE_FILE" 2>/dev/null + if [ -z "$(grep "rules:" "$RULE_FILE" 2>/dev/null)" ]; then + echo "rules:" > "$RULE_FILE" + fi + if [ "$3" -eq 1 ]; then + if [ -z "$(grep "OpenClash-Rule-Set-Extended-End" "$RULE_FILE" 2>/dev/null)" ]; then + if [ -n "$(grep "##Custom Rules 2##" "$RULE_FILE")" ]; then + sed -i "/##Custom Rules 2##/i\#===================== OpenClash-Rule-Set-Extended-End =====================#" "$RULE_FILE" 2>/dev/null + sed -i "/OpenClash-Rule-Set-Extended-End/i\#===================== OpenClash-Rule-Set-Extended =====================#" "$RULE_FILE" 2>/dev/null + elif [ -n "$(grep "^ \{0,\}- GEOIP" "$RULE_FILE")" ]; then + sed -i '1,/^ \{0,\}- GEOIP,/{/^ \{0,\}- GEOIP,/s/^ \{0,\}- GEOIP,/#===================== OpenClash-Rule-Set-Extended-End =====================#\n&/}' "$RULE_FILE" 2>/dev/null + sed -i "/OpenClash-Rule-Set-Extended-End/i\#===================== OpenClash-Rule-Set-Extended =====================#" "$RULE_FILE" 2>/dev/null + elif [ -n "$(grep "^ \{0,\}- MATCH," "$RULE_FILE")" ]; then + sed -i '1,/^ \{0,\}- MATCH,/{/^ \{0,\}- MATCH,/s/^ \{0,\}- MATCH,/#===================== OpenClash-Rule-Set-Extended-End =====================#\n&/}' "$RULE_FILE" 2>/dev/null + sed -i "/OpenClash-Rule-Set-Extended-End/i\#===================== OpenClash-Rule-Set-Extended =====================#" "$RULE_FILE" 2>/dev/null + else + echo "#===================== OpenClash-Rule-Set-Extended =====================#" >> "$RULE_FILE" 2>/dev/null + echo "#===================== OpenClash-Rule-Set-Extended-End =====================#" >> "$RULE_FILE" 2>/dev/null + fi + fi + sed -i "/OpenClash-Rule-Set-Extended-End/i\- RULE-SET,${1},${2}" "$RULE_FILE" 2>/dev/null elif [ "$3" -eq 0 ]; then if [ -z "$(grep "OpenClash-Rule-Set-Priority-End" "$RULE_FILE" 2>/dev/null)" ]; then if [ -n "$(grep "##Custom Rules##" "$RULE_FILE" 2>/dev/null)" ]; then @@ -705,30 +716,30 @@ yml_rule_set_add() yml_gen_rule_provider_file() { - if [ -z "$1" ]; then - return - fi + if [ -z "$1" ]; then + return + fi - RULE_PROVIDER_FILE_NAME=$(grep "^$1," /etc/openclash/rule_providers.list |awk -F ',' '{print $6}' 2>/dev/null) - if [ -z "$RULE_PROVIDER_FILE_NAME" ]; then - RULE_PROVIDER_FILE_NAME=$(grep "^$1," /etc/openclash/rule_providers.list |awk -F ',' '{print $5}' 2>/dev/null) - fi - RULE_PROVIDER_FILE_BEHAVIOR=$(grep ",$RULE_PROVIDER_FILE_NAME$" /etc/openclash/rule_providers.list |awk -F ',' '{print $3}' 2>/dev/null) - RULE_PROVIDER_FILE_PATH="/etc/openclash/rule_provider/$RULE_PROVIDER_FILE_NAME" - RULE_PROVIDER_FILE_URL="https://raw.githubusercontent.com/$(grep ",$RULE_PROVIDER_FILE_NAME$" /etc/openclash/rule_providers.list |awk -F ',' '{print $4$5}' 2>/dev/null)" + RULE_PROVIDER_FILE_NAME=$(grep "^$1," /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $6}' 2>/dev/null) + if [ -z "$RULE_PROVIDER_FILE_NAME" ]; then + RULE_PROVIDER_FILE_NAME=$(grep "^$1," /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $5}' 2>/dev/null) + fi + RULE_PROVIDER_FILE_BEHAVIOR=$(grep ",$RULE_PROVIDER_FILE_NAME$" /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $3}' 2>/dev/null) + RULE_PROVIDER_FILE_PATH="/etc/openclash/rule_provider/$RULE_PROVIDER_FILE_NAME" + RULE_PROVIDER_FILE_URL_PATH="$(grep ",$RULE_PROVIDER_FILE_NAME$" /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $4$5}' 2>/dev/null)" + RULE_PROVIDER_FILE_URL="https://cdn.jsdelivr.net/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}')"" + if [ -n "$(grep "$RULE_PROVIDER_FILE_URL" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then + return + fi + + if [ -z "$(grep "rule-providers:" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then + echo "rule-providers:" > "$RULE_PROVIDER_FILE" + fi + + if [ -z "$(grep "OpenClash-Rule-Providers-Set" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then + echo "#===================== OpenClash-Rule-Providers-Set =====================#" >> "$RULE_PROVIDER_FILE" + fi - if [ -n "$(grep "$RULE_PROVIDER_FILE_URL" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then - return - fi - - if [ -z "$(grep "rule-providers:" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then - echo "rule-providers:" > "$RULE_PROVIDER_FILE" - fi - - if [ -z "$(grep "OpenClash-Rule-Providers-Set" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then - echo "#===================== OpenClash-Rule-Providers-Set =====================#" >> "$RULE_PROVIDER_FILE" - fi - cat >> "$RULE_PROVIDER_FILE" <<-EOF $1: type: http @@ -736,39 +747,39 @@ cat >> "$RULE_PROVIDER_FILE" <<-EOF path: $RULE_PROVIDER_FILE_PATH url: $RULE_PROVIDER_FILE_URL EOF - if [ -z "$3" ]; then + if [ -z "$3" ]; then cat >> "$RULE_PROVIDER_FILE" <<-EOF - interval=86400 + interval=86400 EOF - else + else cat >> "$RULE_PROVIDER_FILE" <<-EOF interval: $3 EOF - fi - yml_rule_set_add "$1" "$2" "$4" + fi + yml_rule_set_add "$1" "$2" "$4" } yml_get_rule_provider() { - local section="$1" - local enabled group config interval position - config_get_bool "enabled" "$section" "enabled" "1" - config_get "group" "$section" "group" "" - config_get "config" "$section" "config" "" - config_get "interval" "$section" "interval" "" - config_get "position" "$section" "position" "" + local section="$1" + local enabled group config interval position + config_get_bool "enabled" "$section" "enabled" "1" + config_get "group" "$section" "group" "" + config_get "config" "$section" "config" "" + config_get "interval" "$section" "interval" "" + config_get "position" "$section" "position" "" - if [ "$enabled" = "0" ]; then - return - fi + if [ "$enabled" = "0" ]; then + return + fi - if [ -n "$config" ] && [ "$config" != "$CONFIG_NAME" ] && [ "$config" != "all" ]; then - return - fi + if [ -n "$config" ] && [ "$config" != "$CONFIG_NAME" ] && [ "$config" != "all" ]; then + return + fi - if [ -z "$group" ]; then - return - fi + if [ -z "$group" ]; then + return + fi config_list_foreach "$section" "rule_name" yml_gen_rule_provider_file "$group" "$interval" "$position" } @@ -776,60 +787,60 @@ yml_get_rule_provider() #处理自定义规则集 yml_set_custom_rule_provider() { - local section="$1" - local enabled name config type behavior path url interval group position - config_get_bool "enabled" "$section" "enabled" "1" - config_get "name" "$section" "name" "" - config_get "config" "$section" "config" "" - config_get "type" "$section" "type" "" - config_get "behavior" "$section" "behavior" "" - config_get "path" "$section" "path" "" - config_get "url" "$section" "url" "" - config_get "interval" "$section" "interval" "" - config_get "group" "$section" "group" "" - config_get "position" "$section" "position" "" + local section="$1" + local enabled name config type behavior path url interval group position + config_get_bool "enabled" "$section" "enabled" "1" + config_get "name" "$section" "name" "" + config_get "config" "$section" "config" "" + config_get "type" "$section" "type" "" + config_get "behavior" "$section" "behavior" "" + config_get "path" "$section" "path" "" + config_get "url" "$section" "url" "" + config_get "interval" "$section" "interval" "" + config_get "group" "$section" "group" "" + config_get "position" "$section" "position" "" - if [ "$enabled" = "0" ]; then - return - fi - - if [ -n "$(grep "$url" "$RULE_PROVIDER_FILE" 2>/dev/null)" ] && [ -n "$url" ]; then - return - fi - - if [ -n "$config" ] && [ "$config" != "$CONFIG_NAME" ] && [ "$config" != "all" ]; then - return - fi - - if [ -z "$name" ] || [ -z "$type" ] || [ -z "$behavior" ]; then - return - fi - - if [ "$type" = "http" ] && [ -z "$url" ]; then - return - fi - - if [ "$path" != "./rule_provider/$name.yaml" ] && [ "$type" = "http" ]; then - path="./rule_provider/$name.yaml" - elif [ -z "$path" ]; then + if [ "$enabled" = "0" ]; then return - fi + fi + + if [ -n "$(grep "$url" "$RULE_PROVIDER_FILE" 2>/dev/null)" ] && [ -n "$url" ]; then + return + fi + + if [ -n "$config" ] && [ "$config" != "$CONFIG_NAME" ] && [ "$config" != "all" ]; then + return + fi + + if [ -z "$name" ] || [ -z "$type" ] || [ -z "$behavior" ]; then + return + fi + + if [ "$type" = "http" ] && [ -z "$url" ]; then + return + fi + + if [ "$path" != "./rule_provider/$name.yaml" ] && [ "$type" = "http" ]; then + path="./rule_provider/$name.yaml" + elif [ -z "$path" ]; then + return + fi if [ -n "$(grep "$path" "$RULE_PROVIDER_FILE" 2>/dev/null)" ]; then - return - fi - - if [ -z "$interval" ] && [ "$type" = "http" ]; then - interval=86400 - fi - - if [ -z "$(grep "rule-providers:" "$RULE_PROVIDER_FILE" 2>/dev/null)" ]; then - echo "rule-providers:" > "$RULE_PROVIDER_FILE" - fi - - if [ -z "$(grep "OpenClash-Rule-Providers-Set" "$RULE_PROVIDER_FILE" 2>/dev/null)" ]; then - echo "#===================== OpenClash-Rule-Providers-Set =====================#" >> "$RULE_PROVIDER_FILE" - fi + return + fi + + if [ -z "$interval" ] && [ "$type" = "http" ]; then + interval=86400 + fi + + if [ -z "$(grep "rule-providers:" "$RULE_PROVIDER_FILE" 2>/dev/null)" ]; then + echo "rule-providers:" > "$RULE_PROVIDER_FILE" + fi + + if [ -z "$(grep "OpenClash-Rule-Providers-Set" "$RULE_PROVIDER_FILE" 2>/dev/null)" ]; then + echo "#===================== OpenClash-Rule-Providers-Set =====================#" >> "$RULE_PROVIDER_FILE" + fi cat >> "$RULE_PROVIDER_FILE" <<-EOF $name: @@ -844,69 +855,58 @@ cat >> "$RULE_PROVIDER_FILE" <<-EOF EOF fi - yml_rule_set_add "$name" "$group" "$position" + yml_rule_set_add "$name" "$group" "$position" } #处理规则集 yml_custom_rule_provider() { - - if [ -n "$(grep "OpenClash-Rule-Set-Extended-End" "$RULE_FILE")" ]; then - sed -i '/OpenClash-Rule-Set-Extended/,/OpenClash-Rule-Set-Extended-End/d' "$RULE_FILE" 2>/dev/null - fi - - if [ -n "$(grep "OpenClash-Rule-Set-Priority-End" "$RULE_FILE")" ]; then - sed -i '/OpenClash-Rule-Set-Priority/,/OpenClash-Rule-Set-Priority-End/d' "$RULE_FILE" 2>/dev/null - fi - - if [ -n "$(grep "OpenClash-Rule-Providers-Set" "$RULE_PROVIDER_FILE" 2>/dev/null)" ]; then - sed -i '/OpenClash-Rule-Providers-Set/,/OpenClash-Rule-Providers-Set-End/d' "$RULE_PROVIDER_FILE" 2>/dev/null - fi - - sed -i '/OpenClash-Rule-Set/d' "$RULE_FILE" 2>/dev/null - sed -i '/OpenClash-Rule-Providers/d' "$RULE_PROVIDER_FILE" 2>/dev/null - - if [ -z "$(grep "^ type:" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then - #处理缩进 - sed -i '/^ *$/d' "$RULE_PROVIDER_FILE" 2>/dev/null - sed -i 's/\t/ /g' "$RULE_PROVIDER_FILE" 2>/dev/null - sed -i 's/^ \{1,\}/ /g' "$RULE_PROVIDER_FILE" 2>/dev/null - sed -i 's/^ \{1,\}type:/ type:/g' "$RULE_PROVIDER_FILE" 2>/dev/null - sed -i 's/^ \{1,\}behavior:/ behavior:/g' "$RULE_PROVIDER_FILE" 2>/dev/null - sed -i 's/^ \{1,\}path:/ path:/g' "$RULE_PROVIDER_FILE" 2>/dev/null - sed -i 's/^ \{1,\}url:/ url:/g' "$RULE_PROVIDER_FILE" 2>/dev/null - sed -i 's/^ \{1,\}interval:/ interval:/g' "$RULE_PROVIDER_FILE" 2>/dev/null - sed -i 's/^ \{1,\}rule-providers:/rule-providers:/g' "$RULE_PROVIDER_FILE" 2>/dev/null - fi - - config_load "openclash" - config_foreach yml_get_rule_provider "rule_provider_config" - config_foreach yml_set_custom_rule_provider "rule_providers" - - if [ -n "$(grep "OpenClash-Rule-Providers-Set" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then - echo "#===================== OpenClash-Rule-Providers-Set-End =====================#" >> "$RULE_PROVIDER_FILE" - fi - + + if [ -n "$(grep "OpenClash-Rule-Set-Extended-End" "$RULE_FILE")" ]; then + sed -i '/OpenClash-Rule-Set-Extended/,/OpenClash-Rule-Set-Extended-End/d' "$RULE_FILE" 2>/dev/null + fi + + if [ -n "$(grep "OpenClash-Rule-Set-Priority-End" "$RULE_FILE")" ]; then + sed -i '/OpenClash-Rule-Set-Priority/,/OpenClash-Rule-Set-Priority-End/d' "$RULE_FILE" 2>/dev/null + fi + + if [ -n "$(grep "OpenClash-Rule-Providers-Set" "$RULE_PROVIDER_FILE" 2>/dev/null)" ]; then + sed -i '/OpenClash-Rule-Providers-Set/,/OpenClash-Rule-Providers-Set-End/d' "$RULE_PROVIDER_FILE" 2>/dev/null + fi + + sed -i '/OpenClash-Rule-Set/d' "$RULE_FILE" 2>/dev/null + sed -i '/OpenClash-Rule-Providers/d' "$RULE_PROVIDER_FILE" 2>/dev/null + + if [ -z "$(grep "^ type:" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then + #处理缩进 + sed -i '/^ *$/d' "$RULE_PROVIDER_FILE" 2>/dev/null + sed -i 's/\t/ /g' "$RULE_PROVIDER_FILE" 2>/dev/null + sed -i 's/^ \{1,\}/ /g' "$RULE_PROVIDER_FILE" 2>/dev/null + sed -i 's/^ \{1,\}type:/ type:/g' "$RULE_PROVIDER_FILE" 2>/dev/null + sed -i 's/^ \{1,\}behavior:/ behavior:/g' "$RULE_PROVIDER_FILE" 2>/dev/null + sed -i 's/^ \{1,\}path:/ path:/g' "$RULE_PROVIDER_FILE" 2>/dev/null + sed -i 's/^ \{1,\}url:/ url:/g' "$RULE_PROVIDER_FILE" 2>/dev/null + sed -i 's/^ \{1,\}interval:/ interval:/g' "$RULE_PROVIDER_FILE" 2>/dev/null + sed -i 's/^ \{1,\}rule-providers:/rule-providers:/g' "$RULE_PROVIDER_FILE" 2>/dev/null + fi + + config_load "openclash" + config_foreach yml_get_rule_provider "rule_provider_config" + config_foreach yml_set_custom_rule_provider "rule_providers" + + if [ -n "$(grep "OpenClash-Rule-Providers-Set" $RULE_PROVIDER_FILE 2>/dev/null)" ]; then + echo "#===================== OpenClash-Rule-Providers-Set-End =====================#" >> "$RULE_PROVIDER_FILE" + fi + } -lan_ac() +ac_add() { if [ -z "$1" ]; then return fi ipset add "$2" "$1" 2>/dev/null - -} - -wan_ac() -{ - if [ -z "$1" ]; then - return - fi - - ipset add "$2" "$1" 2>/dev/null - } firewall_redirect_exclude() @@ -955,42 +955,58 @@ else fi fi 2>/dev/null CONFIG_NAME=$(echo "$CONFIG_FILE" |awk -F '/' '{print $5}' 2>/dev/null) + +if [ ! -f "$CONFIG_FILE" ]; then + subscribe_info=$(uci get openclash.@config_subscribe[0].address 2>/dev/null) + if [ ! -f "$CONFIG_FILE" ] && [ -n "$subscribe_info" ]; then + echo "配置文件不存在,您已设置订阅信息,准备开始下载..." >$START_LOG + sleep 3 + kill_clash + stop + nohup /usr/share/openclash/openclash.sh & + elif [ ! -f "$CONFIG_FILE" ]; then + echo "错误: 缺少配置文件,请上传或更新配置文件!" >$START_LOG + echo "${LOGTIME} Config Not Found" >> $LOG_FILE + sleep 5 + start_fail + fi +fi } #运行模式处理 do_run_mode() { - en_mode=$(uci get openclash.config.en_mode 2>/dev/null) - - if [ "$en_mode" = "fake-ip-tun" ]; then - en_mode_tun="1" - en_mode="fake-ip" - fi + en_mode=$(uci get openclash.config.en_mode 2>/dev/null) + + if [ "$en_mode" = "fake-ip-tun" ]; then + en_mode_tun="1" + en_mode="fake-ip" + fi - if [ "$en_mode" = "redir-host-tun" ]; then - en_mode_tun="1" - en_mode="redir-host" - fi + if [ "$en_mode" = "redir-host-tun" ]; then + en_mode_tun="1" + en_mode="redir-host" + fi - if [ "$en_mode" = "redir-host-mix" ]; then - en_mode_tun="3" - en_mode="redir-host" - fi + if [ "$en_mode" = "redir-host-mix" ]; then + en_mode_tun="3" + en_mode="redir-host" + fi - if [ "$en_mode" = "redir-host-vpn" ]; then - en_mode_tun="2" - en_mode="redir-host" - fi + if [ "$en_mode" = "redir-host-vpn" ]; then + en_mode_tun="2" + en_mode="redir-host" + fi - if [ "$en_mode" = "fake-ip-vpn" ]; then - en_mode_tun="2" - en_mode="fake-ip" - fi + if [ "$en_mode" = "fake-ip-vpn" ]; then + en_mode_tun="2" + en_mode="fake-ip" + fi - if [ "$en_mode" = "fake-ip-mix" ]; then - en_mode_tun="3" - en_mode="fake-ip" - fi + if [ "$en_mode" = "fake-ip-mix" ]; then + en_mode_tun="3" + en_mode="fake-ip" + fi } do_run_core() @@ -1052,6 +1068,25 @@ do_run_core() [ ! -x "/etc/openclash/core/clash_tun" ] && chmod 4755 /etc/openclash/core/clash_tun 2>/dev/null [ ! -x "/etc/openclash/core/clash_game" ] && chmod 4755 /etc/openclash/core/clash_game 2>/dev/null [ ! -x "/etc/openclash/core/clash" ] && chmod 4755 /etc/openclash/core/clash 2>/dev/null + + [ ! -f "$CLASH" ] && { + echo "检测到内核文件不存在,准备开始下载..." >$START_LOG + sleep 3 + rm -rf "/tmp/clash_last_version" 2>/dev/null + kill_clash + stop + nohup /usr/share/openclash/openclash_core.sh "$core_type" & + } + ulimit -SHn 65535 2>/dev/null + config_reload=$(uci get openclash.config.config_reload 2>/dev/null) + if [ -n "$(pidof clash)" ] && [ "$core_type" != "Tun" ] && [ "$config_reload" != "0" ]; then + curl -s --connect-timeout 5 -m 5 -H 'Content-Type: application/json' -H "Authorization: Bearer ${da_password}" -XPUT http://"$lan_ip":"$cn_port"/configs -d "{\"path\": \"$CONFIG_FILE\"}" 2>/dev/null + else + kill_clash + nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 & + fi + uci set openclash.config.config_reload=1 2>/dev/null + uci commit openclash } set_firewall() @@ -1090,37 +1125,52 @@ cat > "/var/etc/openclash.include" <<-EOF EOF if [ "$china_ip_route" -eq 1 ]; then - if [ ! -f "/etc/openclash/china_ip_route.ipset" ]; then + if [ ! -f "/usr/share/openclash/res/china_ip_route.ipset" ]; then cp /etc/openclash/rule_provider/ChinaIP.yaml /tmp/china_ip_route.list 2>/dev/null sed -i "s/'//g" /tmp/china_ip_route.list 2>/dev/null sed -i "s/^ \{0,\}- //g" /tmp/china_ip_route.list 2>/dev/null sed -i '/payload:/d' /tmp/china_ip_route.list 2>/dev/null sed -i '/^ \{0,\}#/d' /tmp/china_ip_route.list 2>/dev/null - echo "create china_ip_route hash:net family inet hashsize 1024 maxelem 65536" >/etc/openclash/china_ip_route.ipset - awk '!/^$/&&!/^#/{printf("add china_ip_route %s'" "'\n",$0)}' /tmp/china_ip_route.list >>/etc/openclash/china_ip_route.ipset + echo "create china_ip_route hash:net family inet hashsize 1024 maxelem 65536" >/usr/share/openclash/res/china_ip_route.ipset + awk '!/^$/&&!/^#/{printf("add china_ip_route %s'" "'\n",$0)}' /tmp/china_ip_route.list >>/usr/share/openclash/res/china_ip_route.ipset rm -rf /tmp/china_ip_route.list 2>/dev/null fi ipset -! flush china_ip_route 2>/dev/null - ipset -! restore /dev/null + ipset -! restore /dev/null fi #lan_ac if [ "$operation_mode" = "redir-host" ] && [ "$en_mode" = "redir-host" ]; then - if [ "$lan_ac_mode" = "0" ] && [ -n "$(uci get openclash.config.lan_ac_black_ips 2>/dev/null)" ]; then - ipset create lan_ac_black_ips hash:net - config_load "openclash" - config_list_foreach "config" "lan_ac_black_ips" lan_ac "lan_ac_black_ips" - elif [ "$lan_ac_mode" = "1" ] && [ -n "$(uci get openclash.config.lan_ac_white_ips 2>/dev/null)" ]; then - ipset create lan_ac_white_ips hash:net - config_load "openclash" - config_list_foreach "config" "lan_ac_white_ips" lan_ac "lan_ac_white_ips" + if [ "$lan_ac_mode" = "0" ]; then + if [ -n "$(uci get openclash.config.lan_ac_black_ips 2>/dev/null)" ]; then + ipset create lan_ac_black_ips hash:net + config_load "openclash" + config_list_foreach "config" "lan_ac_black_ips" ac_add "lan_ac_black_ips" + fi + if [ -n "$(uci get openclash.config.lan_ac_black_macs 2>/dev/null)" ]; then + ipset create lan_ac_black_macs hash:mac + config_load "openclash" + config_list_foreach "config" "lan_ac_black_macs" ac_add "lan_ac_black_macs" + fi + elif [ "$lan_ac_mode" = "1" ]; then + if [ -n "$(uci get openclash.config.lan_ac_white_ips 2>/dev/null)" ]; then + ipset create lan_ac_white_ips hash:net + config_load "openclash" + config_list_foreach "config" "lan_ac_white_ips" ac_add "lan_ac_white_ips" + fi + if [ -n "$(uci get openclash.config.lan_ac_white_macs 2>/dev/null)" ]; then + ipset create lan_ac_white_macs hash:mac + config_load "openclash" + config_list_foreach "config" "lan_ac_white_macs" ac_add "lan_ac_white_macs" + fi fi fi +#wan ac if [ -n "$(uci get openclash.config.wan_ac_black_ips 2>/dev/null)" ]; then - ipset create wan_ac_black_ips hash:net - config_load "openclash" - config_list_foreach "config" "wan_ac_black_ips" wan_ac "wan_ac_black_ips" + ipset create wan_ac_black_ips hash:net + config_load "openclash" + config_list_foreach "config" "wan_ac_black_ips" ac_add "wan_ac_black_ips" fi #local @@ -1147,6 +1197,8 @@ if [ -z "$en_mode_tun" ] || [ "$en_mode_tun" -eq 3 ]; then iptables -t nat -A openclash -m set --match-set localnetwork dst -j RETURN iptables -t nat -A openclash -m set --match-set wan_ac_black_ips dst -j RETURN >/dev/null 2>&1 iptables -t nat -A openclash -m set --match-set lan_ac_black_ips src -j RETURN >/dev/null 2>&1 + iptables -t nat -A openclash -m set --match-set lan_ac_black_macs src -j RETURN >/dev/null 2>&1 + iptables -t nat -A openclash -m set ! --match-set lan_ac_white_macs src -j RETURN >/dev/null 2>&1 iptables -t nat -A openclash -m set ! --match-set lan_ac_white_ips src -j RETURN >/dev/null 2>&1 if [ "$en_mode" = "redir-host" ]; then iptables -t nat -A openclash -m set --match-set china_ip_route dst -j RETURN >/dev/null 2>&1 @@ -1166,10 +1218,12 @@ if [ -z "$en_mode_tun" ] || [ "$en_mode_tun" -eq 3 ]; then iptables -t mangle -N openclash iptables -t mangle -A openclash -m set --match-set localnetwork dst -j RETURN iptables -t mangle -A openclash -m set --match-set wan_ac_black_ips dst -j RETURN >/dev/null 2>&1 + iptables -t mangle -A openclash -m set --match-set lan_ac_black_macs src -j RETURN >/dev/null 2>&1 iptables -t mangle -A openclash -m set --match-set lan_ac_black_ips src -j RETURN >/dev/null 2>&1 iptables -t mangle -A openclash -m set ! --match-set lan_ac_white_ips src -j RETURN >/dev/null 2>&1 + iptables -t mangle -A openclash -m set ! --match-set lan_ac_white_macs src -j RETURN >/dev/null 2>&1 if [ "$en_mode" = "redir-host" ]; then - iptables -t mangle -A openclash -m set --match-set china_ip_route dst -j RETURN >/dev/null 2>&1 + iptables -t mangle -A openclash -m set --match-set china_ip_route dst -j RETURN >/dev/null 2>&1 fi iptables -t mangle -A openclash -p udp --dport 53 -j RETURN >/dev/null 2>&1 #端口转发 @@ -1181,9 +1235,9 @@ if [ -z "$en_mode_tun" ] || [ "$en_mode_tun" -eq 3 ]; then fi if [ "$en_mode" = "fake-ip" ]; then - iptables -t nat -N openclash_output + iptables -t nat -N openclash_output iptables -t nat -F openclash_output - iptables -t nat -A openclash_output -m set --match-set localnetwork dst -j RETURN + iptables -t nat -A openclash_output -m set --match-set localnetwork dst -j RETURN iptables -t nat -A openclash_output -p tcp -d 198.18.0.0/16 -j REDIRECT --to-ports "$proxy_port" iptables -t nat -A OUTPUT -p tcp -j openclash_output fi @@ -1251,13 +1305,16 @@ if [ -n "$en_mode_tun" ]; then config_load "firewall" config_foreach firewall_redirect_exclude "redirect" #其他流量 + iptables -t mangle -A openclash -m set --match-set localnetwork dst -j RETURN >/dev/null 2>&1 iptables -t mangle -A openclash -m set --match-set wan_ac_black_ips dst -j RETURN >/dev/null 2>&1 iptables -t mangle -A openclash -m set --match-set lan_ac_black_ips src -j RETURN >/dev/null 2>&1 + iptables -t mangle -A openclash -m set --match-set lan_ac_black_macs src -j RETURN >/dev/null 2>&1 iptables -t mangle -A openclash -m set ! --match-set lan_ac_white_ips src -j RETURN >/dev/null 2>&1 + iptables -t mangle -A openclash -m set ! --match-set lan_ac_white_macs src -j RETURN >/dev/null 2>&1 if [ "$en_mode" = "redir-host" ]; then iptables -t mangle -A openclash -m set --match-set china_ip_route dst -j RETURN >/dev/null 2>&1 fi - iptables -t mangle -A openclash -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK" + iptables -t mangle -A openclash -j MARK --set-mark "$PROXY_FWMARK" if [ "$en_mode_tun" -ne 3 ]; then iptables -t mangle -I PREROUTING -j openclash @@ -1271,7 +1328,6 @@ if [ -n "$en_mode_tun" ]; then iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j ACCEPT fi - #ipv6 # if [ "$ipv6_enable" -eq 1 ]; then # ip6tables -t mangle -I PREROUTING -j MARK --set-mark "$PROXY_FWMARK" @@ -1351,6 +1407,8 @@ revert_firewall() ipset destroy china_ip_route >/dev/null 2>&1 ipset destroy lan_ac_white_ips >/dev/null 2>&1 ipset destroy lan_ac_black_ips >/dev/null 2>&1 + ipset destroy lan_ac_white_macs >/dev/null 2>&1 + ipset destroy lan_ac_black_macs >/dev/null 2>&1 ipset destroy wan_ac_black_ips >/dev/null 2>&1 } @@ -1381,198 +1439,147 @@ get_config() china_ip_route=$(uci get openclash.config.china_ip_route 2>/dev/null) } +yml_field_check() +{ + if [ -f "$GROUP_FILE" ]; then + if [ ! -f "$PROXY_FILE" ] && [ ! -f "$PROXY_PROVIDER_FILE" ]; then + echo "错误: 配置文件完整性检查不通过,已自动还原配置文件,请对照模板格式检查修改配置文件!" >$START_LOG + mv "$START_BACKUP" "$CONFIG_FILE" + sleep 5 + start_fail + elif [ ! -f "$RULE_FILE" ] && [ ! -f "$SCRIPT_FILE" ]; then + echo "错误: 配置文件完整性检查不通过,已自动还原配置文件,请对照模板格式检查修改配置文件!" >$START_LOG + mv "$START_BACKUP" "$CONFIG_FILE" + sleep 5 + start_fail + fi + else + nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 & + echo "错误: 配置文件完整性检查不通过,已自动还原配置文件,请根据日志信息对照模板格式检查修改配置文件!" >$START_LOG + mv "$START_BACKUP" "$CONFIG_FILE" + sleep 5 + start_fail + fi +} + start() { -#禁止多个实例 -status=$(unify_ps_status "/etc/init.d/openclash") -[ "$status" -gt "3" ] && exit 0 + #禁止多个实例 + status=$(unify_ps_status "/etc/init.d/openclash") + [ "$status" -gt "3" ] && echo "Multiple Start Scripts Running, Exit..." >> $LOG_FILE && exit 0 + + enable=$(uci get openclash.config.enable 2>/dev/null) + [ "$enable" != "1" ] && echo "OpenClash Now Disabled, Need Start From Luci Page, Exit..." >> $LOG_FILE && exit 0 -config_choose + config_choose -enable=$(uci get openclash.config.enable 2>/dev/null) - -if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then - do_run_mode - echo "OpenClash 开始启动..." >$START_LOG - echo "第一步: 获取配置..." >$START_LOG - get_config - echo "第二步: 配置文件检查..." >$START_LOG - yml_check "$en_mode" "$enable_custom_dns" "$CONFIG_FILE" "$BACKUP_FILE" "$START_BACKUP" - if [ -f "$GROUP_FILE" ]; then - if [ ! -f "$PROXY_FILE" ] && [ ! -f "$PROXY_PROVIDER_FILE" ]; then - kill_clash - stop - echo "错误: 配置文件完整性检查不通过,已自动还原配置文件,请对照模板格式检查修改配置文件!" >$START_LOG - mv "$START_BACKUP" "$CONFIG_FILE" - sleep 5 - echo "" >$START_LOG - elif [ ! -f "$RULE_FILE" ] && [ ! -f "$SCRIPT_FILE" ]; then - kill_clash - stop - echo "错误: 配置文件完整性检查不通过,已自动还原配置文件,请对照模板格式检查修改配置文件!" >$START_LOG - mv "$START_BACKUP" "$CONFIG_FILE" - sleep 5 - echo "" >$START_LOG - else - echo "第三步: 修改配置文件..." >$START_LOG - config_load "openclash" - config_foreach yml_auth_get "authentication" - yml_auth_custom "$CHANGE_FILE" - yml_dns_custom "$enable_custom_dns" "$DNS_FILE" "$FALLBACK_FILTER_FILE" - /usr/share/openclash/yml_change.sh >/dev/null 2>&1 "$LOGTIME" "$en_mode" "$enable_custom_dns" "$da_password" "$cn_port" "$proxy_port" "$CHANGE_FILE" "$ipv6_enable" "$http_port" "$socks_port" "$lan_ip" "$log_level" "$proxy_mode" "$intranet_allowed" "$en_mode_tun" "$stack_type" & - /usr/share/openclash/yml_rules_change.sh >/dev/null 2>&1 "$LOGTIME" "$rule_source" "$enable_custom_clash_rules" "$RULE_FILE" "$set_rule_file" "$en_mode" "$enable_rule_proxy" "$BACKUP_FILE" "$RULE_PROVIDER_FILE" & - wait - yml_provider_path "$PROXY_PROVIDER_FILE" "proxy_provider" - yml_provider_path "$RULE_PROVIDER_FILE" "rule_provider" - yml_custom_rule_provider - yml_game_custom - echo "第四步: DNS设置检查..." >$START_LOG - if [ -n "$(sed -n '/^ \{0,\}nameserver:/{n;p}' "$CONFIG_FILE" |grep '^ \{0,\}fallback:')" ] || [ -n "$(sed -n '/^ \{0,\}nameserver:/{n;p}' "$CONFIG_FILE" |grep 'OpenClash-General')" ]; then - kill_clash - stop - echo "错误: 配置文件DNS选项下的Nameserver必须设置服务器,已自动还原配置文件,请重新设置!" >$START_LOG - echo "${LOGTIME} Nameserver Must Be Set, Please Change Your Configrations In Config.yaml" >>$LOG_FILE - mv "$START_BACKUP" "$CONFIG_FILE" - sleep 10 - echo "" >$START_LOG - else - echo "第五步: 启动主程序..." >$START_LOG - #检查是否存在核心文件 - do_run_core - [ ! -f "$CLASH" ] && { - kill_clash - stop - echo "内核文件不存在,开始下载..." >$START_LOG - nohup /usr/share/openclash/openclash_core.sh "$core_type" & - exit 0 - } - ulimit -SHn 65535 2>/dev/null - config_reload=$(uci get openclash.config.config_reload 2>/dev/null) - if [ -n "$(pidof clash)" ] && [ "$core_type" != "Tun" ] && [ "$config_reload" != "0" ]; then - curl -s --connect-timeout 5 -m 5 -H 'Content-Type: application/json' -H "Authorization: Bearer ${da_password}" -XPUT http://"$lan_ip":"$cn_port"/configs -d "{\"path\": \"$CONFIG_FILE\"}" 2>/dev/null - else - kill_clash - nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 & - fi - uci set openclash.config.config_reload=1 2>/dev/null - uci commit openclash - - #检测proxy_provider配置文件状态 - echo "第六步: 等待主程序下载外部文件..." >$START_LOG - yml_provider_check "$PROXY_PROVIDER_FILE" "proxy_provider" - yml_provider_check "$RULE_PROVIDER_FILE" "rule_provider" - - echo "第七步: 设置控制面板..." >$START_LOG - ln -s /usr/share/openclash/yacd /www/luci-static/openclash 2>/dev/null - - echo "第八步: 设置防火墙规则..." >$START_LOG - set_firewall - - echo "第九步: 重启 Dnsmasq 程序..." >$START_LOG - change_dns "$enable_redirect_dns" "$disable_masq_cache" - /etc/init.d/dnsmasq restart >/dev/null 2>&1 - if pidof clash >/dev/null; then - echo "第十步: 还原策略组节点状态..." >$START_LOG - /usr/share/openclash/openclash_history_set.sh - echo "第十一步: 添加计划任务,启动进程守护程序..." >$START_LOG - add_cron - if [ -z "$(uci get dhcp.lan.dhcpv6 2>/dev/null)" ]; then - echo "OpenClash 启动成功,请等待服务器上线!" >$START_LOG - echo "${LOGTIME} OpenClash Start Successful" >> $LOG_FILE - sleep 5 - else - echo "OpenClash 启动成功,检测到您启用了IPV6的DHCP服务,可能会造成连接异常!" >$START_LOG - echo "${LOGTIME} OpenClash Start Successful, Please Note That Network May Abnormal With IPV6's DHCP Server" >> $LOG_FILE - sleep 10 - fi - echo "OpenClash Already Start" - echo "" >$START_LOG - else - if [ "$rule_source" != 0 ] || [ "$enable_custom_clash_rules" != 0 ]; then - echo "错误: OpenClash 启动失败,尝试还原第三方规则并重新启动 Clash 主程序..." >$START_LOG - echo "${LOGTIME} OpenClash Can Not Start, Try Use Backup Rules Start Again" >> $LOG_FILE - #获取备份rule_provider - rule_provider_bak_len=$(sed -n '/^rule-providers:/=' "$START_BACKUP" 2>/dev/null) - if [ -n "$rule_provider_bak_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$rule_provider_bak_len" "$RULE_PROVIDER_BAK_FILE" "$START_BACKUP" - fi 2>/dev/null - #获取备份script - script_bak_len=$(sed -n '/^script:/=' "$START_BACKUP" 2>/dev/null) - if [ -n "$script_bak_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$script_bak_len" "$SCRIPT_BAK_FILE" "$START_BACKUP" - fi 2>/dev/null - #获取备份rule - rule_bak_len=$(sed -n '/^rules:/=' "$START_BACKUP" 2>/dev/null) - if [ -n "$rule_bak_len" ]; then - /usr/share/openclash/yml_field_cut.sh "$rule_bak_len" "$RULE_BAK_FILE" "$START_BACKUP" - fi 2>/dev/null - yml_rule_bak_merge - nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 & - sleep 3 - if pidof clash >/dev/null; then - /usr/share/openclash/openclash_history_set.sh - add_cron - if [ -z "$(uci get dhcp.lan.dhcpv6 2>/dev/null)" ]; then - echo "OpenClash 使用备份规则启动成功,请更新、检查变动的规则后重试!" >$START_LOG - echo "${LOGTIME} OpenClash Start Successful With Backup Rules Config, Please Check Or Update Other Rules And Retry" >> $LOG_FILE - sleep 10 - else - echo "OpenClash 使用备份规则启动成功,请更新、检查变动的规则后重试!" >$START_LOG - echo "${LOGTIME} OpenClash Start Successful With Backup Rules Config, Please Check Or Update Other Rules And Retry" >> $LOG_FILE - sleep 5 - echo "检测到您启用了IPV6的DHCP服务,可能会造成连接异常!" >$START_LOG - echo "${LOGTIME} OpenClash Start Successful, Please Note That Network May Abnormal With IPV6's DHCP Server" >> $LOG_FILE - sleep 10 - fi - echo "OpenClash Already Start" - echo "" >$START_LOG - else - kill_clash - stop - echo "错误: OpenClash 启动失败,请到日志页面查看详细错误信息!" >$START_LOG - echo "${LOGTIME} OpenClash Can Not Start, Please Check The Error Info And Try Again" >> $LOG_FILE - sleep 10 - echo "" >$START_LOG - fi - else - kill_clash - stop - echo "错误: OpenClash 启动失败,请到日志页面查看详细错误信息!" >$START_LOG - echo "${LOGTIME} OpenClash Can Not Start, Please Check The Error Info And Try Again" >> $LOG_FILE - sleep 10 - echo "" >$START_LOG - fi - fi - fi - fi - else - nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 & - kill_clash - stop - echo "错误: 配置文件完整性检查不通过,已自动还原配置文件,请根据日志信息对照模板格式检查修改配置文件!" >$START_LOG - mv "$START_BACKUP" "$CONFIG_FILE" - sleep 5 - echo "" >$START_LOG - fi - rm -rf $START_BACKUP 2>/dev/null - rm -rf /tmp/yaml_* 2>/dev/null -else - subscribe_info=$(uci get openclash.@config_subscribe[0].address 2>/dev/null) - if [ ! -f "$CONFIG_FILE" ] && [ -n "$subscribe_info" ]; then - kill_clash - stop - echo "OpenClash 配置文件不存在,开始下载..." >$START_LOG - nohup /usr/share/openclash/openclash.sh & - exit 0 - elif [ ! -f "$CONFIG_FILE" ]; then - kill_clash - stop - echo "错误: OpenClash 缺少配置文件,请上传或更新配置文件!" >$START_LOG - echo "${LOGTIME} Config Not Found" >> $LOG_FILE + echo "OpenClash 开始启动..." >$START_LOG + do_run_mode + + echo "第一步: 获取配置..." >$START_LOG + get_config + + echo "第二步: 配置文件检查..." >$START_LOG + yml_check "$en_mode" "$enable_custom_dns" "$CONFIG_FILE" "$BACKUP_FILE" "$START_BACKUP" + yml_dns_check + yml_field_check + + echo "第三步: 修改配置文件..." >$START_LOG + config_load "openclash" + config_foreach yml_auth_get "authentication" + yml_auth_custom "$CHANGE_FILE" + yml_dns_custom "$enable_custom_dns" "$DNS_FILE" "$FALLBACK_FILTER_FILE" + /usr/share/openclash/yml_change.sh >/dev/null 2>&1 "$LOGTIME" "$en_mode" "$enable_custom_dns" "$da_password" "$cn_port" "$proxy_port" "$CHANGE_FILE" "$ipv6_enable" "$http_port" "$socks_port" "$lan_ip" "$log_level" "$proxy_mode" "$intranet_allowed" "$en_mode_tun" "$stack_type" & + /usr/share/openclash/yml_rules_change.sh >/dev/null 2>&1 "$LOGTIME" "$rule_source" "$enable_custom_clash_rules" "$RULE_FILE" "$set_rule_file" "$en_mode" "$enable_rule_proxy" "$BACKUP_FILE" "$RULE_PROVIDER_FILE" & + wait + yml_provider_path "$PROXY_PROVIDER_FILE" "proxy_provider" + yml_provider_path "$RULE_PROVIDER_FILE" "rule_provider" + yml_custom_rule_provider + yml_game_custom + + echo "第四步: DNS设置检查..." >$START_LOG + if [ -n "$(sed -n '/^ \{0,\}nameserver:/{n;p}' "$CONFIG_FILE" |grep '^ \{0,\}fallback:')" ] || [ -n "$(sed -n '/^ \{0,\}nameserver:/{n;p}' "$CONFIG_FILE" |grep 'OpenClash-General')" ]; then + echo "错误: 配置文件DNS选项下的Nameserver必须设置服务器,已自动还原配置文件,请重新设置!" >$START_LOG + echo "${LOGTIME} Nameserver Must Be Set, Please Change Your Configrations In Config.yaml" >>$LOG_FILE + mv "$START_BACKUP" "$CONFIG_FILE" sleep 5 - echo "" >$START_LOG + start_fail fi -fi + + echo "第五步: 启动主程序..." >$START_LOG + #检查是否存在核心文件 + do_run_core + + #检测proxy_provider配置文件状态 + echo "第六步: 等待主程序下载外部文件..." >$START_LOG + yml_provider_check "$PROXY_PROVIDER_FILE" "proxy_provider" + yml_provider_check "$RULE_PROVIDER_FILE" "rule_provider" + + echo "第七步: 设置控制面板..." >$START_LOG + ln -s /usr/share/openclash/yacd /www/luci-static/openclash 2>/dev/null + + echo "第八步: 设置防火墙规则..." >$START_LOG + set_firewall + + echo "第九步: 重启 Dnsmasq 程序..." >$START_LOG + change_dns "$enable_redirect_dns" "$disable_masq_cache" + /etc/init.d/dnsmasq restart >/dev/null 2>&1 + + echo "第十步: 检查内核启动状态..." >$START_LOG + if [ -z "$(pidof clash)" ] && [ "$rule_source" = 0 ] && [ "$enable_custom_clash_rules" = 0 ]; then + echo "错误: OpenClash 启动失败,请到日志页面查看详细错误信息!" >$START_LOG + echo "${LOGTIME} OpenClash Can Not Start, Please Check The Error Info And Try Again" >> $LOG_FILE + sleep 5 + start_fail + fi + if ! pidof clash >/dev/null; then + echo "错误: OpenClash 启动失败,尝试还原第三方规则并重新启动 Clash 主程序..." >$START_LOG + echo "${LOGTIME} OpenClash Can Not Start, Try Use Backup Rules Start Again" >> $LOG_FILE + rm -rf /tmp/yaml_general 2>/dev/null + #获取备份rule_provider + rule_provider_bak_len=$(sed -n '/^rule-providers:/=' "$START_BACKUP" 2>/dev/null) + if [ -n "$rule_provider_bak_len" ]; then + /usr/share/openclash/yml_field_cut.sh "$rule_provider_bak_len" "$RULE_PROVIDER_BAK_FILE" "$START_BACKUP" + fi 2>/dev/null + #获取备份script + script_bak_len=$(sed -n '/^script:/=' "$START_BACKUP" 2>/dev/null) + if [ -n "$script_bak_len" ]; then + /usr/share/openclash/yml_field_cut.sh "$script_bak_len" "$SCRIPT_BAK_FILE" "$START_BACKUP" + fi 2>/dev/null + #获取备份rule + rule_bak_len=$(sed -n '/^rules:/=' "$START_BACKUP" 2>/dev/null) + if [ -n "$rule_bak_len" ]; then + /usr/share/openclash/yml_field_cut.sh "$rule_bak_len" "$RULE_BAK_FILE" "$START_BACKUP" + fi 2>/dev/null + yml_rule_bak_merge + nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 & + sleep 3 + if ! pidof clash >/dev/null; then + echo "错误: OpenClash 启动失败,请到日志页面查看详细错误信息!" >$START_LOG + echo "${LOGTIME} OpenClash Can Not Start, Please Check The Error Info And Try Again" >> $LOG_FILE + sleep 5 + start_fail + fi + fi + + echo "第十一步: 还原策略组节点状态..." >$START_LOG + /usr/share/openclash/openclash_history_set.sh + + echo "第十二步: 添加计划任务,启动进程守护程序..." >$START_LOG + add_cron + if [ -z "$(uci get dhcp.lan.dhcpv6 2>/dev/null)" ]; then + echo "OpenClash 启动成功,请等待服务器上线!" >$START_LOG + echo "${LOGTIME} OpenClash Start Successful" >> $LOG_FILE + sleep 5 + else + echo "OpenClash 启动成功,检测到您启用了IPV6的DHCP服务,可能会造成连接异常!" >$START_LOG + echo "${LOGTIME} OpenClash Start Successful, Please Note That Network May Abnormal With IPV6's DHCP Server" >> $LOG_FILE + sleep 5 + fi + echo "OpenClash Already Start" + echo "" >$START_LOG + rm -rf $START_BACKUP 2>/dev/null + rm -rf /tmp/yaml_* 2>/dev/null } stop() @@ -1591,10 +1598,10 @@ stop() watchdog_pids=$(unify_ps_pids "openclash_watchdog.sh") for watchdog_pid in $watchdog_pids; do kill -9 "$watchdog_pid" >/dev/null 2>&1 - done + done >/dev/null 2>&1 echo "第四步: 关闭 Clash 主程序..." >$START_LOG - if [ "$enable" -eq 0 ]; then + if [ "$enable" != "1" ]; then kill_clash fi @@ -1602,11 +1609,11 @@ stop() dns_port=$(uci get openclash.config.dns_port 2>/dev/null) redirect_dns=$(uci get openclash.config.redirect_dns 2>/dev/null) masq_cache=$(uci get openclash.config.masq_cache 2>/dev/null) - revert_dns "$redirect_dns" "$masq_cache" "$dns_port" + revert_dns "$redirect_dns" "$masq_cache" "$dns_port" "$enable" /etc/init.d/dnsmasq restart >/dev/null 2>&1 echo "第六步:删除 OpenClash 残留文件..." >$START_LOG - if [ "$enable" -eq 0 ]; then + if [ "$enable" != "1" ]; then rm -rf $LOG_FILE 2>/dev/null rm -rf /tmp/openclash_debug.log 2>/dev/null rm -rf /www/luci-static/openclash 2>/dev/null @@ -1614,6 +1621,7 @@ stop() rm -rf /tmp/clash_last_version 2>/dev/null rm -rf /tmp/Proxy_Group 2>/dev/null rm -rf /tmp/rules_name 2>/dev/null + rm -rf /tmp/rule_providers_name 2>/dev/null echo "OpenClash 关闭成功!" >$START_LOG sleep 5 fi @@ -1638,6 +1646,6 @@ reload() do_run_mode 2>/dev/null get_config 2>/dev/null set_firewall 2>/dev/null - echo "${LOGTIME} OpenClash Reload After Firewall Restart" >> $LOG_FILE + echo "${LOGTIME} Reload OpenClash Firewall Rules" >> $LOG_FILE fi } diff --git a/package/ctcgfw/luci-app-openclash/root/etc/openclash/Country.mmdb b/package/ctcgfw/luci-app-openclash/root/etc/openclash/Country.mmdb new file mode 100644 index 0000000000..4b0fa6ac8c Binary files /dev/null and b/package/ctcgfw/luci-app-openclash/root/etc/openclash/Country.mmdb differ diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_domain_dns.list b/package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_domain_dns.list similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_domain_dns.list rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_domain_dns.list diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_fake_filter.list b/package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_fake_filter.list similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_fake_filter.list rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_fake_filter.list diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_hosts.list b/package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_hosts.list similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_hosts.list rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_hosts.list diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_rules.list b/package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_rules.list similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_rules.list rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_rules.list diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_rules_2.list b/package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_rules_2.list similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/custom/openclash_custom_rules_2.list rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/custom/openclash_custom_rules_2.list diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules/CS-GO.rules b/package/ctcgfw/luci-app-openclash/root/etc/openclash/game_rules/CS-GO.rules similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules/CS-GO.rules rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/game_rules/CS-GO.rules diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules/Monster-Hunter-World.rules b/package/ctcgfw/luci-app-openclash/root/etc/openclash/game_rules/Monster-Hunter-World.rules similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules/Monster-Hunter-World.rules rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/game_rules/Monster-Hunter-World.rules diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules/PUBG-Asia%26-Southeast-Asia.rules b/package/ctcgfw/luci-app-openclash/root/etc/openclash/game_rules/PUBG-Asia%26-Southeast-Asia.rules similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules/PUBG-Asia%26-Southeast-Asia.rules rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/game_rules/PUBG-Asia%26-Southeast-Asia.rules diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules/Steam.rules b/package/ctcgfw/luci-app-openclash/root/etc/openclash/game_rules/Steam.rules similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules/Steam.rules rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/game_rules/Steam.rules diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/China.yaml b/package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/China.yaml similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/China.yaml rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/China.yaml diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/ChinaIP.yaml b/package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/ChinaIP.yaml similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/ChinaIP.yaml rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/ChinaIP.yaml diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/Global.yaml b/package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/Global.yaml similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/Global.yaml rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/Global.yaml diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/Streaming.yaml b/package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/Streaming.yaml similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/Streaming.yaml rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/Streaming.yaml diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/StreamingSE.yaml b/package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/StreamingSE.yaml similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/StreamingSE.yaml rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/StreamingSE.yaml diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/Unbreak.yaml b/package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/Unbreak.yaml similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_provider/Unbreak.yaml rename to package/ctcgfw/luci-app-openclash/root/etc/openclash/rule_provider/Unbreak.yaml diff --git a/package/ctcgfw/luci-app-openclash/root/etc/uci-defaults/luci-openclash b/package/ctcgfw/luci-app-openclash/root/etc/uci-defaults/luci-openclash new file mode 100644 index 0000000000..c9b335262c --- /dev/null +++ b/package/ctcgfw/luci-app-openclash/root/etc/uci-defaults/luci-openclash @@ -0,0 +1,55 @@ +#!/bin/sh + +uci delete ucitrack.@openclash[-1] >/dev/null 2>&1 +uci add ucitrack openclash >/dev/null 2>&1 +uci set ucitrack.@openclash[-1].init=openclash >/dev/null 2>&1 +uci commit ucitrack >/dev/null 2>&1 +uci delete firewall.openclash >/dev/null 2>&1 +uci set firewall.openclash=include >/dev/null 2>&1 +uci set firewall.openclash.type=script >/dev/null 2>&1 +uci set firewall.openclash.path=/var/etc/openclash.include >/dev/null 2>&1 +uci set firewall.openclash.reload=1 >/dev/null 2>&1 +uci commit firewall >/dev/null 2>&1 + +mkdir -p /etc/openclash/config >/dev/null 2>&1 +mkdir -p /etc/openclash/proxy_provider >/dev/null 2>&1 +mkdir -p /etc/openclash/backup >/dev/null 2>&1 +mkdir -p /etc/openclash/core >/dev/null 2>&1 +mkdir -p /etc/openclash/history >/dev/null 2>&1 +mkdir -p /usr/share/openclash/backup >/dev/null 2>&1 + +cp "/etc/config/openclash" "/usr/share/openclash/backup/openclash" >/dev/null 2>&1 +cp "/etc/openclash/custom/openclash_custom_rules.list" "/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1 +cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1 +cp "/etc/openclash/custom/openclash_custom_hosts.list" "/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1 +cp "/etc/openclash/custom/openclash_custom_fake_filter.list" "/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1 +cp "/etc/openclash/custom/openclash_custom_domain_dns.list" "/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1 + +mkdir -p /lib/upgrade/keep.d >/dev/null 2>&1 +cat > "/lib/upgrade/keep.d/luci-app-openclash" <<-EOF +/etc/openclash/ +EOF + +if [ -f "/tmp/openclash.bak" ]; then + mv "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1 + cp -rf "/tmp/openclash/." "/etc/openclash/" >/dev/null 2>&1 + cp -rf "/tmp/openclash_config/." "/etc/openclash/config/" >/dev/null 2>&1 + cp -rf "/tmp/openclash_core/." "/etc/openclash/core/" >/dev/null 2>&1 + cp -rf "/tmp/openclash_history/." "/etc/openclash/history/" >/dev/null 2>&1 + cp -rf "/tmp/openclash_proxy_provider/." "/etc/openclash/proxy_provider/" >/dev/null 2>&1 + cp -rf "/tmp/openclash_rule_provider/." "/etc/openclash/rule_provider/" >/dev/null 2>&1 + cp -rf "/tmp/openclash_game_rules/." "/etc/openclash/game_rules/" >/dev/null 2>&1 + mv "/tmp/openclash_custom_rules.list.bak" "/etc/openclash/custom/openclash_custom_rules.list" >/dev/null 2>&1 + mv "/tmp/openclash_custom_rules_2.list.bak" "/etc/openclash/custom/openclash_custom_rules_2.list" >/dev/null 2>&1 + mv "/tmp/openclash_custom_hosts.list.bak" "/etc/openclash/custom/openclash_custom_hosts.list" >/dev/null 2>&1 + mv "/tmp/openclash_custom_fake_filter.list.bak" "/etc/openclash/custom/openclash_custom_fake_filter.list" >/dev/null 2>&1 + mv "/tmp/openclash_custom_domain_dns.list.bak" "/etc/openclash/custom/openclash_custom_domain_dns.list" >/dev/null 2>&1 + rm -rf "/etc/openclash/openclash" >/dev/null 2>&1 + rm -rf /tmp/openclash* >/dev/null 2>&1 +fi + +uci set openclash.config.enable=0 >/dev/null 2>&1 +uci commit openclash >/dev/null 2>&1 + +rm -f /tmp/luci-indexcache +exit 0 \ No newline at end of file diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/cfg_servers_address_fake_filter.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/cfg_servers_address_fake_filter.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/cfg_servers_address_fake_filter.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/cfg_servers_address_fake_filter.sh diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/cfg_unused_servers_del.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/cfg_unused_servers_del.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/cfg_unused_servers_del.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/cfg_unused_servers_del.sh diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/clash_version.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/clash_version.sh old mode 100755 new mode 100644 similarity index 87% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/clash_version.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/clash_version.sh index 0fab04c87b..051be0c299 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/clash_version.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/clash_version.sh @@ -19,7 +19,7 @@ if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{prin if pidof clash >/dev/null; then curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1 else - curl -sL --connect-timeout 10 --retry 2 "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1 + curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/core_version -o $LAST_OPVER >/dev/null 2>&1 fi if [ "$?" -eq "0" ] && [ -s "$LAST_OPVER" ]; then echo "CheckTime:$CKTIME" >>$LAST_OPVER diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/CNAME b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/CNAME similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/CNAME rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/CNAME diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/img/ffac0fa1d89f15922b4594863b8b32e9.png b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/img/ffac0fa1d89f15922b4594863b8b32e9.png similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/img/ffac0fa1d89f15922b4594863b8b32e9.png rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/img/ffac0fa1d89f15922b4594863b8b32e9.png diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/index.html b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/index.html similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/index.html rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/index.html diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/js/1.bundle.01d1a3c82895ade21dbf.min.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/js/1.bundle.01d1a3c82895ade21dbf.min.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/js/1.bundle.01d1a3c82895ade21dbf.min.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/js/1.bundle.01d1a3c82895ade21dbf.min.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/js/1.bundle.01d1a3c82895ade21dbf.min.js.LICENSE.txt b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/js/1.bundle.01d1a3c82895ade21dbf.min.js.LICENSE.txt similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/js/1.bundle.01d1a3c82895ade21dbf.min.js.LICENSE.txt rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/js/1.bundle.01d1a3c82895ade21dbf.min.js.LICENSE.txt diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/js/bundle.01d1a3c82895ade21dbf.min.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/js/bundle.01d1a3c82895ade21dbf.min.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/js/bundle.01d1a3c82895ade21dbf.min.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/js/bundle.01d1a3c82895ade21dbf.min.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/main.01d1a3c82895ade21dbf.css b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/main.01d1a3c82895ade21dbf.css similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/dashboard/main.01d1a3c82895ade21dbf.css rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/dashboard/main.01d1a3c82895ade21dbf.css diff --git a/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash.sh new file mode 100644 index 0000000000..935e71fc73 --- /dev/null +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash.sh @@ -0,0 +1,324 @@ +#!/bin/bash +. /lib/functions.sh +. /usr/share/openclash/openclash_ps.sh + +status=$(unify_ps_status "openclash.sh") +[ "$status" -gt 3 ] && exit 0 + +START_LOG="/tmp/openclash_start.log" +LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") +LOG_FILE="/tmp/openclash.log" +CFG_FILE="/tmp/config.yaml" +CRON_FILE="/etc/crontabs/root" +CONFIG_PATH=$(uci get openclash.config.config_path 2>/dev/null) +servers_update=$(uci get openclash.config.servers_update 2>/dev/null) +dns_port=$(uci get openclash.config.dns_port 2>/dev/null) +enable_redirect_dns=$(uci get openclash.config.enable_redirect_dns 2>/dev/null) +disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null) +if_restart=0 + +urlencode() { + local data + if [ "$#" -eq 1 ]; then + data=$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$1" "") + if [ ! -z "$data" ]; then + echo "$(echo ${data##/?} |sed 's/\//%2f/g' |sed 's/:/%3a/g' |sed 's/?/%3f/g' |sed 's/(/%28/g' |sed 's/)/%29/g' |sed 's/\^/%5e/g' |sed 's/=/%3d/g' |sed 's/|/%7c/g')" + fi + fi +} + +kill_watchdog() { + + watchdog_pids=$(unify_ps_pids "openclash_watchdog.sh") + for watchdog_pid in $watchdog_pids; do + kill -9 "$watchdog_pid" >/dev/null 2>&1 + done +} + +config_download() +{ +if [ -n "$subscribe_url_param" ]; then + curl -sL --connect-timeout 10 --retry 2 https://api.dler.io/sub"$subscribe_url_param" -o "$CFG_FILE" >/dev/null 2>&1 + if [ "$?" -ne 0 ]; then + curl -sL --connect-timeout 10 --retry 2 https://subcon.dlj.tf/sub"$subscribe_url_param" -o "$CFG_FILE" >/dev/null 2>&1 + fi +else + curl -sL --connect-timeout 10 --retry 2 --user-agent "clash" "$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1 +fi +} + +config_cus_up() +{ + if [ -z "$CONFIG_PATH" ]; then + CONFIG_PATH="/etc/openclash/config/$(ls -lt /etc/openclash/config/ | grep -E '.yaml|.yml' | head -n 1 |awk '{print $9}')" + uci set openclash.config.config_path="$CONFIG_PATH" + uci commit openclash + fi + if [ -z "$subscribe_url_param" ]; then + if [ "$servers_update" -eq 1 ] || [ ! -z "$keyword" ] || [ ! -z "$ex_keyword" ]; then + echo "配置文件【$name】替换成功,开始挑选节点..." >$START_LOG + uci set openclash.config.config_update_path="/etc/openclash/config/$name.yaml" + uci set openclash.config.servers_if_update=1 + uci commit openclash + /usr/share/openclash/yml_groups_get.sh + uci set openclash.config.servers_if_update=1 + uci commit openclash + /usr/share/openclash/yml_groups_set.sh + if [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then + if_restart=1 + fi + echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE + echo "配置文件【$name】更新成功!" >$START_LOG + sleep 3 + echo "" >$START_LOG + elif [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then + echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE + echo "配置文件【$name】更新成功!" >$START_LOG + sleep 3 + if_restart=1 + else + echo "配置文件【$name】更新成功!" >$START_LOG + echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE + sleep 3 + echo "" >$START_LOG + fi + else + if [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then + echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE + echo "配置文件【$name】更新成功!" >$START_LOG + sleep 3 + if_restart=1 + else + echo "配置文件【$name】更新成功!" >$START_LOG + echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE + sleep 3 + echo "" >$START_LOG + fi + fi + + rm -rf /tmp/Proxy_Group 2>/dev/null +} + +config_su_check() +{ + echo "配置文件下载成功,检查是否有更新..." >$START_LOG + sed -i 's/! //g' "$CFG_FILE" >/dev/null 2>&1 + if [ -f "$CONFIG_FILE" ]; then + cmp -s "$BACKPACK_FILE" "$CFG_FILE" + if [ "$?" -ne 0 ]; then + echo "配置文件【$name】有更新,开始替换..." >$START_LOG + mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null + cp "$CONFIG_FILE" "$BACKPACK_FILE" + config_cus_up + else + echo "配置文件【$name】没有任何更新,停止继续操作..." >$START_LOG + rm -rf "$CFG_FILE" + echo "${LOGTIME} Updated Config【$name】 No Change, Do Nothing" >>$LOG_FILE + sleep 5 + echo "" >$START_LOG + fi + else + echo "配置文件下载成功,本地没有配置文件,开始创建 ..." >$START_LOG + mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null + cp "$CONFIG_FILE" "$BACKPACK_FILE" + config_cus_up + fi +} + +config_encode() +{ + /usr/share/openclash/yml_field_name_ch.sh "$CFG_FILE" +} + +config_error() +{ + echo "配置文件【$name】下载失败,请检查网络或稍后再试!" >$START_LOG + echo "${LOGTIME} Config 【$name】Update Error" >>$LOG_FILE + rm -rf "$CFG_FILE" 2>/dev/null + sleep 5 + echo "" >$START_LOG +} + +change_dns() +{ + if pidof clash >/dev/null; then + if [ "$enable_redirect_dns" -ne 0 ]; then + uci del dhcp.@dnsmasq[-1].server >/dev/null 2>&1 + uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1 + uci delete dhcp.@dnsmasq[0].resolvfile >/dev/null 2>&1 + uci set dhcp.@dnsmasq[0].noresolv=1 >/dev/null 2>&1 + [ "$disable_masq_cache" -eq 1 ] && { + uci set dhcp.@dnsmasq[0].cachesize=0 >/dev/null 2>&1 + } + uci commit dhcp + /etc/init.d/dnsmasq restart >/dev/null 2>&1 + fi + nohup /usr/share/openclash/openclash_watchdog.sh & + fi +} + +config_download_direct() +{ + if pidof clash >/dev/null; then + echo "配置文件【$name】下载失败,尝试不使用代理下载配置文件..." >$START_LOG + + kill_watchdog + + uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1 + uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto >/dev/null 2>&1 + uci set dhcp.@dnsmasq[0].noresolv=0 >/dev/null 2>&1 + uci delete dhcp.@dnsmasq[0].cachesize >/dev/null 2>&1 + uci commit dhcp + /etc/init.d/dnsmasq restart >/dev/null 2>&1 + sleep 3 + + config_download + + if [ "$?" -eq 0 ] && [ -s "$CFG_FILE" ]; then + change_dns + config_su_check + else + change_dns + config_error + fi + else + config_error + fi +} + +server_key_match() +{ + local key_match key_word + + if [ -n "$(echo "$1" |grep "^ \{0,\}$")" ] || [ -n "$(echo "$1" |grep "^\t\{0,\}$")" ]; then + return + fi + + if [ -n "$(echo "$1" |grep "&")" ]; then + key_word=$(echo "$1" |sed 's/&/ /g') + for k in $key_word + do + if [ -z "$k" ]; then + continue + fi + k="(?=.*$k)" + key_match="$key_match$k" + done + key_match="^($key_match).*" + else + if [ -n "$1" ]; then + key_match="($1)" + fi + fi + + if [ "$2" = "keyword" ]; then + if [ -z "$key_match_param" ]; then + key_match_param="$key_match" + else + key_match_param="$key_match_param|$key_match" + fi + elif [ "$2" = "ex_keyword" ]; then + if [ -z "$key_ex_match_param" ]; then + key_ex_match_param="$key_match" + else + key_ex_match_param="$key_ex_match_param|$key_match" + fi + fi +} + +sub_info_get() +{ + local section="$1" subscribe_url template_path subscribe_url_param template_path_encode key_match_param key_ex_match_param + config_get_bool "enabled" "$section" "enabled" "1" + config_get "name" "$section" "name" "" + config_get "sub_convert" "$section" "sub_convert" "" + config_get "address" "$section" "address" "" + config_get "keyword" "$section" "keyword" "" + config_get "ex_keyword" "$section" "ex_keyword" "" + config_get "emoji" "$section" "emoji" "" + config_get "udp" "$section" "udp" "" + config_get "skip_cert_verify" "$section" "skip_cert_verify" "" + config_get "sort" "$section" "sort" "" + config_get "template" "$section" "template" "" + config_get "node_type" "$section" "node_type" "" + config_get "custom_template_url" "$section" "custom_template_url" "" + + if [ "$enabled" -eq 0 ]; then + return + fi + + if [ -z "$address" ]; then + return + fi + + if [ -z "$name" ]; then + name="config" + CONFIG_FILE="/etc/openclash/config/config.yaml" + BACKPACK_FILE="/etc/openclash/backup/config.yaml" + else + CONFIG_FILE="/etc/openclash/config/$name.yaml" + BACKPACK_FILE="/etc/openclash/backup/$name.yaml" + fi + + if [ "$sub_convert" -eq 0 ]; then + subscribe_url=$address + elif [ "$sub_convert" -eq 1 ] && [ -n "$template" ]; then + subscribe_url=$(urlencode "$address") + if [ "$template" != "0" ]; then + template_path=$(grep "^$template," /usr/share/openclash/res/sub_ini.list |awk -F ',' '{print $3}' 2>/dev/null) + else + template_path=$custom_template_url + fi + if [ -n "$template_path" ]; then + template_path_encode=$(urlencode "$template_path") + if [ ! -z "$keyword" ] || [ ! -z "$ex_keyword" ]; then + config_list_foreach "$section" "keyword" server_key_match "keyword" + config_list_foreach "$section" "ex_keyword" server_key_match "ex_keyword" + [ -n "$key_match_param" ] && key_match_param=$(urlencode "$key_match_param") + [ -n "$key_ex_match_param" ] && key_ex_match_param=$(urlencode "$key_ex_match_param") + fi + subscribe_url_param="?target=clash&new_name=true&url=$subscribe_url&config=$template_path_encode&include=$key_match_param&exclude=$key_ex_match_param&emoji=$emoji&list=false&sort=$sort&udp=$udp&scv=$skip_cert_verify&append_type=$node_type&fdn=true" + else + subscribe_url=$address + fi + else + subscribe_url=$address + fi + + echo "开始更新配置文件【$name】..." >$START_LOG + + config_download + + if [ "$?" -eq 0 ] && [ -s "$CFG_FILE" ]; then + config_encode + if [ -n "$(grep "^ \{0,\}proxy-groups:" "$CFG_FILE")" ]; then + if [ -n "$(grep "^ \{0,\}Proxy:" "$CFG_FILE" 2>/dev/null)" ] || [ -n "$(grep "^ \{0,\}proxy-providers:" "$CFG_FILE" 2>/dev/null)" ]; then + if [ -n "$(grep "^ \{0,\}rules:" "$CFG_FILE" 2>/dev/null)" ] || [ -n "$(grep "^ \{0,\}script:" "$CFG_FILE" 2>/dev/null)" ]; then + config_su_check + else + config_download_direct + fi + else + config_download_direct + fi + else + config_download_direct + fi + else + config_download_direct + fi +} + +#分别获取订阅信息进行处理 +config_load "openclash" +config_foreach sub_info_get "config_subscribe" +uci delete openclash.config.config_update_path >/dev/null 2>&1 +uci commit openclash + +if [ "$if_restart" -eq 1 ]; then + /etc/init.d/openclash restart >/dev/null 2>&1 +else + sed -i '/openclash.sh/d' $CRON_FILE 2>/dev/null + [ "$(uci get openclash.config.auto_update 2>/dev/null)" -eq 1 ] && [ "$(uci get openclash.config.config_auto_update_mode 2>/dev/null)" -ne 1 ] && echo "0 $(uci get openclash.config.auto_update_time 2>/dev/null) * * $(uci get openclash.config.config_update_week_time 2>/dev/null) /usr/share/openclash/openclash.sh" >> $CRON_FILE + /etc/init.d/cron restart +fi diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_chnroute.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_chnroute.sh old mode 100755 new mode 100644 similarity index 90% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_chnroute.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_chnroute.sh index c215562c38..8e42219131 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_chnroute.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_chnroute.sh @@ -18,7 +18,7 @@ if pidof clash >/dev/null; then curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/Extra/ChinaIP.yaml -o /tmp/ChinaIP.yaml >/dev/null 2>&1 else - curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/Extra/ChinaIP.yaml -o /tmp/ChinaIP.yaml >/dev/null 2>&1 + curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/DivineEngine/Profiles@master/Clash/RuleSet/Extra/ChinaIP.yaml -o /tmp/ChinaIP.yaml >/dev/null 2>&1 fi if [ "$?" -eq "0" ] && [ -s "/tmp/ChinaIP.yaml" ]; then echo "大陆IP白名单下载成功,检查版本是否更新..." >$START_LOG @@ -34,7 +34,7 @@ mv /tmp/ChinaIP.yaml /etc/openclash/rule_provider/ChinaIP.yaml >/dev/null 2>&1 echo "删除下载缓存..." >$START_LOG rm -rf /tmp/ChinaIP.yaml >/dev/null 2>&1 - rm -rf /etc/openclash/china_ip_route.ipset >/dev/null 2>&1 + rm -rf /usr/share/openclash/res/china_ip_route.ipset >/dev/null 2>&1 [ "$china_ip_route" -eq 1 ] && /etc/init.d/openclash restart echo "大陆IP白名单更新成功!" >$START_LOG echo "${LOGTIME} Chnroute Lists Update Successful" >>$LOG_FILE diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_core.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_core.sh old mode 100755 new mode 100644 similarity index 89% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_core.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_core.sh index b5590cda2b..813de8ac5a --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_core.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_core.sh @@ -10,6 +10,7 @@ en_mode=$(uci get openclash.config.en_mode 2>/dev/null) CPU_MODEL=$(uci get openclash.config.core_version 2>/dev/null) HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null) PROXY_ADDR=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null) +[ ! -f "/tmp/clash_last_version" ] && /usr/share/openclash/clash_version.sh 2>/dev/null mkdir -p /etc/openclash/core [ -s "/tmp/openclash.auth" ] && { @@ -46,7 +47,6 @@ case $CORE_TYPE in fi esac -[ -z "$(pidof clash)" ] && if_restart=0 [ -n "$2" ] || [ "$1" = "one_key_update" ] && if_restart=0 if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then @@ -69,15 +69,15 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then case $CORE_TYPE in "Tun") echo "正在下载【Tun】版本内核,如下载失败请尝试手动下载并上传..." >$START_LOG - curl -sL -m 30 --retry 2 https://github.com/vernesong/OpenClash/releases/download/TUN-Premium/clash-"$CPU_MODEL"-"$CORE_LV".gz -o /tmp/clash_tun.gz >/dev/null 2>&1 + curl -sL -m 30 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/core-lateset/premium/clash-"$CPU_MODEL"-"$CORE_LV".gz -o /tmp/clash_tun.gz >/dev/null 2>&1 ;; "Game") echo "正在下载【Game】版本内核,如下载失败请尝试手动下载并上传..." >$START_LOG - curl -sL -m 30 --retry 2 https://github.com/vernesong/OpenClash/releases/download/TUN/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_game.tar.gz >/dev/null 2>&1 + curl -sL -m 30 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/core-lateset/game/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_game.tar.gz >/dev/null 2>&1 ;; *) echo "正在下载【Dev】版本内核,如下载失败请尝试手动下载并上传..." >$START_LOG - curl -sL -m 30 --retry 2 https://github.com/vernesong/OpenClash/releases/download/Clash/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1 + curl -sL -m 30 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/core-lateset/dev/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1 esac fi if [ "$?" -eq "0" ]; then @@ -130,8 +130,10 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then fi if [ "$if_restart" -eq 1 ]; then - kill -9 "$(pidof clash|sed 's/$//g')" 2>/dev/null - /etc/init.d/openclash stop + clash_pids=$(pidof clash|sed 's/$//g') + for clash_pid in $clash_pids; do + kill -9 "$clash_pid" 2>/dev/null + done fi case $CORE_TYPE in @@ -151,7 +153,7 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then uci set openclash.config.config_reload=0 uci commit openclash fi - [ "$if_restart" -eq 1 ] && /etc/init.d/openclash start + [ "$if_restart" -eq 1 ] && /etc/init.d/openclash restart echo "" >$START_LOG else echo "【"$CORE_TYPE"】版本内核更新失败,请确认设备闪存空间足够后再试!" >$START_LOG diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_custom_domain_dns.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_custom_domain_dns.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_custom_domain_dns.sh diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_debug.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh old mode 100755 new mode 100644 similarity index 98% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_debug.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh index 5aae05b8e6..d807010751 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_debug.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh @@ -29,7 +29,7 @@ core_version=$(/etc/openclash/core/clash -v 2>/dev/null |awk -F ' ' '{print $2}' core_tun_version=$(/etc/openclash/core/clash_tun -v 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null) core_game_version=$(/etc/openclash/core/clash_game -v 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null) servers_update=$(uci get openclash.config.servers_update 2>/dev/null) -op_version=$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null) +op_version=$(sed -n 1p /usr/share/openclash/res/openclash_version 2>/dev/null) china_ip_route=$(uci get openclash.config.china_ip_route 2>/dev/null) if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then @@ -275,7 +275,8 @@ else /usr/share/openclash/yml_field_cut.sh "$nameserver_len" "$DNS_FILE" "$CONFIG_FILE" fi 2>/dev/null - cat "$CONFIG_FILE" "$DNS_FILE" >> "$DEBUG_LOG" + rm -rf /tmp/yaml_general 2>/dev/null + cat "$CHANGE_FILE" "$DNS_FILE" >> "$DEBUG_LOG" fi #firewall diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_download_rule_list.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh old mode 100755 new mode 100644 similarity index 74% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_download_rule_list.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh index 9b883eae5f..ee6c6ceea3 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_download_rule_list.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh @@ -1,12 +1,12 @@ #!/bin/sh RULE_FILE_NAME="$1" - if [ -z "$(grep "$RULE_FILE_NAME" /etc/openclash/rule_providers.list 2>/dev/null)" ]; then - DOWNLOAD_PATH=$(grep -F "$RULE_FILE_NAME" /etc/openclash/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null) + if [ -z "$(grep "$RULE_FILE_NAME" /usr/share/openclash/res/rule_providers.list 2>/dev/null)" ]; then + DOWNLOAD_PATH=$(grep -F "$RULE_FILE_NAME" /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null) RULE_FILE_DIR="/etc/openclash/game_rules/$RULE_FILE_NAME" RULE_TYPE="game" else DOWNLOAD_PATH=$(echo "$RULE_FILE_NAME" |awk -F ',' '{print $1$2}' 2>/dev/null) - RULE_FILE_NAME=$(grep -F "$RULE_FILE_NAME" /etc/openclash/rule_providers.list |awk -F ',' '{print $NF}' 2>/dev/null) + RULE_FILE_NAME=$(grep -F "$RULE_FILE_NAME" /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $NF}' 2>/dev/null) RULE_FILE_DIR="/etc/openclash/rule_provider/$RULE_FILE_NAME" RULE_TYPE="provider" fi @@ -28,13 +28,13 @@ if pidof clash >/dev/null; then curl -sL --connect-timeout 5 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1 else - curl -sL --connect-timeout 5 --retry 2 https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1 + curl -sL --connect-timeout 5 --retry 2 https://cdn.jsdelivr.net/gh/FQrabbit/SSTap-Rule@master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1 fi elif [ "$RULE_TYPE" = "provider" ]; then if pidof clash >/dev/null; then curl -sL --connect-timeout 5 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1 else - curl -sL --connect-timeout 5 --retry 2 https://raw.githubusercontent.com/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1 + curl -sL --connect-timeout 5 --retry 2 https://cdn.jsdelivr.net/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" >/dev/null 2>&1 fi fi diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_fake_filter.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_fake_filter.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_fake_filter.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_fake_filter.sh diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_history_get.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_history_get.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_history_set.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_history_set.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_history_set.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_history_set.sh diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_ipdb.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_ipdb.sh old mode 100755 new mode 100644 similarity index 93% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_ipdb.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_ipdb.sh index 6a6ae9ab86..c09b3172bb --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_ipdb.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_ipdb.sh @@ -16,7 +16,7 @@ if pidof clash >/dev/null; then curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/alecthw/mmdb_china_ip_list/release/Country.mmdb -o /tmp/Country.mmdb >/dev/null 2>&1 else - curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/alecthw/mmdb_china_ip_list/release/Country.mmdb -o /tmp/Country.mmdb >/dev/null 2>&1 + curl -sL --connect-timeout 10 --retry 2 http://www.ideame.top/mmdb/Country.mmdb -o /tmp/Country.mmdb >/dev/null 2>&1 fi if [ "$?" -eq "0" ] && [ -s "/tmp/Country.mmdb" ]; then echo "GEOIP 数据库下载成功,检查数据库版本是否更新..." >$START_LOG diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_ps.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_ps.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_ps.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_ps.sh diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_rule.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh old mode 100755 new mode 100644 similarity index 86% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_rule.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh index 47cead78ce..50802fce16 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_rule.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_rule.sh @@ -24,14 +24,14 @@ if pidof clash >/dev/null; then curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/lhie1/Rules/master/Clash/Rule.yaml -o /tmp/rules.yaml >/dev/null 2>&1 else - curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/lhie1/Rules/master/Clash/Rule.yaml -o /tmp/rules.yaml >/dev/null 2>&1 + curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/lhie1/Rules@master/Clash/Rule.yaml -o /tmp/rules.yaml >/dev/null 2>&1 fi sed -i '1i rules:' /tmp/rules.yaml elif [ "$RUlE_SOURCE" = "ConnersHua" ]; then if pidof clash >/dev/null; then curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/Global.yaml -o /tmp/rules.yaml >/dev/null 2>&1 else - curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/Global.yaml -o /tmp/rules.yaml >/dev/null 2>&1 + curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/DivineEngine/Profiles@master/Clash/Global.yaml -o /tmp/rules.yaml >/dev/null 2>&1 fi sed -i -n '/^rule-providers:/,$p' /tmp/rules.yaml 2>/dev/null sed -i "s/# - RULE-SET,ChinaIP,DIRECT/- RULE-SET,ChinaIP,DIRECT/g" /tmp/rules.yaml 2>/dev/null @@ -40,7 +40,7 @@ if pidof clash >/dev/null; then curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/China.yaml -o /tmp/rules.yaml >/dev/null 2>&1 else - curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/China.yaml -o /tmp/rules.yaml >/dev/null 2>&1 + curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/DivineEngine/Profiles@master/Clash/China.yaml -o /tmp/rules.yaml >/dev/null 2>&1 fi sed -i -n '/^rules:/,$p' /tmp/rules.yaml 2>/dev/null fi @@ -66,13 +66,14 @@ #合并 cat "$OTHER_RULE_PROVIDER_FILE" "$OTHER_SCRIPT_FILE" "$OTHER_RULE_FILE" > "/tmp/rules.yaml" 2>/dev/null rm -rf /tmp/other_rule* 2>/dev/null + rm -rf /tmp/yaml_general 2>/dev/null echo "检查下载的规则文件是否有更新..." >$START_LOG - cmp -s /etc/openclash/"$RUlE_SOURCE".yaml /tmp/rules.yaml + cmp -s /usr/share/openclash/res/"$RUlE_SOURCE".yaml /tmp/rules.yaml if [ "$?" -ne "0" ]; then echo "检测到下载的规则文件有更新,开始替换..." >$START_LOG - mv /tmp/rules.yaml /etc/openclash/"$RUlE_SOURCE".yaml >/dev/null 2>&1 - sed -i '/^rules:/a\##updated' /etc/openclash/"$RUlE_SOURCE".yaml >/dev/null 2>&1 + mv /tmp/rules.yaml /usr/share/openclash/res/"$RUlE_SOURCE".yaml >/dev/null 2>&1 + sed -i '/^rules:/a\##updated' /usr/share/openclash/res/"$RUlE_SOURCE".yaml >/dev/null 2>&1 echo "替换成功,重新加载 OpenClash 应用新规则..." >$START_LOG status=$(unify_ps_prevent) while ( [ "$status" -gt 1 ] ) diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_update.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_update.sh old mode 100755 new mode 100644 similarity index 92% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_update.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index 2119088538..1f0f5b237f --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_update.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -20,7 +20,7 @@ LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") LOG_FILE="/tmp/openclash.log" LAST_OPVER="/tmp/openclash_last_version" LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |sed "s/^v//g") -OP_CV=$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +OP_CV=$(sed -n 1p /usr/share/openclash/res/openclash_version 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 '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null) PROXY_ADDR=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null) @@ -33,7 +33,7 @@ if [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 ] && [ -f "$LAST_OPVER" ]; then if pidof clash >/dev/null; then curl -sL -m 30 --retry 5 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://github.com/vernesong/OpenClash/releases/download/v"$LAST_VER"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk >/dev/null 2>&1 else - curl -sL -m 30 --retry 5 https://github.com/vernesong/OpenClash/releases/download/v"$LAST_VER"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk >/dev/null 2>&1 + curl -sL -m 30 --retry 5 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk >/dev/null 2>&1 fi if [ "$?" -eq "0" ] && [ -s "/tmp/openclash.ipk" ]; then echo "OpenClash-$LAST_VER 下载成功,开始更新,更新过程请不要刷新页面和进行其他操作..." >$START_LOG diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_version.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_version.sh old mode 100755 new mode 100644 similarity index 84% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_version.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_version.sh index c193279b6d..e6521dcaf5 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_version.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_version.sh @@ -1,7 +1,7 @@ #!/bin/sh CKTIME=$(date "+%Y-%m-%d-%H") LAST_OPVER="/tmp/openclash_last_version" -OP_CV=$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +OP_CV=$(sed -n 1p /usr/share/openclash/res/openclash_version 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 '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null) PROXY_ADDR=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null) @@ -15,7 +15,7 @@ if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{prin if pidof clash >/dev/null; then curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1 else - curl -sL --connect-timeout 10 --retry 2 "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1 + curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/version -o $LAST_OPVER >/dev/null 2>&1 fi if [ "$?" -eq "0" ] && [ -s "$LAST_OPVER" ]; 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) diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_watchdog.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_watchdog.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/ConnersHua.yaml b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/ConnersHua.yaml similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/ConnersHua.yaml rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/ConnersHua.yaml diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/ConnersHua_return.yaml b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/ConnersHua_return.yaml similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/ConnersHua_return.yaml rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/ConnersHua_return.yaml diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/china_ip_route.ipset b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/china_ip_route.ipset similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/china_ip_route.ipset rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/china_ip_route.ipset diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/default.yaml b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/default.yaml similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/default.yaml rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/default.yaml diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules.list b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/game_rules.list similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules.list rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/game_rules.list diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/lhie1.yaml b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml similarity index 99% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/lhie1.yaml rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml index 9cb828d7a1..24d307b562 100644 --- a/package/ctcgfw/luci-app-openclash/files/etc/openclash/lhie1.yaml +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/lhie1.yaml @@ -334,9 +334,9 @@ script: "PayPal": "PayPal", "Microsoft": "Microsoft", "PROXY": "Proxy", + "Apple": "Apple", "Domestic": "Domestic", - "Domestic IPs": "Domestic", - "Apple": "Apple" + "Domestic IPs": "Domestic" } port = int(metadata["dst_port"]) @@ -353,12 +353,12 @@ script: return "DIRECT" code = ctx.geoip(ip) - if code == "CN": - return "Domestic" - if code == "LAN": return "DIRECT" + if code == "CN": + return "Domestic" + return "Others" rules: @@ -414,9 +414,11 @@ rules: - RULE-SET,Microsoft,Microsoft - RULE-SET,PROXY,Proxy + +- RULE-SET,Apple,Apple + - RULE-SET,Domestic,Domestic - RULE-SET,Domestic IPs,Domestic -- RULE-SET,Apple,Apple - GEOIP,CN,Domestic - MATCH,Others diff --git a/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/openclash_version b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/openclash_version new file mode 100644 index 0000000000..e0f6a78e2b --- /dev/null +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/openclash_version @@ -0,0 +1,2 @@ +v0.40.6-beta +data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXMAAAAqCAMAAAB2kksrAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ4IDc5LjE2NDAzNiwgMjAxOS8wOC8xMy0wMTowNjo1NyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIxLjAgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkE3OEM5N0E3RkREMjExRUFBQkI2QjUzMzYzN0Q0MjY4IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkE3OEM5N0E4RkREMjExRUFBQkI2QjUzMzYzN0Q0MjY4Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6QTc4Qzk3QTVGREQyMTFFQUFCQjZCNTMzNjM3RDQyNjgiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6QTc4Qzk3QTZGREQyMTFFQUFCQjZCNTMzNjM3RDQyNjgiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz6fzmK7AAADAFBMVEWTvNMvfKlFmsq6urqiwNIFXI46lcqizOUGZp0HVYMFbamCgoKStcienp7a2tqlpaUJeLgHX5F4eHhXpdLf398kapJ2tdrn5+cGcKw/Pz/GxsaGv9+hoaEIW4rOzs5TiqqDs85paWljlbHR5vJlnbyRkZFxcXG/v79GRkasrKy1tbXR4uxHjLQEU4DKyspmrNViYmKz1uqEhISSuM40dJoEYJVLS0tDQ0Pg4OCLi4sGWYhzobsIZJl2dnbAwMAFZZqcnJxFgKIJdbQKaqHCwsJBQUGx0OFCQkIJcq4mcJsGdLKUxuJHnM1sbGy2trYYYo2jxdnw9feXl5dFkb0IaJ7S0tLB1eDQ0NBlZWUmicKNjY1Jns42kcaTxOCDrcWvr68FaaJgYGBvb28dh8ODqsEZdaoGVYKUlJQhhL0JbKUEYpgHbKXB2edKns8FcrAJWIVDfqArjsdyn7h0dHSyytkXgb5ortcahMFFhamJweIwk8t0sdVFia81h7UIYZURgsMCc7QBcrNRUVFUVFRVVVVSUlIFdrcLfL1WVlYHeLkKe7wDdbUOf8AEdrYOgMAEdbYDdLQDdLUSg8NXV1cSg8QShMQThMUAcrIGd7gOf78Nfr8Nfr4Mfb4Mfb0Je7sJersJeroIebk6OjqqqqrU1NTV1dVISEirq6s9PT2pqak7Ozvw9/uAgIB+fn48PDzC3u5JSUmBgYGEvN3q6uqEvd3B3u5MTEz19fXz8/Ph7/f09PR/f3/B3e2CqcAGVYGDvNzv9PeFvt6hv9CJiYlkq9Pg6u/B3e6ErMLo6OhVos+EtNAEVYMHVoQFZ6DW1tbg6vALdK9Hm8wUXolInc2Dq8LA1N8lhLoFa6bD3+/R3+hInc7g7vYLermGhoYnhryEu9qjzuYVaJcLb6gKebjB1+MGdbSDr8jv9voZg8DC3+/g7/eButoJcKyiyN4vkstTU1MPgMEQgcJZWVlaWlpfX19bW1tcXFxNTU1eXl5PT09QUFBYWFhdXV1OTk7///////8FtINTAAABAHRSTlP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AU/cHJQAADBdJREFUeNrsWAlUVNcZftGAFhgIgwojBhdEB+IYxDgDaqQuGMWg0SDVqtGoidHGmLhmta2IDLRJF7qYNFEZYAAnLIqsUUPcF0yM0Rizmn0zndbagBg++t/7lnlvAMOpOZ4zc/zOybv/8t3vf++7w5sxQmtr9fz+l7wBf/MAPPmEo7VVaI1fdck78FePwJORrUL1oCYvwV88A086hPneYnnTnz0ETwiDfvAW/NpD8E/hhxueX294kef/9hQI33sNbnh+/fEvT4HwX6/BDc+vP57zFAj/8Rr83lPQruf+0dHRv1z407syy99/lpIs9PfvzB69v76T6s93hOd8e4X38m2/t3z5IilaFBIeHrKoHcpja8PDe7k1whH+/P8N4aI7YqdWgyN+RuzFa4R/tL8mr8YMJR6DoZ2ReB2vd3LYCx1g0Tv8cd5Z1E5vCrBcjNY6GMmx1p3hK+5erq2S5x2Ne2F5+PIXroo2nusrgMBCnS6CBvlfq+fRiFan1sGIV44WiPppPf9HB/gatw0cMvA2fN22tZYecg6P5gDCkCGCnKoZ028+fPicW/k1vNbRuKv2OIQrWsTGo2ahgcGsq/G/co0gzzX5ICBFCmegJqMzEkaDsZPDXmwfa/HGtBUrVkybjrXurRBMJ5N5WItRRFpxGLUaBh3FYVZfcVK7k3x9sSNcrcchtHGpJtZgKTebjQaDtX9nvdX7a47H3z+lfc/toegjhQWY2iKR9e0rxrp5nqIdEiszZLzUPoZhVPAnJz8JPoxhbh1fx/Q7yHMeYvqK1JMnU+lkfNWUWrL81tHjxwef1G4lX1966bE5au4cOeM9pajhiHD3vBo6wwYeWc0sKMAOnu1AgXSdEQ8UXilEYWwhvYZYt5B9AVQXch4Qy9OCWJ6IUNQ36FAhGQgstJJxY1i/IuGKRvxKnwpeZpKFEIUTeGlMrMRM4Runqm89U0IIaqWoFiGZmQ48/j7F7z8OR6YG6xwYsAJ4l8W9kLaUrePT0EtFCcEbDeMz2wH5GlJLN1AbImmdh5zJD52Z6VvLA8drbpuFHA12ADkZcpKenpNDnkuNAn6NL2AyhTmFGMpN2JFDb6PqrkFdqzGG8cgpVEcE0jcwJQUVqCgguPQvAnoe9EGoMSdHX42K+UG9gRka8alA16CgHnQvOTSokPFnAL2D5lcgPpYzq6txJCKUTFfdu/JMtXiLr77M/HXAAzx7AFinsTwSo0aOg8idguG8+P5wTFFxziNg/Lp33/Vtx3P6yn04DdJ2XwdqhWMTgdszM8tqUVtGyMx8C7X3HDv2nUMj2dZzssKsKbh7jro+VUXlsWQFjuw3FG38PicGgeVFRUXlNbiTe87KRbE8K9JBR60il5w5EDE8iEdeM7tOZf0UVKvF6W8ghZU3RiieU+kDNiSQnywxZw6i9AO+T0a2hAuncZ4H53H6QvbdwCSeTQLuzlZhGG5uWJotFctwTKweQ5mKU4aAYfyj2itbi11w9JvW0DDtHL5haSRpEcbCkZ3dcBqnWZKd/eFYtjbQ+2udZrNg1aAQEU5NoQAv8/VlFPDrkcZSQjkRextY1Ey/P9INxnKjIQoxxADMpQZLUukEFFqtlj7oYyG45JxxqGPrnfTCsVoTEFpKey3ETlCJvwyUGsvLk0pL+R2RkHUMJpRaaAg7DsYMNNAUQ2mNdHccyjNNBr6i5SsHJmczzz/l1U+1np9HGlnu8vwjsfyRxnOy+5tux46dg3SKKs/va2gIDm7oCfhmZ7NX0K3dx69vWI2Q7OAv8EUwgU65gX0VjB6Zpj3stp7PtF7V8whDebo13UlEnaGKPExPQGBSOrXSF3IGwMpWenEXKoap0Qhmr5X+OIzsmmdkxWbOVsT7A4NT2AFZFIkeiGKy6Uk14ulEWJoprYpQe75FRupq3E7L7VidumULeS6VyV6FQs1z09a7imXYJdZ3ocxFom6/9eyjOkCklYngtPtSb9my5RafN9ioKQgYzeiTFjOZXbLWuElb7t61a9jD9erBBGGjBnnooS2Q53wlz/l1plMmBsmBAsYAREIQ8ngzTyu3sWoCBtNSgagMJq4gTyV+md7n6DFY13+jIgHcKbYiJKao9gvp7ji2yhg3AJG0lKHvuK1b3wSkMvCmQtmK6T2DVUXyXKyT51tVLIy9dXRqqs/P0nCepxycJvLHpbGgzPUcu1w9ihxSVTWY4Oa5Hrj/qp4XKIeTJwcVeRxBugRujrrf1nOnHnX3kw4auXiBvFevEs8ojQvkt6pTea63Si7nqZgFas+3KVhfj7lbZuPgeoo/BKQq8KGLAhUqt237DjvF+k58t03NupevSxcz0raxIjhN4j/MgkpU7uTot/heVW8ecM/ApycHf4Y3t6khpGsBLNHk+XiFr68gX7kykBVyELhdQhLfr+4rLBcsNTRhMCaUc/Fiea9dLW6hQkoU/SxZJUvUYL/Y6gGdiinfHUeugl8FoFvuTiz2o/gCfcp4kT7wF1yUtM8qOYDIynm5uf1QKdYr0S9XxcIBMRD7D4qgiHwVG5F4im0KkFoPprp6a4CVe/dSLU26AxlunrdMRcUlObnUnz3V/qt7Tn8ZP9hFmDvjedVUDE2vQ1wGxUEIlbbaW9Ti6WYDO4dQtluUiECMeEv0gf9xz3N7wrHmPUxmYbLsG/0ET3Yx9kqgt8fe4NzcIXhPrDswRKXDzo5jGIRtublhIih/Fa/y+mzgGXYiB7tLCHP1ugB7ly0NS6Yj6aL13KlBhpPepE1ivL+uxOnsisEsbhqMfFpK+JWhGMViYAzFUKm2iv6j97mqrxN3a0A/dHSouYuF9GtdJxab+qvEV9FcZ6O9KJB1RaEPUNckyobaVcx8lLiEs1xIPINhWN2dxytxiK+RWMmWA4cOzaXFRwLwuE9iVlb3enRh3aOo57sOHZpH11tuAhg5a7YDT2epQb7ytRsOLsjKpR9KT4n1NbOzsp5CNx6T52+zde57orYCN8+dljj6lRyzv6SkmP5JUsIeD8UlJTF16MjzRvqgDyXiKl1FcRvPU0Dn1rREOyEUdYgx8/MqJnU6KdIvUYlTsL/J2b8YNZdkIUMgepAS8fWNnfA8mX5ooG8yjz8+iG6zs2Z3Q/3HolsaB6QsbCUcR8lyBxaHieXdbBm9D44DVI7EvkQ3zx3zjnY5cIj+TIjfPQB4lQ6nyzwHqT0Duq45kBV2EJEHuhztBvyI55dtKaHSV0uN7iI5FMPjI0s68txZpK+RNvy8jed2cbdmQksUVe6Xhunk77FBKvFBkmBNnF0WKjeK36qIK3J25PlmFXzqcTBYDE/cUc931t9xgqXMcxVRzo7vE/X3HZfKu9kSdkoum/zU8kxFFB0wkrJk0x75OebSQHHPZj9psHCbZuLmzUKGG8ptNr0uIiKiWG+zVWVkmG1xYyImxJU6dQnUnMWvDHqdXorMNmNc15n5XZc4jZTpdOp+iy1uQn7vPtoJVp1OZxFDo80Z1XtmfnScsUolXmWMi56Z3zvKWHpZGWSw0ZCZOqfNrL6NBN0sl676sRb03dP3rBh+PvLUqIm7J446dfxzlt67Z8/bKqKcnTA9Onz37uGPmhKl8kC+jjA9GnCIlUdoXCOVsX1vTjsT0FM8i2WmnjRjtzDgFKVhpgGrKyd+sXnzyJ4BZ84Mv8k0QDOxHc8zqopsIrYbmym18LjIaDOwHr+KbhnlDebt0gZWsdk0fXG3doCRKo2qmKNRJd4oCW4vdwk1G8RaeYb6NgzsYyFjkxrHTSPlMOy4ieF4GM8STSY/FU/JRnCSaYRc9uHr59qygkSxbDq+QJubwhQpZfCykZqJmzYJG9qC/X9cg8UsZfYkQ5J9Q4vRTrF4FTlmhd9sv8tguMvYwmKjUdtnu41a+Raj0ahKkmiWvVkj3my3GGhbs2YQGyLOcDHtUoFD81xnE88qcfKJYB+fE8li4peY+IjaPCXzW+bjs8xPKS9or6zAL9Hv7AhqKFKPsBnLFohDFlDc/Vkqsr1hmxZoJrbvuYfiWU+B0Ow1+IOnwIs8/52nQLjsNfiTp8CLPP+jp0CY1eIt+I2H4CEh6Ibn1xnfCnVe80H/rWfgoS+F1h6xjd4BD7E8slVoba0L8g7X/+4BeOjbL1tb/yfAAGWv8iqXf5G/AAAAAElFTkSuQmCC \ No newline at end of file diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_providers.list b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/etc/openclash/rule_providers.list rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/rule_providers.list diff --git a/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/sub_ini.list b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/sub_ini.list new file mode 100644 index 0000000000..3b492fa329 --- /dev/null +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/res/sub_ini.list @@ -0,0 +1,49 @@ +无Urltest,no_urltest.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/no_urltest.ini +带Urltest,urltest.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/urltest.ini +ConnersHua 神机规则 Basic,connershua_basic.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_basic.ini +ConnersHua 神机规则 Pro,connershua_pro.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_pro.ini +ConnersHua 神机规则 BacktoCN 回国专用,connershua_backtocn.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_backtocn.ini +lhie1 洞主规则(使用 Clash 分组规则),lhie1_clash.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/lhie1_clash.ini +lhie1 洞主规则完整版,lhie1_dler.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/lhie1_dler.ini +ACL4SSR 规则标准版,acl4ssr_standard.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/acl4ssr_standard.ini +ACL4SSR 规则 GFWList,acl4ssr_gfwlist.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/acl4ssr_gfwlist.ini +ACL4SSR 规则 AdblockPlus,ACL4SSR_AdblockPlus.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_AdblockPlus.ini +ACL4SSR 规则 BackCN,ACL4SSR_BackCN.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_BackCN.ini +ACL4SSR 规则 Mini,ACL4SSR_Mini.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Mini.ini +ACL4SSR 规则 Mini Fallback,ACL4SSR_Mini_Fallback.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Mini_Fallback.ini +ACL4SSR 规则 Mini MultiMode,ACL4SSR_Mini_MultiMode.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Mini_MultiMode.ini +ACL4SSR 规则 Mini NoAuto,ACL4SSR_Mini_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Mini_NoAuto.ini +ACL4SSR 规则 NoApple,ACL4SSR_NoApple.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoApple.ini +ACL4SSR 规则 NoAuto,ACL4SSR_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoAuto.ini +ACL4SSR 规则 NoAuto NoApple,ACL4SSR_NoAuto_NoApple.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoAuto_NoApple.ini +ACL4SSR 规则 NoAuto NoApple NoMicrosoft,ACL4SSR_NoAuto_NoApple_NoMicrosoft.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoAuto_NoApple_NoMicrosoft.ini +ACL4SSR 规则 NoMicrosoft,ACL4SSR_NoMicrosoft.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoMicrosoft.ini +ACL4SSR 规则 Online,ACL4SSR_Online.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online.ini +ACL4SSR 规则 Online AdblockPlus,ACL4SSR_Online_AdblockPlus.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_AdblockPlus.ini +ACL4SSR 规则 Online Full,ACL4SSR_Online_Full.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Full.ini +ACL4SSR 规则 Online Full AdblockPlus,ACL4SSR_Online_Full_AdblockPlus.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Full_AdblockPlus.ini +ACL4SSR 规则 Online Full Netflix,ACL4SSR_Online_Full_Netflix.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Full_Netflix.ini +ACL4SSR 规则 Online Full NoAuto,ACL4SSR_Online_Full_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Full_NoAuto.ini +ACL4SSR 规则 Online Mini,ACL4SSR_Online_Mini.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini.ini +ACL4SSR 规则 Online Mini AdblockPlus,ACL4SSR_Online_Mini_AdblockPlus.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini_AdblockPlus.ini +ACL4SSR 规则 Online Mini Fallback,ACL4SSR_Online_Mini_Fallback.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini_Fallback.ini +ACL4SSR 规则 Online Mini MultiMode,ACL4SSR_Online_Mini_MultiMode.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini_MultiMode.ini +ACL4SSR 规则 Online Mini NoAuto,ACL4SSR_Online_Mini_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini_NoAuto.ini +ACL4SSR 规则 Online NoAuto,ACL4SSR_Online_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_NoAuto.ini +ACL4SSR 规则 Online NoReject,ACL4SSR_Online_NoReject.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_NoReject.ini +ACL4SSR 规则 WithChinaIp,ACL4SSR_WithChinaIp.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_WithChinaIp.ini +ACL4SSR 规则 WithChinaIp WithGFW,ACL4SSR_WithChinaIp_WithGFW.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_WithChinaIp_WithGFW.ini +eHpo1 规则,ehpo1_main.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/ehpo1_main.ini +nzw9314 规则,nzw9314_custom.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/nzw9314_custom.ini +maicoo-l 规则,maicoo-l_custom.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/maicoo-l_custom.ini +rixCloud 官方规则,rixcloud_custom.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/rixcloud_custom.ini +Maying,maying_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/maying_optimized.ini +Nexitally,nexitally_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/nexitally_optimized.ini +贼船,zeichuan_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/zeichuan_optimized.ini +N3RO,n3ro_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/n3ro_optimized.ini +Scholar,scholar_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/scholar_optimized.ini +YToo,ytoo_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/ytoo_optimized.ini +DlerCloud Platinum 李哥定制规则,dlercloud_lige_platinum.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_platinum.ini +DlerCloud Gold 李哥定制规则,dlercloud_lige_gold.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_gold.ini +DlerCloud Silver 李哥定制规则,dlercloud_lige_silver.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_silver.ini +网易云解锁(仅规则分组),netease.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/netease.ini \ No newline at end of file diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/CNAME b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/CNAME similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/CNAME rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/CNAME diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/_headers b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/_headers similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/_headers rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/_headers diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js.LICENSE.txt b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js.LICENSE.txt similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js.LICENSE.txt rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js.LICENSE.txt diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.2738c7e31c47b68f8120.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.8bddcee27ca7cab56b00.css b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.8bddcee27ca7cab56b00.css similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.8bddcee27ca7cab56b00.css rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.8bddcee27ca7cab56b00.css diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.8bddcee27ca7cab56b00.css.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.8bddcee27ca7cab56b00.css.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/app.8bddcee27ca7cab56b00.css.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/app.8bddcee27ca7cab56b00.css.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/config.34f4fe226a92f4ab6257.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/config.34f4fe226a92f4ab6257.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/config.34f4fe226a92f4ab6257.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/config.34f4fe226a92f4ab6257.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/config.34f4fe226a92f4ab6257.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/config.34f4fe226a92f4ab6257.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/config.34f4fe226a92f4ab6257.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/config.34f4fe226a92f4ab6257.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/config.f4c2f06f01d16464ea49.css b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/config.f4c2f06f01d16464ea49.css similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/config.f4c2f06f01d16464ea49.css rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/config.f4c2f06f01d16464ea49.css diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/config.f4c2f06f01d16464ea49.css.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/config.f4c2f06f01d16464ea49.css.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/config.f4c2f06f01d16464ea49.css.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/config.f4c2f06f01d16464ea49.css.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/conns.99b1285dff5ccca94b08.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/conns.99b1285dff5ccca94b08.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/conns.99b1285dff5ccca94b08.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/conns.99b1285dff5ccca94b08.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/conns.99b1285dff5ccca94b08.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/conns.99b1285dff5ccca94b08.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/conns.99b1285dff5ccca94b08.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/conns.99b1285dff5ccca94b08.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/conns.c9072a30fa369846711d.css b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/conns.c9072a30fa369846711d.css similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/conns.c9072a30fa369846711d.css rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/conns.c9072a30fa369846711d.css diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/conns.c9072a30fa369846711d.css.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/conns.c9072a30fa369846711d.css.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/conns.c9072a30fa369846711d.css.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/conns.c9072a30fa369846711d.css.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/core-js~app.dd6e8da2caf226e70989.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/core-js~app.dd6e8da2caf226e70989.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/core-js~app.dd6e8da2caf226e70989.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/core-js~app.dd6e8da2caf226e70989.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/core-js~app.dd6e8da2caf226e70989.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/core-js~app.dd6e8da2caf226e70989.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/core-js~app.dd6e8da2caf226e70989.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/core-js~app.dd6e8da2caf226e70989.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/index.html b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/index.html similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/index.html rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/index.html diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/logs.9c919d1590eed02bc4b6.css b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/logs.9c919d1590eed02bc4b6.css similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/logs.9c919d1590eed02bc4b6.css rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/logs.9c919d1590eed02bc4b6.css diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/logs.9c919d1590eed02bc4b6.css.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/logs.9c919d1590eed02bc4b6.css.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/logs.9c919d1590eed02bc4b6.css.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/logs.9c919d1590eed02bc4b6.css.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/logs.cc50e5d3455225682ee1.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/logs.cc50e5d3455225682ee1.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/logs.cc50e5d3455225682ee1.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/logs.cc50e5d3455225682ee1.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/logs.cc50e5d3455225682ee1.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/logs.cc50e5d3455225682ee1.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/logs.cc50e5d3455225682ee1.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/logs.cc50e5d3455225682ee1.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/open-sans-latin-400.woff2 b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/open-sans-latin-400.woff2 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/open-sans-latin-400.woff2 rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/open-sans-latin-400.woff2 diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/open-sans-latin-700.woff2 b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/open-sans-latin-700.woff2 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/open-sans-latin-700.woff2 rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/open-sans-latin-700.woff2 diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/proxies.0fea71f33a1333d027ad.css b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/proxies.0fea71f33a1333d027ad.css similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/proxies.0fea71f33a1333d027ad.css rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/proxies.0fea71f33a1333d027ad.css diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/proxies.0fea71f33a1333d027ad.css.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/proxies.0fea71f33a1333d027ad.css.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/proxies.0fea71f33a1333d027ad.css.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/proxies.0fea71f33a1333d027ad.css.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/proxies.c9885b811bbac6a73481.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/proxies.c9885b811bbac6a73481.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/proxies.c9885b811bbac6a73481.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/proxies.c9885b811bbac6a73481.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/proxies.c9885b811bbac6a73481.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/proxies.c9885b811bbac6a73481.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/proxies.c9885b811bbac6a73481.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/proxies.c9885b811bbac6a73481.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js.LICENSE.txt b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js.LICENSE.txt similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js.LICENSE.txt rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js.LICENSE.txt diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/react~app.9750176a07a47aafb60a.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/report.html b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/report.html similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/report.html rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/report.html diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/roboto-mono-latin-400.woff2 b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/roboto-mono-latin-400.woff2 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/roboto-mono-latin-400.woff2 rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/roboto-mono-latin-400.woff2 diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/rules.86d27ed35189095cbd2d.css b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/rules.86d27ed35189095cbd2d.css similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/rules.86d27ed35189095cbd2d.css rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/rules.86d27ed35189095cbd2d.css diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/rules.86d27ed35189095cbd2d.css.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/rules.86d27ed35189095cbd2d.css.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/rules.86d27ed35189095cbd2d.css.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/rules.86d27ed35189095cbd2d.css.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/rules.ea160448d44308c089d7.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/rules.ea160448d44308c089d7.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/rules.ea160448d44308c089d7.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/rules.ea160448d44308c089d7.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/rules.ea160448d44308c089d7.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/rules.ea160448d44308c089d7.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/rules.ea160448d44308c089d7.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/rules.ea160448d44308c089d7.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/runtime.f62113484153f953d626.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/runtime.f62113484153f953d626.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/runtime.f62113484153f953d626.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/runtime.f62113484153f953d626.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/runtime.f62113484153f953d626.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/runtime.f62113484153f953d626.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/runtime.f62113484153f953d626.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/runtime.f62113484153f953d626.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js.LICENSE.txt b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js.LICENSE.txt similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js.LICENSE.txt rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js.LICENSE.txt diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~chartjs.42b55d72a7fa9aeebd81.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~conns.755c8e5abbda57591cce.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~conns.755c8e5abbda57591cce.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~conns.755c8e5abbda57591cce.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~conns.755c8e5abbda57591cce.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~conns.755c8e5abbda57591cce.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~conns.755c8e5abbda57591cce.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~conns.755c8e5abbda57591cce.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~conns.755c8e5abbda57591cce.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~conns~proxies~rules.c215600c8244056a7348.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~conns~proxies~rules.c215600c8244056a7348.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~conns~proxies~rules.c215600c8244056a7348.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~conns~proxies~rules.c215600c8244056a7348.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~conns~proxies~rules.c215600c8244056a7348.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~conns~proxies~rules.c215600c8244056a7348.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~conns~proxies~rules.c215600c8244056a7348.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~conns~proxies~rules.c215600c8244056a7348.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~logs~rules.b89b151299a9a0792fbd.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~logs~rules.b89b151299a9a0792fbd.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~logs~rules.b89b151299a9a0792fbd.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~logs~rules.b89b151299a9a0792fbd.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~logs~rules.b89b151299a9a0792fbd.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~logs~rules.b89b151299a9a0792fbd.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~logs~rules.b89b151299a9a0792fbd.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~logs~rules.b89b151299a9a0792fbd.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~proxies.e33cf62311dc7a41141e.js b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~proxies.e33cf62311dc7a41141e.js similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~proxies.e33cf62311dc7a41141e.js rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~proxies.e33cf62311dc7a41141e.js diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~proxies.e33cf62311dc7a41141e.js.map b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~proxies.e33cf62311dc7a41141e.js.map similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/vendors~proxies.e33cf62311dc7a41141e.js.map rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/vendors~proxies.e33cf62311dc7a41141e.js.map diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/yacd-128.png b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/yacd-128.png similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/yacd-128.png rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/yacd-128.png diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/yacd-64.png b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/yacd-64.png similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/yacd-64.png rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/yacd-64.png diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/yacd.ico b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/yacd.ico similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yacd/yacd.ico rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yacd/yacd.ico diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_change.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_change.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_change.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_change.sh diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_field_cut.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_field_cut.sh similarity index 85% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_field_cut.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_field_cut.sh index 49731d30dc..2b7ffca440 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_field_cut.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_field_cut.sh @@ -5,7 +5,7 @@ field_cut() { local i lines end_len if [ "$4" != "dns" ]; then - proxy_len=$(sed -n '/^Proxy:/=' "$3" 2>/dev/null |sed -n 1p) + proxy_len=$(sed -n '/^Proxy:/=' "$3" 2>/dev/null) provider_len=$(sed -n '/^proxy-providers:/=' "$3" 2>/dev/null) group_len=$(sed -n '/^proxy-groups:/=' "$3" 2>/dev/null) rule_len=$(sed -n '/^rules:/=' "$3" 2>/dev/null) @@ -40,21 +40,25 @@ field_cut() elif [ -n "$end_len" ]; then end_len=$(expr "$end_len" - 1) fi - - if [ "$4" != "yaml_get" ]; then - sed -n "${1},${end_len}p" "$3" > "$2" 2>/dev/null - else + + if [ "$4" = "yaml_get" ]; then sed -n "${1},${end_len}p" "$3" |sed 's/\"//g' 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\t/ /g' 2>/dev/null > "$2" 2>/dev/null + elif [ "$4" = "dns" ]; then + sed -n "${1},${end_len}p" "$3" > "$2" 2>/dev/null + sed -i "${1},${end_len}d" "$3" 2>/dev/null + else + sed -n "${1},${end_len}p" "$3" > "$2" 2>/dev/null fi } +if [ ! -f "/tmp/yaml_general" ]; then #识别general部分 space_num=$(grep "^ \{0,\}socks-port:" "$3" 2>/dev/null |awk -F ':' '{print $1}' |grep -c " ") if [ -z "$space_num" ]; then space_num=$(grep "^ \{0,\}allow-lan:" "$3" 2>/dev/null |awk -F ':' '{print $1}' |grep -c " ") fi - cat "/etc/openclash/default.yaml" |awk '1;/dns:/{exit}' 2>/dev/null |sed '/^ \{0,\}#\|^ \{0,\}-\|^ \{0,\}$/d' 2>/dev/null |awk -F ':' '{print $1}' |while read -r line + cat "/usr/share/openclash/res/default.yaml" |awk '1;/dns:/{exit}' 2>/dev/null |sed '/^ \{0,\}#\|^ \{0,\}-\|^ \{0,\}$/d' 2>/dev/null |awk -F ':' '{print $1}' |while read -r line do if [ -z "$line" ]; then continue @@ -76,9 +80,10 @@ field_cut() general_len=$line_len echo $general_len >/tmp/yaml_general fi - done - - general_len=$(cat /tmp/yaml_general) + done 2>/dev/null +fi + + general_len=$(cat /tmp/yaml_general 2>/dev/null) if [ "$1" = "general" ]; then field_cut "$general_len" "$2" "$3" else @@ -100,5 +105,4 @@ field_cut() sed -i '/^ \{0,\}dns-hijack:/d' "$2" 2>/dev/null sed -i '/^ \{0,\}stack:/d' "$2" 2>/dev/null sed -i '/^ \{0,\}device-url:/d' "$2" 2>/dev/null - sed -i '/^ \{0,\}dns-listen:/d' "$2" 2>/dev/null - rm -rf /tmp/yaml_general 2>/dev/null \ No newline at end of file + sed -i '/^ \{0,\}dns-listen:/d' "$2" 2>/dev/null \ No newline at end of file diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_field_name_ch.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_field_name_ch.sh old mode 100755 new mode 100644 similarity index 91% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_field_name_ch.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_field_name_ch.sh index 014b056206..d5b8024d74 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_field_name_ch.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_field_name_ch.sh @@ -20,9 +20,11 @@ YML_FILE="$1" } #proxies - [ -z "$(grep "^Proxy:" "$YML_FILE")" ] && { + if [ -n "$(grep "^Proxy:" "$YML_FILE")" ] && [ -n "$(grep "^proxies:" "$YML_FILE")" ]; then + sed -i "s/^proxies:/Proxy:#d/g" "$YML_FILE" 2>/dev/null + else sed -i "s/^proxies:/Proxy:/g" "$YML_FILE" 2>/dev/null - } + fi [ -z "$(grep "^Proxy:" "$YML_FILE")" ] && { group_len=$(sed -n '/^Proxy Group:/=' "$YML_FILE" 2>/dev/null) proxies_len=$(sed -n '/proxies:/=' "$YML_FILE" 2>/dev/null |sed -n 1p) diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_get.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_get.sh old mode 100755 new mode 100644 similarity index 83% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_get.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_get.sh index 460862d3ca..6004599321 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_get.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_get.sh @@ -51,6 +51,7 @@ echo "开始更新【$CONFIG_NAME】的策略组配置..." >$START_LOG #判断各个区位置 group_len=$(sed -n '/^ \{0,\}proxy-groups:/=' "$CONFIG_FILE" 2>/dev/null) /usr/share/openclash/yml_field_cut.sh "$group_len" "/tmp/yaml_group.yaml" "$CONFIG_FILE" "yaml_get" +rm -rf /tmp/yaml_general 2>/dev/null #判断当前配置文件是否有策略组信息 cfg_group_name() @@ -174,7 +175,6 @@ do ${uci_set}tolerance="$group_test_tolerance" #other_group - if [ "$group_type" = "select" ]; then cat $single_group |while read -r line do if [ -z "$line" ]; then @@ -192,21 +192,39 @@ do continue fi + if [ "$group_type" != "select" ] && [ "$group_type" != "relay" ]; then + if [ "$group_name1" != "DIRECT" ] && [ "$group_name2" != "DIRECT" ] && [ "$group_name1" != "REJECT" ] && [ "$group_name2" != "REJECT" ]; then + continue + fi + fi + if [ ! -z "$group_name1" ] && [ -z "$group_name2" ]; then if [ "$proxies_len" -le "$use_len" ]; then if [ "$name1_len" -le "$use_len" ] && [ ! -z "$(grep -F "$group_name1" $match_group_file)" ] && [ "$group_name1" != "$group_name" ]; then - ${uci_add}other_group="$group_name1" + if [ "$group_type" = "select" ] || [ "$group_type" = "relay" ]; then + ${uci_add}other_group="$group_name1" + elif [ "$group_name1" = "DIRECT" ] || [ "$group_name1" = "REJECT" ]; then + ${uci_add}other_group_dr="$group_name1" + fi fi else if [ "$name1_len" -ge "$proxies_len" ] && [ ! -z "$(grep -F "$group_name1" $match_group_file)" ] && [ "$group_name1" != "$group_name" ]; then - ${uci_add}other_group="$group_name1" + if [ "$group_type" = "select" ] || [ "$group_type" = "relay" ]; then + ${uci_add}other_group="$group_name1" + elif [ "$group_name1" = "DIRECT" ] || [ "$group_name1" = "REJECT" ]; then + ${uci_add}other_group_dr="$group_name1" + fi fi fi 2>/dev/null elif [ -z "$group_name1" ] && [ ! -z "$group_name2" ]; then group_num=$(expr $(echo "$group_name2" |grep -c "#,#") + 1) if [ "$group_num" -le 1 ]; then if [ ! -z "$(grep -F "$group_name2" $match_group_file)" ] && [ "$group_name2" != "$group_name" ]; then - ${uci_add}other_group="$group_name2" + if [ "$group_type" = "select" ] || [ "$group_type" = "relay" ]; then + ${uci_add}other_group="$group_name2" + elif [ "$group_name2" = "DIRECT" ] || [ "$group_name2" = "REJECT" ]; then + ${uci_add}other_group_dr="$group_name2" + fi fi else group_nums=1 @@ -214,7 +232,11 @@ do do other_group_name=$(echo "$group_name2" |awk -v t="${group_nums}" -F '#,#' '{print $t}' 2>/dev/null) if [ ! -z "$(grep -F "$other_group_name" $match_group_file 2>/dev/null)" ] && [ "$other_group_name" != "$group_name" ]; then - ${uci_add}other_group="$other_group_name" + if [ "$group_type" = "select" ] || [ "$group_type" = "relay" ]; then + ${uci_add}other_group="$other_group_name" + elif [ "$other_group_name" = "DIRECT" ] || [ "$other_group_name" = "REJECT" ]; then + ${uci_add}other_group_dr="$other_group_name" + fi fi group_nums=$(expr "$group_nums" + 1) done @@ -222,7 +244,6 @@ do fi done - fi file_count=$(expr "$file_count" + 1) done diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_ch.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh old mode 100755 new mode 100644 similarity index 94% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_ch.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh index 16a1557d33..79ce105341 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_ch.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_name_ch.sh @@ -33,6 +33,7 @@ cfg_groups_set() sed -i "s/old_name_cfg \'${old_name_cfg}\'/old_name_cfg \'${name}\'/g" $CFG_FILE 2>/dev/null sed -i "s/groups \'${old_name_cfg}/groups \'${name}/g" $CFG_FILE 2>/dev/null sed -i "s/other_group \'${old_name_cfg}/other_group \'${name}/g" $CFG_FILE 2>/dev/null + sed -i "s/other_group_dr \'${old_name_cfg}/other_group_dr \'${name}/g" $CFG_FILE 2>/dev/null sed -i "s/new_servers_group \'${old_name_cfg}/new_servers_group \'${name}/g" $CFG_FILE 2>/dev/null sed -i "s/relay_groups \'${old_name_cfg}/relay_groups \'${name}/g" $CFG_FILE 2>/dev/null #第三方规则处理 diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_get.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_name_get.sh old mode 100755 new mode 100644 similarity index 96% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_get.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_name_get.sh index e2bb6ce995..a93fe79578 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_get.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_name_get.sh @@ -20,6 +20,7 @@ if [ -f "$CFG_FILE" ]; then group_len=$(sed -n '/^proxy-groups:/=' "$CFG_FILE" 2>/dev/null) if [ -n "$group_len" ]; then /usr/share/openclash/yml_field_cut.sh "$group_len" "$GROUP_FILE" "$CFG_FILE" + rm -rf /tmp/yaml_general 2>/dev/null fi 2>/dev/null cat "$GROUP_FILE" |sed "s/\'//g" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed 's/\t/ /g' 2>/dev/null |grep name: |awk -F 'name:' '{print $2}' |sed 's/,.*//' |sed 's/^ \{0,\}//' 2>/dev/null |sed 's/ \{0,\}$//' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null >/tmp/Proxy_Group 2>&1 diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_set.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_set.sh old mode 100755 new mode 100644 similarity index 98% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_set.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_set.sh index 46bebf9b3b..62b19ed871 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_set.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_groups_set.sh @@ -199,6 +199,8 @@ yml_groups_set() if [ "$type" = "select" ] || [ "$type" = "relay" ]; then config_list_foreach "$section" "other_group" set_other_groups #加入其他策略组 + else + config_list_foreach "$section" "other_group_dr" set_other_groups #仅加入direct/reject其他策略组 fi config_foreach yml_servers_add "servers" "$name" "$type" #加入服务器节点 diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh old mode 100755 new mode 100644 similarity index 98% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh index 19509a03b7..650fc9438f --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh @@ -36,11 +36,21 @@ elif [ ! -s "$CONFIG_FILE" ] && [ -s "$BACKUP_FILE" ]; then fi #判断各个区位置 -proxy_len=$(sed -n '/^ \{0,\}Proxy:/=' "$CONFIG_FILE" 2>/dev/null) -/usr/share/openclash/yml_field_cut.sh "$proxy_len" "/tmp/yaml_proxy.yaml" "$CONFIG_FILE" "yaml_get" +proxy_lens=$(sed -n '/^ \{0,\}Proxy:/=' "$CONFIG_FILE" 2>/dev/null) +proxy_len_num=1 +for proxy_len in $proxy_lens; do + if [ -n "$proxy_len" ]; then + /usr/share/openclash/yml_field_cut.sh "$proxy_len" "/tmp/yaml_proxy_$proxy_len_num.yaml" "$CONFIG_FILE" "yaml_get" + fi 2>/dev/null + proxy_len_num=$(expr "$proxy_len_num" + 1) +done 2>/dev/null +for i in $(seq "$proxy_len_num"); do + cat "/tmp/yaml_proxy_$i.yaml" >> /tmp/yaml_proxy.yaml +done 2>/dev/null +rm -rf /tmp/yaml_proxy_*.yaml 2>/dev/null provider_len=$(sed -n '/^ \{0,\}proxy-providers:/=' "$CONFIG_FILE" 2>/dev/null) /usr/share/openclash/yml_field_cut.sh "$provider_len" "/tmp/yaml_provider.yaml" "$CONFIG_FILE" "yaml_get" - +rm -rf /tmp/yaml_general 2>/dev/null CFG_FILE="/etc/config/openclash" server_file="/tmp/yaml_proxy.yaml" diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_set.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh old mode 100755 new mode 100644 similarity index 100% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_set.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_rules_change.sh b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh old mode 100755 new mode 100644 similarity index 98% rename from package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_rules_change.sh rename to package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh index 02ca3b8006..101294e1a9 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_rules_change.sh +++ b/package/ctcgfw/luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh @@ -154,9 +154,9 @@ if [ "$2" != 0 ]; then } [ "$check_def" -ne 1 ] && { - grep "^##updated$" /etc/openclash/"$2".yaml 1>/dev/null + grep "^##updated$" /usr/share/openclash/res/"$2".yaml 1>/dev/null [ "$?" -eq 0 ] && { - sed -i '/^##updated$/d' /etc/openclash/"$2".yaml + sed -i '/^##updated$/d' /usr/share/openclash/res/"$2".yaml check_def=1 } } @@ -218,7 +218,7 @@ if [ "$2" != 0 ]; then if [ "$2" = "lhie1" ]; then #删除原有的script部分,防止冲突 rm -rf "$SCRIPT_FILE" 2>/dev/null - cp /etc/openclash/lhie1.yaml "$OTHER_RULE_PROVIDER_FILE" + cp /usr/share/openclash/res/lhie1.yaml "$OTHER_RULE_PROVIDER_FILE" sed -n '/^ \{0,\}rules:/,$p' "$OTHER_RULE_PROVIDER_FILE" > "$OTHER_RULE_FILE" 2>/dev/null sed -i '/^ \{0,\}rules:/,$d' "$OTHER_RULE_PROVIDER_FILE" 2>/dev/null sed -n '/^ \{0,\}script:/,$p' "$OTHER_RULE_PROVIDER_FILE" > "$SCRIPT_FILE" 2>/dev/null @@ -312,7 +312,7 @@ if [ "$2" != 0 ]; then sed -i '/rule-providers:/r/tmp/other_rule_provider.yaml' "$9" 2>/dev/null fi elif [ "$2" = "ConnersHua" ]; then - cp /etc/openclash/ConnersHua.yaml "$OTHER_RULE_PROVIDER_FILE" + cp /usr/share/openclash/res/ConnersHua.yaml "$OTHER_RULE_PROVIDER_FILE" sed -n '/^rules:/,$p' "$OTHER_RULE_PROVIDER_FILE" > "$OTHER_RULE_FILE" 2>/dev/null sed -i '/^rules:/,$d' "$OTHER_RULE_PROVIDER_FILE" 2>/dev/null sed -i "/^ \{0,\}rule-providers:/c\rule-providers:" "$OTHER_RULE_PROVIDER_FILE" 2>/dev/null @@ -360,7 +360,7 @@ if [ "$2" != 0 ]; then sed -i '/rule-providers:/r/tmp/other_rule_provider.yaml' "$9" 2>/dev/null fi else - cp /etc/openclash/ConnersHua_return.yaml "$OTHER_RULE_FILE" + cp /usr/share/openclash/res/ConnersHua_return.yaml "$OTHER_RULE_FILE" sed -i "s/,PROXY$/,${Proxy}#d/g" "$OTHER_RULE_FILE" 2>/dev/null sed -i "s/,PROXY,no-resolve$/,${Proxy},no-resolve#d/g" "$OTHER_RULE_FILE" 2>/dev/null sed -i "/rules:/a\##Proxy:${Proxy}" "$OTHER_RULE_FILE" 2>/dev/null