From 128372e7437bd773c1cb159396429d1e2636edd8 Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Wed, 12 Mar 2025 14:16:16 +0800 Subject: [PATCH] update 2025-03-12 14:16:16 --- istoreenhance/Makefile | 2 +- istoreenhance/files/istoreenhance.init | 8 +- .../resources/view/fchomo/client.js | 106 ++++++++++++++++++ .../luci-static/resources/view/fchomo/node.js | 3 +- 4 files changed, 116 insertions(+), 3 deletions(-) diff --git a/istoreenhance/Makefile b/istoreenhance/Makefile index 85f3c63ad..0e729eebf 100644 --- a/istoreenhance/Makefile +++ b/istoreenhance/Makefile @@ -11,7 +11,7 @@ PKG_ARCH_ISTOREENHANCE:=$(ARCH) PKG_NAME:=istoreenhance PKG_VERSION:=0.1.9 -PKG_RELEASE:=$(PKG_ARCH_ISTOREENHANCE)-1 +PKG_RELEASE:=$(PKG_ARCH_ISTOREENHANCE)-2 PKG_SOURCE:=iStoreEnhance-binary-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://fw.koolcenter.com/binary/iStoreEnhance/ PKG_HASH:=846ef252e28a70f96d5051fdcdabb898d04dede37699137f439cfc77141cc072 diff --git a/istoreenhance/files/istoreenhance.init b/istoreenhance/files/istoreenhance.init index 92d03bb06..dbe0dd965 100755 --- a/istoreenhance/files/istoreenhance.init +++ b/istoreenhance/files/istoreenhance.init @@ -6,6 +6,8 @@ USE_PROCD=1 get_config() { config_get_bool enabled $1 enabled 1 config_get port $1 port 5443 + config_get adminport $1 adminport 5003 + config_get cache $1 cache } start_service() { @@ -16,10 +18,14 @@ start_service() { return 1 fi + if [ -z $cache ]; then + return 2 + fi + procd_open_instance procd_set_param limits nofile="65535 65535" procd_set_param command /usr/sbin/iStoreEnhance - [ -n "$port" ] && procd_append_param command --localAddr ":$port" + [ -n "$port" ] && procd_append_param command --localAddr ":$port" --adminAddr ":$adminport" --cachePath $cache procd_set_param respawn procd_close_instance } diff --git a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/client.js b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/client.js index ff0f59056..70125db20 100644 --- a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/client.js +++ b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/client.js @@ -2,11 +2,50 @@ 'require form'; 'require poll'; 'require uci'; +'require ui'; 'require view'; 'require fchomo as hm'; 'require tools.widgets as widgets'; +function parseProxyGroupYaml(field, name, cfg) { + if (!cfg.type) + return null; + + // key mapping + let config = hm.removeBlankAttrs({ + id: cfg.hm_id, + label: cfg.hm_label, + type: cfg.type, + groups: cfg.proxies ? cfg.proxies.map((grop) => hm.preset_outbound.full.map(([key, label]) => key).includes(grop) ? grop : this.calcID(hm.glossary["proxy_group"].field, grop)) : null, // array + use: cfg.use ? cfg.use.map((prov) => this.calcID(hm.glossary["provider"].field, prov)) : null, // array + include_all: hm.bool2str(cfg["include-all"]), // bool + include_all_proxies: hm.bool2str(cfg["include-all-proxies"]), // bool + include_all_providers: hm.bool2str(cfg["include-all-providers"]), // bool + // Url-test fields + tolerance: cfg.tolerance, + // Load-balance fields + strategy: cfg.strategy, + // Override fields + disable_udp: hm.bool2str(cfg["disable-udp"]), // bool + // Health fields + url: cfg.url, + interval: cfg.interval, + timeout: cfg.timeout, + lazy: hm.bool2str(cfg.lazy), // bool + expected_status: cfg["expected-status"], + max_failed_times: cfg["max-failed-times"], + // General fields + filter: [cfg.filter], // array.string: string + exclude_filter: [cfg["exclude-filter"]], // array.string: string + exclude_type: [cfg["exclude-type"]], // array.string: string + hidden: hm.bool2str(cfg.hidden), // bool + icon: cfg.icon + }); + + return config; +} + function loadDNSServerLabel(section_id) { delete this.keylist; delete this.vallist; @@ -618,6 +657,73 @@ return view.extend({ ss.hm_prefmt = hm.glossary[ss.sectiontype].prefmt; ss.hm_field = hm.glossary[ss.sectiontype].field; ss.hm_lowcase_only = true; + /* Import mihomo config start */ + ss.handleYamlImport = function() { + const field = this.hm_field; + const o = new hm.HandleImport(this.map, this, _('Import mihomo config'), + _('Please type %s fields of mihomo config.
') + .format(field)); + o.placeholder = 'proxy-groups:\n' + + '- name: "auto"\n' + + ' type: url-test\n' + + ' proxies:\n' + + ' - ss1\n' + + ' - ss2\n' + + ' - vmess1\n' + + ' tolerance: 150\n' + + ' lazy: true\n' + + ' expected-status: 204\n' + + ' url: "https://cp.cloudflare.com/generate_204"\n' + + ' interval: 300\n' + + ' timeout: 5000\n' + + ' max-failed-times: 5\n' + + '- name: "fallback-auto"\n' + + ' type: fallback\n' + + ' proxies:\n' + + ' - DIRECT\n' + + ' - auto\n' + + ' url: "https://cp.cloudflare.com/generate_204"\n' + + ' interval: 300\n' + + '- name: "load-balance"\n' + + ' type: load-balance\n' + + ' include-all: true\n' + + ' url: "https://cp.cloudflare.com/generate_204"\n' + + ' interval: 300\n' + + ' lazy: false\n' + + ' strategy: consistent-hashin\n' + + '- name: AllProxy\n' + + ' type: select\n' + + ' disable-udp: true\n' + + ' include-all-proxies: true\n' + + ' use:\n' + + ' - provider1\n' + + '- name: AllProvider\n' + + ' type: select\n' + + ' include-all-providers: true\n' + + ' filter: "(?i)港|hk|hongkong|hong kong"\n' + + ' exclude-filter: "美|日"\n' + + ' exclude-type: "Shadowsocks|Http"\n' + + ' ...' + o.parseYaml = function(field, name, cfg) { + let config = hm.HandleImport.prototype.parseYaml.call(this, field, name, cfg); + + return config ? parseProxyGroupYaml.call(this, field, name, config) : config; + }; + + return o.render(); + } + ss.renderSectionAdd = function(/* ... */) { + let el = hm.GridSection.prototype.renderSectionAdd.apply(this, arguments); + + el.appendChild(E('button', { + 'class': 'cbi-button cbi-button-add', + 'title': _('mihomo config'), + 'click': ui.createHandlerFn(this, 'handleYamlImport') + }, [ _('Import mihomo config') ])); + + return el; + } + /* Import mihomo config end */ ss.tab('field_general', _('General fields')); ss.tab('field_override', _('Override fields')); diff --git a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/node.js b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/node.js index 8fd0fb513..6c0c8c133 100644 --- a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/node.js +++ b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/node.js @@ -36,6 +36,7 @@ function parseProviderYaml(field, name, cfg) { override_prefix: hm.getValue(cfg, "override.additional-prefix"), override_suffix: hm.getValue(cfg, "override.additional-suffix"), override_replace: (hm.getValue(cfg, "override.proxy-name") || []).map((obj) => JSON.stringify(obj)), // array.string: array.object + // Configuration Items override_tfo: hm.bool2str(hm.getValue(cfg, "override.tfo")), // bool override_mptcp: hm.bool2str(hm.getValue(cfg, "override.mptcp")), // bool override_udp: hm.bool2str(hm.getValue(cfg, "override.udp")), // bool @@ -48,7 +49,7 @@ function parseProviderYaml(field, name, cfg) { override_routing_mark: hm.getValue(cfg, "override.routing-mark"), override_ip_version: hm.getValue(cfg, "override.ip-version"), /* General fields */ - filter: [cfg.filter], // array: string + filter: [cfg.filter], // array.string: string exclude_filter: [cfg["exclude-filter"]], // array.string: string exclude_type: [cfg["exclude-type"]] // array.string: string })