From b5de20ba4d85906b31e9d7a2ce8970cf5cff0a79 Mon Sep 17 00:00:00 2001 From: ZeroChaos <71016736+zerolabnet@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:46:50 +0300 Subject: [PATCH] Fix log display speed --- Makefile | 2 +- README.md | 10 +-- rootfs/opt/clash/config.yaml | 21 +++++- .../luci-static/resources/view/ssclash/log.js | 69 ++++++++++--------- 4 files changed, 61 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile index 826c06d..4d185f4 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssclash -PKG_VERSION:=1.6 +PKG_VERSION:=1.7 PKG_RELEASE:=1 PKG_MAINTAINER:=ZeroChaos diff --git a/README.md b/README.md index c1d6193..c28e5a1 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ For iptables (if you have OpenWrt version < 22.03.x) – `iptables-mod-tproxy`. Download the ssclash package and install it. ```bash -curl -L https://github.com/zerolabnet/ssclash/releases/download/v1.6/luci-app-ssclash_1.6-1_all.ipk -o /tmp/luci-app-ssclash_1.6-1_all.ipk -opkg install /tmp/luci-app-ssclash_1.6-1_all.ipk +curl -L https://github.com/zerolabnet/ssclash/releases/download/v1.7/luci-app-ssclash_1.7-1_all.ipk -o /tmp/luci-app-ssclash_1.7-1_all.ipk +opkg install /tmp/luci-app-ssclash_1.7-1_all.ipk rm /tmp/*.ipk ``` @@ -48,19 +48,19 @@ cd /opt/clash/bin For **amd64** architecture: ```bash -curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.8/mihomo-linux-amd64-compatible-v1.18.8.gz -o clash.gz +curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.9/mihomo-linux-amd64-compatible-v1.18.9.gz -o clash.gz ``` For **arm64** architecture: ```bash -curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.8/mihomo-linux-arm64-v1.18.8.gz -o clash.gz +curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.9/mihomo-linux-arm64-v1.18.9.gz -o clash.gz ``` For **mipsel_24kc** architecture: ```bash -curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.8/mihomo-linux-mipsle-softfloat-v1.18.8.gz -o clash.gz +curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.9/mihomo-linux-mipsle-softfloat-v1.18.9.gz -o clash.gz ``` Need a different architecture? Visit the [MetaCubeX Release Page](https://github.com/MetaCubeX/mihomo/releases) and choose the one that matches your device. diff --git a/rootfs/opt/clash/config.yaml b/rootfs/opt/clash/config.yaml index 482d7d6..6ed7188 100644 --- a/rootfs/opt/clash/config.yaml +++ b/rootfs/opt/clash/config.yaml @@ -59,24 +59,39 @@ proxies: short-id: ae380de2eeded283 # change it client-fingerprint: chrome + - name: 'YY-reality' # change it + type: vless + server: yy-reality-server-IP # change it + port: 443 + uuid: 3f0d4ce6-e4fe-46f9-804c-cce633e22785 # change it + network: tcp + tls: true + udp: true + flow: xtls-rprx-vision + servername: masking-domain.example.org # change it + reality-opts: + public-key: beAHvGPT-mhlYQAvX7u_rQQfnJqTXaStmRFkTnkUolE # change it + short-id: 0890fec52c6dd1ca # change it + client-fingerprint: chrome + proxy-groups: # Select (used for selecting proxy or proxy group) - name: PROXY type: select # disable-udp: true - proxies: [XX-reality] # change it, add the others + proxies: [XX-reality, YY-reality] # change it, add the others # Fallback - name: FALLBACK type: fallback - proxies: [XX-reality] # change it, add the others + proxies: [XX-reality, YY-reality] # change it, add the others url: 'https://www.gstatic.com/generate_204' # or https://cp.cloudflare.com/generate_204 interval: 300 # # Load-balance # - name: LB-PROXY # type: load-balance - # proxies: [XX-reality] # change it, add the others + # proxies: [XX-reality, YY-reality] # change it, add the others # url: 'https://www.gstatic.com/generate_204' # interval: 300 # strategy: consistent-hashing # or round-robin diff --git a/rootfs/www/luci-static/resources/view/ssclash/log.js b/rootfs/www/luci-static/resources/view/ssclash/log.js index 4fee5cb..cd14ffd 100644 --- a/rootfs/www/luci-static/resources/view/ssclash/log.js +++ b/rootfs/www/luci-static/resources/view/ssclash/log.js @@ -5,6 +5,7 @@ let editor = null; let lastLogLength = 0; +let loggerPath = null; function loadScript(src) { return new Promise((resolve, reject) => { @@ -28,6 +29,39 @@ async function initializeAceEditor() { readOnly: true, wrap: true }); + + startPolling(); +} + +function startPolling() { + poll.add(() => { + if (loggerPath) { + return fs.exec_direct(loggerPath, ['-e', 'clash']) + .then(res => { + if (res) { + const lines = res.trim().split('\n'); + if (lines.length > lastLogLength) { + const newLines = lines.slice(lastLogLength); + const processedNewLines = newLines.map(processLogLine).join('\n'); + + editor.session.insert({ + row: editor.session.getLength(), + column: 0 + }, (lastLogLength > 0 ? '\n' : '') + processedNewLines); + + lastLogLength = lines.length; + editor.scrollToLine(editor.session.getLength(), false, true, function() {}); + } + } else if (lastLogLength > 0) { + editor.setValue('', 1); + lastLogLength = 0; + } + }) + .catch(err => { + console.error('Error executing logread:', err); + }); + } + }); } function processLogLine(line) { @@ -40,41 +74,12 @@ function processLogLine(line) { return view.extend({ load: function () { - return fs.stat('/sbin/logread'); + return fs.stat('/sbin/logread').then(stat => { + loggerPath = stat && stat.path ? stat.path : null; + }); }, render: function (stat) { - const loggerPath = stat && stat.path ? stat.path : null; - - poll.add(() => { - if (loggerPath && editor) { - return fs.exec_direct(loggerPath, ['-e', 'clash']) - .then(res => { - if (res) { - const lines = res.trim().split('\n'); - if (lines.length > lastLogLength) { - const newLines = lines.slice(lastLogLength); - const processedNewLines = newLines.map(processLogLine).join('\n'); - - editor.session.insert({ - row: editor.session.getLength(), - column: 0 - }, (lastLogLength > 0 ? '\n' : '') + processedNewLines); - - lastLogLength = lines.length; - editor.scrollToLine(editor.session.getLength(), false, true, function() {}); - } - } else if (lastLogLength > 0) { - editor.setValue('', 1); - lastLogLength = 0; - } - }) - .catch(err => { - console.error('Error executing logread:', err); - }); - } - }); - const view = E( 'div', { class: 'cbi-map' },