From 743eab33f5aa89609347084367e97837f178e7be Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Fri, 28 Feb 2020 00:57:28 +0800 Subject: [PATCH] luci-app-openclash: sync with upstream source --- package/ctcgfw/luci-app-openclash/Makefile | 13 +++++++------ .../luci-app-openclash/files/etc/init.d/openclash | 2 +- .../files/usr/lib/lua/luci/controller/openclash.lua | 2 +- .../usr/lib/lua/luci/model/cbi/openclash/config.lua | 2 +- .../usr/lib/lua/luci/view/openclash/status.htm | 2 +- .../files/usr/share/openclash/openclash_watchdog.sh | 12 ++++++++++-- .../i18n/zh_Hans/openclash.zh-cn.po | 2 +- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/package/ctcgfw/luci-app-openclash/Makefile b/package/ctcgfw/luci-app-openclash/Makefile index 0eef43305b..2bfde13db3 100644 --- a/package/ctcgfw/luci-app-openclash/Makefile +++ b/package/ctcgfw/luci-app-openclash/Makefile @@ -26,13 +26,14 @@ define Package/$(PKG_NAME)/postinst endef define Build/Prepare + $(CP) $(CURDIR)/files $(PKG_BUILD_DIR) $(foreach po,$(wildcard ${CURDIR}/i18n/zh_Hans/*.po), \ po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));) - chmod 0755 ${CURDIR}/files/etc/init.d/openclash - chmod -R 0755 ${CURDIR}/files/usr/share/openclash/ - mkdir -p ${CURDIR}/files/etc/openclash/config >/dev/null 2>&1 - mkdir -p ${CURDIR}/files/etc/openclash/proxy_provider >/dev/null 2>&1 - mkdir -p ${CURDIR}/files/etc/openclash/backup >/dev/null 2>&1 + 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/proxy_provider >/dev/null 2>&1 + mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/backup >/dev/null 2>&1 endef define Build/Configure @@ -157,7 +158,7 @@ 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) ./files/* $(1)/ + $(CP) $(PKG_BUILD_DIR)/files/* $(1)/ endef $(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash b/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash index 1b06a72ef9..a49076bd4a 100755 --- a/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash +++ b/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash @@ -10,7 +10,7 @@ CRON_FILE="/etc/crontabs/root" CONFIG_FILE=$(uci get openclash.config.config_path 2>/dev/null) LOG_FILE="/tmp/openclash.log" START_LOG="/tmp/openclash_start.log" -BACKUP_FILE="/etc/openclash/backup/$(uci get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)" +BACKUP_FILE="/etc/openclash/backup/$(uci get openclash.config.config_path 2>/dev/null |awk -F '/' '{print $5}' 2>/dev/null)" START_BACKUP="/tmp/config.sbak" CHANGE_FILE="/tmp/yaml_change.yaml" RULE_FILE="/tmp/yaml_rules.yaml" diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua index ab087eb6ee..82b40c5971 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua +++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua @@ -27,7 +27,7 @@ function index() 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 - entry({"admin", "services", "openclash", "config"},form("openclash/config"),_("Server Config"), 70).leaf = true + entry({"admin", "services", "openclash", "config"},form("openclash/config"),_("Config Manage"), 70).leaf = true entry({"admin", "services", "openclash", "log"},form("openclash/log"),_("Logs"), 80).leaf = true end diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua index 5c7773c213..fd60a5c7d5 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua +++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua @@ -24,7 +24,7 @@ function IsYmlFile(e) return e == ".yml" end -ful = SimpleForm("upload", translate("Server Config"), nil) +ful = SimpleForm("upload", translate("Config Manage"), nil) ful.reset = false ful.submit = false diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/status.htm b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/status.htm index 7949c40763..d4488c299b 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/status.htm +++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/status.htm @@ -154,7 +154,7 @@ function sponsorpage() { - url7='https://github.com/vernesong/OpenClash/wiki/Sponsor'; + url7='https://ko-fi.com/vernesong'; window.open(url7); } diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_watchdog.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_watchdog.sh index 0eb151953f..f49b8de372 100755 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_watchdog.sh +++ b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_watchdog.sh @@ -7,6 +7,7 @@ PROXY_ROUTE_TABLE="0x162" enable_redirect_dns=$(uci get openclash.config.enable_redirect_dns 2>/dev/null) dns_port=$(uci get openclash.config.dns_port 2>/dev/null) disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null) +en_mode=$(uci get openclash.config.en_mode 2>/dev/null) CRASH_NUM=0 while :; @@ -22,8 +23,15 @@ if [ "$enable" -eq 1 ]; then echo "${LOGTIME} Watchdog: Clash Core Problem, Restart." >> $LOG_FILE nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 & sleep 3 - ip route replace default dev utun table "$PROXY_ROUTE_TABLE" 2>/dev/null - ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" 2>/dev/null + if [ "$en_mode" = "fake-ip-tun" ] || [ "$en_mode" = "redir-host-tun" ]; then + ip route replace default dev utun table "$PROXY_ROUTE_TABLE" 2>/dev/null + ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" 2>/dev/null + elif [ "$en_mode" = "redir-host-vpn" ] || [ "$en_mode" = "fake-ip-vpn" ]; then + ip tuntap add user root mode tun clash0 + ip link set clash0 up + ip route replace default dev clash0 table "$PROXY_ROUTE_TABLE" + ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" + fi /usr/share/openclash/openclash_history_set.sh else echo "${LOGTIME} Watchdog: Already Restart 3 Times With Clash Core Problem, Auto-Exit." >> $LOG_FILE diff --git a/package/ctcgfw/luci-app-openclash/i18n/zh_Hans/openclash.zh-cn.po b/package/ctcgfw/luci-app-openclash/i18n/zh_Hans/openclash.zh-cn.po index de9e17daf5..4dcbb33983 100644 --- a/package/ctcgfw/luci-app-openclash/i18n/zh_Hans/openclash.zh-cn.po +++ b/package/ctcgfw/luci-app-openclash/i18n/zh_Hans/openclash.zh-cn.po @@ -237,7 +237,7 @@ msgstr "" msgid "Rules Setting" msgstr "规则设置(访问控制)" -msgid "Server Config" +msgid "Config Manage" msgstr "配置文件管理" msgid "Upload File Type"