mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-07-12 16:21:48 +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
|
// forward flow headers
|
||||||
if (
|
const flowInfo = await getFlowHeaders(sub.url);
|
||||||
["QX", "Surge", "Loon", "Clash"].indexOf(
|
if (flowInfo) {
|
||||||
getPlatformFromHeaders(req.headers)
|
res.set("subscription-userinfo", flowInfo);
|
||||||
) !== -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platform === "JSON") {
|
if (platform === "JSON") {
|
||||||
@ -335,6 +322,17 @@ function service() {
|
|||||||
|
|
||||||
$.info(`正在下载组合订阅:${name}`);
|
$.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) {
|
if (collection) {
|
||||||
try {
|
try {
|
||||||
const output = await produceArtifact({
|
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) {
|
function getEnv(req, res) {
|
||||||
const {isNode, isQX, isLoon, isSurge} = ENV();
|
const {isNode, isQX, isLoon, isSurge} = ENV();
|
||||||
let backend = "Node";
|
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