Skip to content

Commit b6110e8

Browse files
committed
feat: 手动设置的订阅流量信息会附加到订阅自己的流量信息之前
1 parent dea937d commit b6110e8

File tree

3 files changed

+48
-51
lines changed

3 files changed

+48
-51
lines changed

backend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.14.420",
3+
"version": "2.14.421",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/restful/download.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ async function downloadSubscription(req, res) {
213213
}
214214
}
215215
if (sub.subUserinfo) {
216-
res.set('subscription-userinfo', sub.subUserinfo);
216+
res.set(
217+
'subscription-userinfo',
218+
[sub.subUserinfo, res.get('subscription-userinfo')]
219+
.filter((i) => i)
220+
.join('; '),
221+
);
217222
}
218223

219224
if (platform === 'JSON') {
@@ -411,7 +416,12 @@ async function downloadCollection(req, res) {
411416
}
412417
}
413418
if (sub.subUserinfo) {
414-
res.set('subscription-userinfo', sub.subUserinfo);
419+
res.set(
420+
'subscription-userinfo',
421+
[sub.subUserinfo, res.get('subscription-userinfo')]
422+
.filter((i) => i)
423+
.join('; '),
424+
);
415425
}
416426
}
417427

backend/src/restful/subscriptions.js

+35-48
Original file line numberDiff line numberDiff line change
@@ -125,66 +125,53 @@ async function getFlowInfo(req, res) {
125125
);
126126
return;
127127
}
128-
if (sub.subUserinfo) {
129-
try {
130-
const remainingDays = getRmainingDays({
131-
resetDay: $arguments.resetDay,
132-
startDate: $arguments.startDate,
133-
cycleDays: $arguments.cycleDays,
134-
});
135-
const result = {
136-
...parseFlowHeaders(sub.subUserinfo),
137-
};
138-
if (remainingDays != null) {
139-
result.remainingDays = remainingDays;
140-
}
141-
success(res, result);
142-
} catch (e) {
143-
$.error(
144-
`Failed to parse flow info for local subscription ${name}: ${
145-
e.message ?? e
146-
}`,
147-
);
148-
failed(
149-
res,
150-
new RequestInvalidError(
151-
'NO_FLOW_INFO',
152-
'N/A',
153-
`Failed to parse flow info`,
154-
),
155-
);
156-
}
157-
} else {
158-
const flowHeaders = await getFlowHeaders(
159-
$arguments?.insecure ? `${url}#insecure` : url,
160-
$arguments.flowUserAgent,
161-
undefined,
162-
sub.proxy,
163-
$arguments.flowUrl,
128+
const flowHeaders = await getFlowHeaders(
129+
$arguments?.insecure ? `${url}#insecure` : url,
130+
$arguments.flowUserAgent,
131+
undefined,
132+
sub.proxy,
133+
$arguments.flowUrl,
134+
);
135+
if (!flowHeaders && !sub.subUserinfo) {
136+
failed(
137+
res,
138+
new InternalServerError(
139+
'NO_FLOW_INFO',
140+
'No flow info',
141+
`Failed to fetch flow headers`,
142+
),
164143
);
165-
if (!flowHeaders) {
166-
failed(
167-
res,
168-
new InternalServerError(
169-
'NO_FLOW_INFO',
170-
'No flow info',
171-
`Failed to fetch flow headers`,
172-
),
173-
);
174-
return;
175-
}
144+
return;
145+
}
146+
try {
176147
const remainingDays = getRmainingDays({
177148
resetDay: $arguments.resetDay,
178149
startDate: $arguments.startDate,
179150
cycleDays: $arguments.cycleDays,
180151
});
181152
const result = {
182-
...parseFlowHeaders(flowHeaders),
153+
...parseFlowHeaders(
154+
[sub.subUserinfo, flowHeaders].filter((i) => i).join('; '),
155+
),
183156
};
184157
if (remainingDays != null) {
185158
result.remainingDays = remainingDays;
186159
}
187160
success(res, result);
161+
} catch (e) {
162+
$.error(
163+
`Failed to parse flow info for local subscription ${name}: ${
164+
e.message ?? e
165+
}`,
166+
);
167+
failed(
168+
res,
169+
new RequestInvalidError(
170+
'NO_FLOW_INFO',
171+
'N/A',
172+
`Failed to parse flow info`,
173+
),
174+
);
188175
}
189176
} catch (err) {
190177
failed(

0 commit comments

Comments
 (0)