Compare commits

..

1 Commits

4 changed files with 9 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.141",
"version": "2.14.138",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {

View File

@@ -386,12 +386,10 @@ async function syncAllArtifacts(_, res) {
async function syncArtifact(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
$.info(`开始同步远程配置 ${name}...`);
const allArtifacts = $.read(ARTIFACTS_KEY);
const artifact = findByName(allArtifacts, name);
if (!artifact) {
$.error(`找不到远程配置 ${name}`);
failed(
res,
new ResourceNotFoundError(
@@ -430,7 +428,6 @@ async function syncArtifact(req, res) {
$.write(allArtifacts, ARTIFACTS_KEY);
success(res, artifact);
} catch (err) {
$.error(`远程配置 ${artifact.name} 发生错误: ${err}`);
failed(
res,
new InternalServerError(

View File

@@ -7,7 +7,7 @@ import $ from '@/core/app';
const tasks = new Map();
export default async function download(url, ua, timeout) {
export default async function download(url, ua) {
let $arguments = {};
const rawArgs = url.split('#');
if (rawArgs.length > 1) {
@@ -45,19 +45,17 @@ export default async function download(url, ua, timeout) {
}
const { isNode } = ENV();
const { defaultUserAgent, defaultTimeout } = $.read(SETTINGS_KEY);
const userAgent = ua || defaultUserAgent || 'clash.meta';
const requestTimeout = timeout || defaultTimeout;
const id = hex_md5(userAgent + url);
const { defaultUserAgent } = $.read(SETTINGS_KEY);
ua = ua || defaultUserAgent || 'clash.meta';
const id = hex_md5(ua + url);
if (!isNode && tasks.has(id)) {
return tasks.get(id);
}
const http = HTTP({
headers: {
'User-Agent': userAgent,
'User-Agent': ua,
},
timeout: requestTimeout,
});
const result = new Promise((resolve, reject) => {
@@ -66,9 +64,7 @@ export default async function download(url, ua, timeout) {
if (!$arguments?.noCache && cached) {
resolve(cached);
} else {
$.info(
`Downloading...\nUser-Agent: ${userAgent}\nTimeout: ${requestTimeout}\nURL: ${url}`,
);
$.info(`Downloading...\nUser-Agent: ${ua}\nURL: ${url}`);
http.get(url)
.then((resp) => {
const body = resp.body;

View File

@@ -1,14 +1,6 @@
import { SETTINGS_KEY } from '@/constants';
import { HTTP } from '@/vendor/open-api';
import $ from '@/core/app';
export async function getFlowHeaders(url, ua, timeout) {
const { defaultFlowUserAgent, defaultTimeout } = $.read(SETTINGS_KEY);
const userAgent =
ua ||
defaultFlowUserAgent ||
'Quantumult%20X/1.0.30 (iPhone14,2; iOS 15.6)';
const requestTimeout = timeout || defaultTimeout;
export async function getFlowHeaders(url) {
const http = HTTP();
const { headers } = await http.get({
url: url
@@ -16,9 +8,8 @@ export async function getFlowHeaders(url, ua, timeout) {
.map((i) => i.trim())
.filter((i) => i.length)[0],
headers: {
'User-Agent': userAgent,
'User-Agent': 'Quantumult%20X/1.0.30 (iPhone14,2; iOS 15.6)',
},
timeout: requestTimeout,
});
const subkey = Object.keys(headers).filter((k) =>
/SUBSCRIPTION-USERINFO/i.test(k),