mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-22 08:59:05 +08:00
feat: 处理端口跳跃(感谢亚托莉佬)
This commit is contained in:
parent
317a804b36
commit
15aff6fa2b
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.353",
|
"version": "2.14.354",
|
||||||
"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": {
|
||||||
|
@ -20,6 +20,23 @@ import { produceArtifact } from '@/restful/sync';
|
|||||||
import { getFlag, removeFlag, getISO, MMDB } from '@/utils/geo';
|
import { getFlag, removeFlag, getISO, MMDB } from '@/utils/geo';
|
||||||
import Gist from '@/utils/gist';
|
import Gist from '@/utils/gist';
|
||||||
|
|
||||||
|
function getRandomInt(min, max) {
|
||||||
|
min = Math.ceil(min);
|
||||||
|
max = Math.floor(max);
|
||||||
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRandomPort(portString) {
|
||||||
|
let portParts = portString.split(',');
|
||||||
|
let randomPart = portParts[Math.floor(Math.random() * portParts.length)];
|
||||||
|
if (randomPart.includes('-')) {
|
||||||
|
let [min, max] = randomPart.split('-').map(Number);
|
||||||
|
return getRandomInt(min, max);
|
||||||
|
} else {
|
||||||
|
return Number(randomPart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function preprocess(raw) {
|
function preprocess(raw) {
|
||||||
for (const processor of PROXY_PREPROCESSORS) {
|
for (const processor of PROXY_PREPROCESSORS) {
|
||||||
try {
|
try {
|
||||||
@ -220,6 +237,18 @@ function produce(proxies, targetPlatform, type, opts = {}) {
|
|||||||
delete proxy['tls-fingerprint'];
|
delete proxy['tls-fingerprint'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理 端口跳跃
|
||||||
|
if (proxy.ports) {
|
||||||
|
if (!['ClashMeta', 'JSON'].includes(targetPlatform)) {
|
||||||
|
proxy.ports = proxy.ports.replace(/\//g, ',');
|
||||||
|
}
|
||||||
|
if (!['ClashMeta', 'Stash', 'JSON'].includes(targetPlatform)) {
|
||||||
|
proxy.port = getRandomPort(proxy.ports);
|
||||||
|
delete proxy.ports;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user