mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-09-15 02:33:13 +08:00
feat: Sub-Store 生成的订阅地址支持传入 订阅链接/User-Agent/节点内容 可以复用此订阅的其他设置
例如: 建一个 name 为 sub 的订阅, 配置好节点操作 以后可以自由传入参数 无需在 Sub-Store 前端创建新的配置 `/download/sub?target=Surge&content=encodeURIComponent编码过的本地节点` `/download/sub?target=Surge&url=encodeURIComponent编码过的订阅链接&ua=encodeURIComponent编码过的User-Agent`
This commit is contained in:
parent
f3de132d70
commit
53925518b4
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.90",
|
"version": "2.14.91",
|
||||||
"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": {
|
||||||
|
@ -20,6 +20,16 @@ async function downloadSubscription(req, res) {
|
|||||||
req.query.target || getPlatformFromHeaders(req.headers) || 'JSON';
|
req.query.target || getPlatformFromHeaders(req.headers) || 'JSON';
|
||||||
|
|
||||||
$.info(`正在下载订阅:${name}`);
|
$.info(`正在下载订阅:${name}`);
|
||||||
|
const { url, ua, content } = req.query;
|
||||||
|
if (url) {
|
||||||
|
$.info(`指定 url: ${url}`);
|
||||||
|
}
|
||||||
|
if (ua) {
|
||||||
|
$.info(`指定 ua: ${ua}`);
|
||||||
|
}
|
||||||
|
if (content) {
|
||||||
|
$.info(`指定 content: ${content}`);
|
||||||
|
}
|
||||||
|
|
||||||
const allSubs = $.read(SUBS_KEY);
|
const allSubs = $.read(SUBS_KEY);
|
||||||
const sub = findByName(allSubs, name);
|
const sub = findByName(allSubs, name);
|
||||||
@ -29,12 +39,15 @@ async function downloadSubscription(req, res) {
|
|||||||
type: 'subscription',
|
type: 'subscription',
|
||||||
name,
|
name,
|
||||||
platform,
|
platform,
|
||||||
|
url,
|
||||||
|
ua,
|
||||||
|
content,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (sub.source !== 'local') {
|
if (sub.source !== 'local' || url) {
|
||||||
try {
|
try {
|
||||||
// forward flow headers
|
// forward flow headers
|
||||||
const flowInfo = await getFlowHeaders(sub.url);
|
const flowInfo = await getFlowHeaders(url || sub.url);
|
||||||
if (flowInfo) {
|
if (flowInfo) {
|
||||||
res.set('subscription-userinfo', flowInfo);
|
res.set('subscription-userinfo', flowInfo);
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,18 @@ export default function register($app) {
|
|||||||
$app.get('/api/sync/artifact/:name', syncArtifact);
|
$app.get('/api/sync/artifact/:name', syncArtifact);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function produceArtifact({ type, name, platform }) {
|
async function produceArtifact({ type, name, platform, url, ua, content }) {
|
||||||
platform = platform || 'JSON';
|
platform = platform || 'JSON';
|
||||||
|
|
||||||
if (type === 'subscription') {
|
if (type === 'subscription') {
|
||||||
const allSubs = $.read(SUBS_KEY);
|
const allSubs = $.read(SUBS_KEY);
|
||||||
const sub = findByName(allSubs, name);
|
const sub = findByName(allSubs, name);
|
||||||
let raw;
|
let raw;
|
||||||
if (sub.source === 'local') {
|
if (url) {
|
||||||
|
raw = await download(url, ua);
|
||||||
|
} else if (content) {
|
||||||
|
raw = content;
|
||||||
|
} else if (sub.source === 'local') {
|
||||||
raw = sub.content;
|
raw = sub.content;
|
||||||
} else {
|
} else {
|
||||||
raw = await download(sub.url, sub.ua);
|
raw = await download(sub.url, sub.ua);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user