mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-03-27 11:33:15 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c09a945368 | ||
|
|
317a804b36 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.14.352",
|
||||
"version": "2.14.355",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -20,6 +20,23 @@ import { produceArtifact } from '@/restful/sync';
|
||||
import { getFlag, removeFlag, getISO, MMDB } from '@/utils/geo';
|
||||
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) {
|
||||
for (const processor of PROXY_PREPROCESSORS) {
|
||||
try {
|
||||
@@ -220,6 +237,18 @@ function produce(proxies, targetPlatform, type, opts = {}) {
|
||||
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;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,30 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
import { Base64 } from 'js-base64';
|
||||
import URI_Producer from './uri';
|
||||
import $ from '@/core/app';
|
||||
|
||||
const URI = URI_Producer();
|
||||
|
||||
export default function V2Ray_Producer() {
|
||||
const type = 'ALL';
|
||||
const produce = (proxies) =>
|
||||
Base64.encode(proxies.map((proxy) => URI.produce(proxy)).join('\n'));
|
||||
const produce = (proxies) => {
|
||||
let result = [];
|
||||
proxies.map((proxy) => {
|
||||
try {
|
||||
result.push(URI.produce(proxy));
|
||||
} catch (err) {
|
||||
$.error(
|
||||
`Cannot produce proxy: ${JSON.stringify(
|
||||
proxy,
|
||||
null,
|
||||
2,
|
||||
)}\nReason: ${err}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return Base64.encode(result.join('\n'));
|
||||
};
|
||||
|
||||
return { type, produce };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user