mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 05:09:01 +08:00
feat: 优化流量解析规则
This commit is contained in:
parent
9b6d9d49f9
commit
e5c1ae9ed8
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.188",
|
"version": "2.14.189",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -88,17 +88,27 @@ export async function getFlowHeaders(rawUrl, ua, timeout) {
|
|||||||
export function parseFlowHeaders(flowHeaders) {
|
export function parseFlowHeaders(flowHeaders) {
|
||||||
if (!flowHeaders) return;
|
if (!flowHeaders) return;
|
||||||
// unit is KB
|
// unit is KB
|
||||||
const uploadMatch = flowHeaders.match(/upload=(-?)([E+.\d]+)/);
|
const uploadMatch = flowHeaders.match(
|
||||||
|
/upload=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/,
|
||||||
|
);
|
||||||
const upload = Number(uploadMatch[1] + uploadMatch[2]);
|
const upload = Number(uploadMatch[1] + uploadMatch[2]);
|
||||||
|
|
||||||
const downloadMatch = flowHeaders.match(/download=(-?)([E+.\d]+)/);
|
const downloadMatch = flowHeaders.match(
|
||||||
|
/download=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/,
|
||||||
|
);
|
||||||
const download = Number(downloadMatch[1] + downloadMatch[2]);
|
const download = Number(downloadMatch[1] + downloadMatch[2]);
|
||||||
|
const totalMatch = flowHeaders.match(
|
||||||
const total = Number(flowHeaders.match(/total=([E+.\d]+)/)[1]);
|
/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/,
|
||||||
|
);
|
||||||
|
const total = Number(totalMatch[1] + totalMatch[2]);
|
||||||
|
|
||||||
// optional expire timestamp
|
// optional expire timestamp
|
||||||
const match = flowHeaders.match(/expire=(\d+)/);
|
const expireMatch = flowHeaders.match(
|
||||||
const expires = match ? Number(match[1]) : undefined;
|
/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/,
|
||||||
|
);
|
||||||
|
const expires = expireMatch
|
||||||
|
? Number(expireMatch[1] + expireMatch[2])
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return { expires, total, usage: { upload, download } };
|
return { expires, total, usage: { upload, download } };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user