mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-04-23 22:29:32 +08:00
Forward subscription-userinfo from the first subscription in a collection
This commit is contained in:
parent
8b1928e2da
commit
4dc40e92ae
@ -164,22 +164,9 @@ function service() {
|
||||
});
|
||||
|
||||
// forward flow headers
|
||||
if (
|
||||
["QX", "Surge", "Loon", "Clash"].indexOf(
|
||||
getPlatformFromHeaders(req.headers)
|
||||
) !== -1
|
||||
) {
|
||||
const {headers} = await $.http.get({
|
||||
url: sub.url,
|
||||
headers: {
|
||||
"User-Agent": "Quantumult/1.0.13 (iPhone10,3; iOS 14.0)",
|
||||
},
|
||||
});
|
||||
const subkey = Object.keys(headers).filter((k) =>
|
||||
/SUBSCRIPTION-USERINFO/i.test(k)
|
||||
)[0];
|
||||
const userinfo = headers[subkey];
|
||||
res.set("subscription-userinfo", userinfo);
|
||||
const flowInfo = await getFlowHeaders(sub.url);
|
||||
if (flowInfo) {
|
||||
res.set("subscription-userinfo", flowInfo);
|
||||
}
|
||||
|
||||
if (platform === "JSON") {
|
||||
@ -335,6 +322,17 @@ function service() {
|
||||
|
||||
$.info(`正在下载组合订阅:${name}`);
|
||||
|
||||
// forward flow header from the first subscription in this collection
|
||||
const allSubs = $.read(SUBS_KEY);
|
||||
const subs = collection["subscriptions"];
|
||||
if (subs.length > 0) {
|
||||
const sub = allSubs[subs[0]];
|
||||
const flowInfo = await getFlowHeaders(sub.url);
|
||||
if (flowInfo) {
|
||||
res.set("subscription-userinfo", flowInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (collection) {
|
||||
try {
|
||||
const output = await produceArtifact({
|
||||
@ -790,6 +788,19 @@ function service() {
|
||||
}
|
||||
}
|
||||
|
||||
async function getFlowHeaders(url) {
|
||||
const {headers} = await $.http.get({
|
||||
url,
|
||||
headers: {
|
||||
"User-Agent": "Quantumult/1.0.13 (iPhone10,3; iOS 14.0)",
|
||||
},
|
||||
});
|
||||
const subkey = Object.keys(headers).filter((k) =>
|
||||
/SUBSCRIPTION-USERINFO/i.test(k)
|
||||
)[0];
|
||||
return headers[subkey];
|
||||
}
|
||||
|
||||
function getEnv(req, res) {
|
||||
const {isNode, isQX, isLoon, isSurge} = ENV();
|
||||
let backend = "Node";
|
||||
|
4
backend/sub-store.min.js
vendored
4
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user