mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 11:28:59 +08:00
fix: 修复 Clash 节点名为 binary 的情况
This commit is contained in:
parent
468d136f0e
commit
a4384f4f13
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.233",
|
"version": "2.14.235",
|
||||||
"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": {
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
import YAML from '@/utils/yaml';
|
import YAML from '@/utils/yaml';
|
||||||
import download from '@/utils/download';
|
import download from '@/utils/download';
|
||||||
import { isIPv4, isIPv6, isValidPortNumber, isNotBlank } from '@/utils';
|
import {
|
||||||
|
isIPv4,
|
||||||
|
isIPv6,
|
||||||
|
isValidPortNumber,
|
||||||
|
isNotBlank,
|
||||||
|
utf8ArrayToStr,
|
||||||
|
} from '@/utils';
|
||||||
import PROXY_PROCESSORS, { ApplyProcessor } from './processors';
|
import PROXY_PROCESSORS, { ApplyProcessor } from './processors';
|
||||||
import PROXY_PREPROCESSORS from './preprocessors';
|
import PROXY_PREPROCESSORS from './preprocessors';
|
||||||
import PROXY_PRODUCERS from './producers';
|
import PROXY_PRODUCERS from './producers';
|
||||||
@ -370,6 +376,18 @@ function lastParse(proxy) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (typeof proxy.name !== 'string') {
|
||||||
|
try {
|
||||||
|
if (proxy.name?.data) {
|
||||||
|
proxy.name = Buffer.from(proxy.name.data).toString('utf8');
|
||||||
|
} else {
|
||||||
|
proxy.name = utf8ArrayToStr(proxy.name);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
$.error(`proxy.name decode failed\nReason: ${e}`);
|
||||||
|
proxy.name = `${proxy.type} ${proxy.server}:${proxy.port}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,53 @@ function getIfPresent(obj, defaultValue) {
|
|||||||
return isPresent(obj) ? obj : defaultValue;
|
return isPresent(obj) ? obj : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const utf8ArrayToStr =
|
||||||
|
typeof TextDecoder !== 'undefined'
|
||||||
|
? (v) => new TextDecoder().decode(new Uint8Array(v))
|
||||||
|
: (function () {
|
||||||
|
var charCache = new Array(128); // Preallocate the cache for the common single byte chars
|
||||||
|
var charFromCodePt = String.fromCodePoint || String.fromCharCode;
|
||||||
|
var result = [];
|
||||||
|
|
||||||
|
return function (array) {
|
||||||
|
var codePt, byte1;
|
||||||
|
var buffLen = array.length;
|
||||||
|
|
||||||
|
result.length = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < buffLen; ) {
|
||||||
|
byte1 = array[i++];
|
||||||
|
|
||||||
|
if (byte1 <= 0x7f) {
|
||||||
|
codePt = byte1;
|
||||||
|
} else if (byte1 <= 0xdf) {
|
||||||
|
codePt = ((byte1 & 0x1f) << 6) | (array[i++] & 0x3f);
|
||||||
|
} else if (byte1 <= 0xef) {
|
||||||
|
codePt =
|
||||||
|
((byte1 & 0x0f) << 12) |
|
||||||
|
((array[i++] & 0x3f) << 6) |
|
||||||
|
(array[i++] & 0x3f);
|
||||||
|
} else if (String.fromCodePoint) {
|
||||||
|
codePt =
|
||||||
|
((byte1 & 0x07) << 18) |
|
||||||
|
((array[i++] & 0x3f) << 12) |
|
||||||
|
((array[i++] & 0x3f) << 6) |
|
||||||
|
(array[i++] & 0x3f);
|
||||||
|
} else {
|
||||||
|
codePt = 63; // Cannot convert four byte code points, so use "?" instead
|
||||||
|
i += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.push(
|
||||||
|
charCache[codePt] ||
|
||||||
|
(charCache[codePt] = charFromCodePt(codePt)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.join('');
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
export {
|
export {
|
||||||
isIPv4,
|
isIPv4,
|
||||||
isIPv6,
|
isIPv6,
|
||||||
@ -43,4 +90,5 @@ export {
|
|||||||
getIfNotBlank,
|
getIfNotBlank,
|
||||||
isPresent,
|
isPresent,
|
||||||
getIfPresent,
|
getIfPresent,
|
||||||
|
utf8ArrayToStr,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user