mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 00:52:40 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fbc589a8a | ||
|
|
c854614efc | ||
|
|
16a5995d21 | ||
|
|
15b55f6d1a | ||
|
|
8e5ce26e7b | ||
|
|
c5d8aff73c | ||
|
|
5696492dde | ||
|
|
e6d05fd873 | ||
|
|
4111b8fabf | ||
|
|
dfc619a181 | ||
|
|
ff5283a66f |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.18.7",
|
"version": "2.19.6",
|
||||||
"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": {
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
"cron": "^3.1.6",
|
"cron": "^3.1.6",
|
||||||
"dns-packet": "^5.6.1",
|
"dns-packet": "^5.6.1",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"mime-types": "^2.1.35",
|
||||||
"http-proxy-middleware": "^3.0.3",
|
"http-proxy-middleware": "^3.0.3",
|
||||||
"ip-address": "^9.0.5",
|
"ip-address": "^9.0.5",
|
||||||
"js-base64": "^3.7.2",
|
"js-base64": "^3.7.2",
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ function lastParse(proxy) {
|
|||||||
proxy['tls-fingerprint'] = rs.generateFingerprint(caStr);
|
proxy['tls-fingerprint'] = rs.generateFingerprint(caStr);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
['shadowsocks'].includes(proxy.type) &&
|
['ss'].includes(proxy.type) &&
|
||||||
isPresent(proxy, 'shadow-tls-password')
|
isPresent(proxy, 'shadow-tls-password')
|
||||||
) {
|
) {
|
||||||
proxy.plugin = 'shadow-tls';
|
proxy.plugin = 'shadow-tls';
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ vmess = tag equals "vmess"i address method uuid (transport/transport_host/transp
|
|||||||
proxy.alterId = proxy.alterId || 0;
|
proxy.alterId = proxy.alterId || 0;
|
||||||
handleTransport();
|
handleTransport();
|
||||||
}
|
}
|
||||||
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* {
|
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/flow/public_key/short_id/others)* {
|
||||||
proxy.type = "vless";
|
proxy.type = "vless";
|
||||||
handleTransport();
|
handleTransport();
|
||||||
}
|
}
|
||||||
@@ -180,6 +180,10 @@ tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-
|
|||||||
tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
|
|
||||||
|
flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
|
public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
|
short_id = comma "short-id" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
|
|
||||||
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
||||||
udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; }
|
udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; }
|
||||||
ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); }
|
ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); }
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ vmess = tag equals "vmess"i address method uuid (transport/transport_host/transp
|
|||||||
proxy.alterId = proxy.alterId || 0;
|
proxy.alterId = proxy.alterId || 0;
|
||||||
handleTransport();
|
handleTransport();
|
||||||
}
|
}
|
||||||
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* {
|
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/flow/public_key/short_id/others)* {
|
||||||
proxy.type = "vless";
|
proxy.type = "vless";
|
||||||
handleTransport();
|
handleTransport();
|
||||||
}
|
}
|
||||||
@@ -178,6 +178,10 @@ tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-
|
|||||||
tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
|
|
||||||
|
flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
|
public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
|
short_id = comma "short-id" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||||
|
|
||||||
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
||||||
udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; }
|
udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; }
|
||||||
ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); }
|
ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); }
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default function Loon_Producer() {
|
|||||||
case 'vmess':
|
case 'vmess':
|
||||||
return vmess(proxy);
|
return vmess(proxy);
|
||||||
case 'vless':
|
case 'vless':
|
||||||
return vless(proxy);
|
return vless(proxy, opts['include-unsupported-proxy']);
|
||||||
case 'http':
|
case 'http':
|
||||||
return http(proxy);
|
return http(proxy);
|
||||||
case 'socks5':
|
case 'socks5':
|
||||||
@@ -347,10 +347,26 @@ function vmess(proxy) {
|
|||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function vless(proxy) {
|
function vless(proxy, includeUnsupportedProxy) {
|
||||||
if (typeof proxy.flow !== 'undefined' || proxy['reality-opts']) {
|
if (
|
||||||
|
!includeUnsupportedProxy &&
|
||||||
|
(typeof proxy.flow !== 'undefined' || proxy['reality-opts'])
|
||||||
|
) {
|
||||||
throw new Error(`VLESS XTLS/REALITY is not supported`);
|
throw new Error(`VLESS XTLS/REALITY is not supported`);
|
||||||
}
|
}
|
||||||
|
let isReality = false;
|
||||||
|
if (includeUnsupportedProxy) {
|
||||||
|
if (
|
||||||
|
proxy['reality-opts'] &&
|
||||||
|
['xtls-rprx-vision'].includes(proxy.flow)
|
||||||
|
) {
|
||||||
|
isReality = true;
|
||||||
|
} else if (proxy['reality-opts'] || proxy.flow) {
|
||||||
|
throw new Error(
|
||||||
|
`VLESS XTLS/REALITY with flow(${proxy.flow}) is not supported`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
const result = new Result(proxy);
|
const result = new Result(proxy);
|
||||||
result.append(
|
result.append(
|
||||||
`${proxy.name}=vless,${proxy.server},${proxy.port},"${proxy.uuid}"`,
|
`${proxy.name}=vless,${proxy.server},${proxy.port},"${proxy.uuid}"`,
|
||||||
@@ -399,7 +415,20 @@ function vless(proxy) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// sni
|
// sni
|
||||||
result.appendIfPresent(`,tls-name=${proxy.sni}`, 'sni');
|
if (isReality) {
|
||||||
|
result.appendIfPresent(`,sni=${proxy.sni}`, 'sni');
|
||||||
|
result.appendIfPresent(
|
||||||
|
`,public-key="${proxy['reality-opts']['public-key']}"`,
|
||||||
|
'reality-opts.public-key',
|
||||||
|
);
|
||||||
|
result.appendIfPresent(
|
||||||
|
`,short-id=${proxy['reality-opts']['short-id']}`,
|
||||||
|
'reality-opts.short-id',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
result.appendIfPresent(`,tls-name=${proxy.sni}`, 'sni');
|
||||||
|
}
|
||||||
|
|
||||||
result.appendIfPresent(
|
result.appendIfPresent(
|
||||||
`,tls-cert-sha256=${proxy['tls-fingerprint']}`,
|
`,tls-cert-sha256=${proxy['tls-fingerprint']}`,
|
||||||
'tls-fingerprint',
|
'tls-fingerprint',
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ console.log(
|
|||||||
┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅
|
┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
if ($.env.isNode) {
|
|
||||||
const dotenv = eval(`require("dotenv")`);
|
|
||||||
dotenv.config();
|
|
||||||
}
|
|
||||||
import migrate from '@/utils/migration';
|
import migrate from '@/utils/migration';
|
||||||
import serve from '@/restful';
|
import serve from '@/restful';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
||||||
import { COLLECTIONS_KEY, ARTIFACTS_KEY } from '@/constants';
|
import { COLLECTIONS_KEY, ARTIFACTS_KEY, FILES_KEY } from '@/constants';
|
||||||
import { failed, success } from '@/restful/response';
|
import { failed, success } from '@/restful/response';
|
||||||
import $ from '@/core/app';
|
import $ from '@/core/app';
|
||||||
import { RequestInvalidError, ResourceNotFoundError } from '@/restful/errors';
|
import { RequestInvalidError, ResourceNotFoundError } from '@/restful/errors';
|
||||||
@@ -106,7 +106,18 @@ function updateCollection(req, res) {
|
|||||||
artifact.source = newCol.name;
|
artifact.source = newCol.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// update all files referring this collection
|
||||||
|
const allFiles = $.read(FILES_KEY) || [];
|
||||||
|
for (const file of allFiles) {
|
||||||
|
if (
|
||||||
|
file.sourceType === 'collection' &&
|
||||||
|
file.sourceName === oldCol.name
|
||||||
|
) {
|
||||||
|
file.sourceName = newCol.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
$.write(allArtifacts, ARTIFACTS_KEY);
|
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||||
|
$.write(allFiles, FILES_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateByName(allCols, name, newCol);
|
updateByName(allCols, name, newCol);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
||||||
import { getFlowHeaders, normalizeFlowHeader } from '@/utils/flow';
|
import { getFlowHeaders, normalizeFlowHeader } from '@/utils/flow';
|
||||||
import { FILES_KEY } from '@/constants';
|
import { FILES_KEY, ARTIFACTS_KEY } from '@/constants';
|
||||||
import { failed, success } from '@/restful/response';
|
import { failed, success } from '@/restful/response';
|
||||||
import $ from '@/core/app';
|
import $ from '@/core/app';
|
||||||
import {
|
import {
|
||||||
@@ -245,6 +245,20 @@ function updateFile(req, res) {
|
|||||||
};
|
};
|
||||||
$.info(`正在更新文件:${name}...`);
|
$.info(`正在更新文件:${name}...`);
|
||||||
|
|
||||||
|
if (name !== newFile.name) {
|
||||||
|
// update all artifacts referring this collection
|
||||||
|
const allArtifacts = $.read(ARTIFACTS_KEY) || [];
|
||||||
|
for (const artifact of allArtifacts) {
|
||||||
|
if (
|
||||||
|
artifact.type === 'file' &&
|
||||||
|
artifact.source === oldFile.name
|
||||||
|
) {
|
||||||
|
artifact.source = newFile.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
updateByName(allFiles, name, newFile);
|
updateByName(allFiles, name, newFile);
|
||||||
$.write(allFiles, FILES_KEY);
|
$.write(allFiles, FILES_KEY);
|
||||||
success(res, newFile);
|
success(res, newFile);
|
||||||
|
|||||||
@@ -30,25 +30,68 @@ export default function serve() {
|
|||||||
}
|
}
|
||||||
const $app = express({ substore: $, port, host });
|
const $app = express({ substore: $, port, host });
|
||||||
if ($.env.isNode) {
|
if ($.env.isNode) {
|
||||||
|
const be_merge = eval('process.env.SUB_STORE_BACKEND_MERGE');
|
||||||
const be_prefix = eval('process.env.SUB_STORE_BACKEND_PREFIX');
|
const be_prefix = eval('process.env.SUB_STORE_BACKEND_PREFIX');
|
||||||
const fe_be_path = eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH');
|
const fe_be_path = eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH');
|
||||||
if (be_prefix) {
|
const fe_path = eval('process.env.SUB_STORE_FRONTEND_PATH');
|
||||||
if (!fe_be_path.startsWith('/')) {
|
if (be_prefix || be_merge) {
|
||||||
|
if(!fe_be_path.startsWith('/')){
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'SUB_STORE_FRONTEND_BACKEND_PATH should start with /',
|
'SUB_STORE_FRONTEND_BACKEND_PATH should start with /',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$.info(
|
if (be_merge) {
|
||||||
`[BACKEND PREFIX] ${host}:${port}${fe_be_path} -> ${host}:${port}`,
|
$.info(`[BACKEND] MERGE mode is [ON].`);
|
||||||
);
|
$.info(`[BACKEND && FRONTEND] ${host}:${port}`);
|
||||||
|
}
|
||||||
|
$.info(`[BACKEND PREFIX] ${host}:${port}${fe_be_path}`);
|
||||||
$app.use((req, res, next) => {
|
$app.use((req, res, next) => {
|
||||||
if (req.path.startsWith(fe_be_path)) {
|
if (req.path.startsWith(fe_be_path)) {
|
||||||
const newPath = req.url.replace(fe_be_path, '') || '/';
|
req.url = req.url.replace(fe_be_path, '') || '/';
|
||||||
req.url = newPath;
|
if(be_merge && req.url.startsWith('/api/')){
|
||||||
|
req.query['share'] = 'true';
|
||||||
|
}
|
||||||
next();
|
next();
|
||||||
} else {
|
return;
|
||||||
res.status(403).send();
|
|
||||||
}
|
}
|
||||||
|
const pathname = decodeURIComponent(req._parsedUrl.pathname) || '/';
|
||||||
|
if(be_merge && req.path.startsWith('/share/') && req.query.token){
|
||||||
|
if (req.method.toLowerCase() !== 'get'){
|
||||||
|
res.status(405).send('Method not allowed');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const tokens = $.read(TOKENS_KEY) || [];
|
||||||
|
const token = tokens.find(
|
||||||
|
(t) =>
|
||||||
|
t.token === req.query.token &&
|
||||||
|
`/share/${t.type}/${t.name}` === pathname &&
|
||||||
|
(t.exp == null || t.exp > Date.now()),
|
||||||
|
);
|
||||||
|
if (token){
|
||||||
|
next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (be_merge && fe_path && req.path.indexOf('/',1) == -1) {
|
||||||
|
if (req.path.indexOf('.') == -1){
|
||||||
|
req.url = "/index.html"
|
||||||
|
}
|
||||||
|
const express_ = eval(`require("express")`);
|
||||||
|
const mime_ = eval(`require("mime-types")`);
|
||||||
|
const path_ = eval(`require("path")`);
|
||||||
|
const staticFileMiddleware = express_.static(fe_path, {
|
||||||
|
setHeaders: (res, path) => {
|
||||||
|
const type = mime_.contentType(path_.extname(path));
|
||||||
|
if (type) {
|
||||||
|
res.set('Content-Type', type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
staticFileMiddleware(req, res, next);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res.status(403).end('Forbbiden');
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,7 +241,8 @@ export default function serve() {
|
|||||||
const fe_abs_path = path.resolve(
|
const fe_abs_path = path.resolve(
|
||||||
fe_path || path.join(__dirname, 'frontend'),
|
fe_path || path.join(__dirname, 'frontend'),
|
||||||
);
|
);
|
||||||
if (fe_path) {
|
const be_merge = eval('process.env.SUB_STORE_BACKEND_MERGE');
|
||||||
|
if (fe_path && !be_merge) {
|
||||||
try {
|
try {
|
||||||
fs.accessSync(path.join(fe_abs_path, 'index.html'));
|
fs.accessSync(path.join(fe_abs_path, 'index.html'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ import {
|
|||||||
RequestInvalidError,
|
RequestInvalidError,
|
||||||
} from './errors';
|
} from './errors';
|
||||||
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
||||||
import { SUBS_KEY, COLLECTIONS_KEY, ARTIFACTS_KEY } from '@/constants';
|
import {
|
||||||
|
SUBS_KEY,
|
||||||
|
COLLECTIONS_KEY,
|
||||||
|
ARTIFACTS_KEY,
|
||||||
|
FILES_KEY,
|
||||||
|
} from '@/constants';
|
||||||
import {
|
import {
|
||||||
getFlowHeaders,
|
getFlowHeaders,
|
||||||
parseFlowHeaders,
|
parseFlowHeaders,
|
||||||
@@ -320,9 +325,20 @@ function updateSubscription(req, res) {
|
|||||||
artifact.source = sub.name;
|
artifact.source = sub.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// update all files referring this subscription
|
||||||
|
const allFiles = $.read(FILES_KEY) || [];
|
||||||
|
for (const file of allFiles) {
|
||||||
|
if (
|
||||||
|
file.sourceType === 'subscription' &&
|
||||||
|
file.sourceName == name
|
||||||
|
) {
|
||||||
|
file.sourceName = sub.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$.write(allCols, COLLECTIONS_KEY);
|
$.write(allCols, COLLECTIONS_KEY);
|
||||||
$.write(allArtifacts, ARTIFACTS_KEY);
|
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||||
|
$.write(allFiles, FILES_KEY);
|
||||||
}
|
}
|
||||||
updateByName(allSubs, name, newSub);
|
updateByName(allSubs, name, newSub);
|
||||||
$.write(allSubs, SUBS_KEY);
|
$.write(allSubs, SUBS_KEY);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import {
|
|||||||
SCHEMA_VERSION_KEY,
|
SCHEMA_VERSION_KEY,
|
||||||
ARTIFACTS_KEY,
|
ARTIFACTS_KEY,
|
||||||
RULES_KEY,
|
RULES_KEY,
|
||||||
|
FILES_KEY,
|
||||||
|
TOKENS_KEY,
|
||||||
} from '@/constants';
|
} from '@/constants';
|
||||||
import $ from '@/core/app';
|
import $ from '@/core/app';
|
||||||
|
|
||||||
@@ -55,7 +57,17 @@ function doMigrationV2() {
|
|||||||
const newRules = Object.values(rules);
|
const newRules = Object.values(rules);
|
||||||
$.write(newRules, RULES_KEY);
|
$.write(newRules, RULES_KEY);
|
||||||
|
|
||||||
// 5. delete builtin rules
|
// 5. migrate files
|
||||||
|
const files = $.read(FILES_KEY) || {};
|
||||||
|
const newFiles = Object.values(files);
|
||||||
|
$.write(newFiles, FILES_KEY);
|
||||||
|
|
||||||
|
// 6. migrate tokens
|
||||||
|
const tokens = $.read(TOKENS_KEY) || {};
|
||||||
|
const newTokens = Object.values(tokens);
|
||||||
|
$.write(newTokens, TOKENS_KEY);
|
||||||
|
|
||||||
|
// 7. delete builtin rules
|
||||||
delete $.cache.builtin;
|
delete $.cache.builtin;
|
||||||
$.info('Migration complete!');
|
$.info('Migration complete!');
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export function getPlatformFromUserAgent({ ua, UA, accept }) {
|
|||||||
return 'Clash';
|
return 'Clash';
|
||||||
} else if (ua.indexOf('v2ray') !== -1) {
|
} else if (ua.indexOf('v2ray') !== -1) {
|
||||||
return 'V2Ray';
|
return 'V2Ray';
|
||||||
} else if (ua.indexOf('sing-box') !== -1) {
|
} else if (ua.indexOf('sing-box') !== -1 || ua.indexOf('singbox') !== -1) {
|
||||||
return 'sing-box';
|
return 'sing-box';
|
||||||
} else if (accept.indexOf('application/json') === 0) {
|
} else if (accept.indexOf('application/json') === 0) {
|
||||||
return 'JSON';
|
return 'JSON';
|
||||||
@@ -66,10 +66,12 @@ export function shouldIncludeUnsupportedProxy(platform, ua) {
|
|||||||
UA: ua,
|
UA: ua,
|
||||||
ua: ua.toLowerCase(),
|
ua: ua.toLowerCase(),
|
||||||
});
|
});
|
||||||
if (!['Stash', 'Egern'].includes(target)) {
|
if (!['Stash', 'Egern', 'Loon'].includes(target)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const version = coerce(ua).version;
|
const coerceVersion = coerce(ua);
|
||||||
|
$.log(JSON.stringify(coerceVersion, null, 2));
|
||||||
|
const { version } = coerceVersion;
|
||||||
if (
|
if (
|
||||||
platform === 'Stash' &&
|
platform === 'Stash' &&
|
||||||
target === 'Stash' &&
|
target === 'Stash' &&
|
||||||
@@ -84,6 +86,14 @@ export function shouldIncludeUnsupportedProxy(platform, ua) {
|
|||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// Loon 的 UA 不规范, version 取出来是 build
|
||||||
|
if (
|
||||||
|
platform === 'Loon' &&
|
||||||
|
target === 'Loon' &&
|
||||||
|
gte(version, '838.0.0')
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$.error(`获取版本号失败: ${e}`);
|
$.error(`获取版本号失败: ${e}`);
|
||||||
}
|
}
|
||||||
|
|||||||
4
backend/src/vendor/open-api.js
vendored
4
backend/src/vendor/open-api.js
vendored
@@ -18,6 +18,10 @@ export class OpenAPI {
|
|||||||
this.http = HTTP();
|
this.http = HTTP();
|
||||||
this.env = ENV();
|
this.env = ENV();
|
||||||
|
|
||||||
|
if (isNode) {
|
||||||
|
const dotenv = eval(`require("dotenv")`);
|
||||||
|
dotenv.config();
|
||||||
|
}
|
||||||
this.node = (() => {
|
this.node = (() => {
|
||||||
if (isNode) {
|
if (isNode) {
|
||||||
const fs = eval("require('fs')");
|
const fs = eval("require('fs')");
|
||||||
|
|||||||
Reference in New Issue
Block a user