Skip to content

Commit

Permalink
Fix log display speed
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolabnet committed Oct 10, 2024
1 parent fdbaef1 commit b5de20b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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.
Expand Down
21 changes: 18 additions & 3 deletions rootfs/opt/clash/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
69 changes: 37 additions & 32 deletions rootfs/www/luci-static/resources/view/ssclash/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

let editor = null;
let lastLogLength = 0;
let loggerPath = null;

function loadScript(src) {
return new Promise((resolve, reject) => {
Expand All @@ -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) {
Expand All @@ -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' },
Expand Down

0 comments on commit b5de20b

Please sign in to comment.