mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-17 21:03:30 +00:00
* luci-app-ssr-plus: optimize calc hashkey, fix #3096 * luci-app-ssr-plus: optimize server list socket check
This commit is contained in:
parent
56b4df4cdb
commit
69a7c1ed35
@ -14,6 +14,8 @@ local dsp = require "luci.dispatcher"
|
||||
const dom = doms[index];
|
||||
const port = ports[index];
|
||||
if (!dom) res()
|
||||
port.innerHTML = '<font color="#0072c3">connecting...</font>';
|
||||
|
||||
XHR.get('<%=dsp.build_url("admin/services/shadowsocksr/ping")%>', {
|
||||
index,
|
||||
domain: dom.getAttribute("hint"),
|
||||
@ -28,24 +30,22 @@ local dsp = require "luci.dispatcher"
|
||||
}
|
||||
dom.innerHTML = `<font color="${col}">${(result.ping ? result.ping : "--") + " ms"}</font>`
|
||||
if (result.socket) {
|
||||
port.innerHTML = '<font color="#249400">ok</font>'
|
||||
port.innerHTML = '<font color="#249400">ok</font>';
|
||||
} else {
|
||||
port.innerHTML = '<font color="#ff0000">fail</font>'
|
||||
port.innerHTML = '<font color="#ff0000">fail</font>';
|
||||
}
|
||||
res()
|
||||
res();
|
||||
});
|
||||
})
|
||||
}
|
||||
(async () => {
|
||||
for (let group = 0; group < Math.ceil(doms.length / 5); group++) {
|
||||
await Promise.all([
|
||||
xhr(group * 5 + 0),
|
||||
xhr(group * 5 + 1),
|
||||
xhr(group * 5 + 2),
|
||||
xhr(group * 5 + 3),
|
||||
xhr(group * 5 + 4),
|
||||
])
|
||||
let task = -1;
|
||||
const thread = () => {
|
||||
task = task + 1
|
||||
if (doms[task]) {
|
||||
xhr(task).then(thread);
|
||||
}
|
||||
})()
|
||||
//]]>
|
||||
</script>
|
||||
}
|
||||
for (let i = 0; i < 10; i++) {
|
||||
thread()
|
||||
}
|
||||
</script>
|
@ -1,3 +1,3 @@
|
||||
<%+cbi/valueheader%>
|
||||
<span class="socket-connected" hint="<%=self:cfgvalue(section)%>">connecting</span>
|
||||
<span class="socket-connected" hint="<%=self:cfgvalue(section)%>">wait</span>
|
||||
<%+cbi/valuefooter%>
|
||||
|
@ -105,7 +105,6 @@ local function processData(szType, content)
|
||||
-- kcp_port = 0,
|
||||
kcp_param = '--nocomp'
|
||||
}
|
||||
result.hashkey = type(content) == 'string' and md5(content) or md5(jsonStringify(content))
|
||||
if szType == 'ssr' then
|
||||
local dat = split(content, "/\\?")
|
||||
local hostInfo = split(dat[1], ':')
|
||||
@ -226,6 +225,11 @@ local function processData(szType, content)
|
||||
if not result.alias then
|
||||
result.alias = result.server .. ':' .. result.server_port
|
||||
end
|
||||
-- alias 不参与 hashkey 计算
|
||||
local alias = result.alias
|
||||
result.alias = nil
|
||||
result.hashkey = md5(jsonStringify(result))
|
||||
result.alias = alias
|
||||
return result
|
||||
end
|
||||
-- wget
|
||||
|
Loading…
Reference in New Issue
Block a user