Skip to content

Commit

Permalink
feat: produceArtifact 方法支持传入自定义 subscription; VLESS 非 reality 删除空 flow
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Mar 10, 2024
1 parent aaef97c commit 078bf22
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.244",
"version": "2.14.245",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions backend/src/core/proxy-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ function lastParse(proxy) {
delete proxy.ports;
}
if (['vless'].includes(proxy.type)) {
// 非 reality, 空 flow 没有意义
if (!proxy['reality-opts'] && !proxy.flow) {
delete proxy.flow;
}
if (['http'].includes(proxy.network)) {
let transportPath = proxy[`${proxy.network}-opts`]?.path;
if (!transportPath) {
Expand Down
1 change: 1 addition & 0 deletions backend/src/core/proxy-utils/parsers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ function URI_VLESS() {
proxy[`${params.security}-opts`] = opts;
}
}

proxy.network = params.type;
if (proxy.network === 'tcp' && params.headerType === 'http') {
proxy.network = 'http';
Expand Down
14 changes: 11 additions & 3 deletions backend/src/restful/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ async function produceArtifact({
ignoreFailedRemoteFile,
produceType,
produceOpts = {},
subscription,
}) {
platform = platform || 'JSON';

if (type === 'subscription') {
const allSubs = $.read(SUBS_KEY);
const sub = findByName(allSubs, name);
if (!sub) throw new Error(`找不到订阅 ${name}`);
let sub;
if (name) {
const allSubs = $.read(SUBS_KEY);
sub = findByName(allSubs, name);
if (!sub) throw new Error(`找不到订阅 ${name}`);
} else if (subscription) {
sub = subscription;
} else {
throw new Error('未提供订阅名称或订阅数据');
}
let raw;
if (content && !['localFirst', 'remoteFirst'].includes(mergeSources)) {
raw = content;
Expand Down

0 comments on commit 078bf22

Please sign in to comment.