Skip to content

Commit

Permalink
feat: 支持设置默认 User-Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Nov 24, 2023
1 parent 5f1415d commit 1fc5b76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.101",
"version": "2.14.102",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions backend/src/utils/download.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FILES_KEY, MODULES_KEY } from '@/constants';
import { FILES_KEY, MODULES_KEY, SETTINGS_KEY } from '@/constants';
import { findByName } from '@/utils/database';
import { HTTP, ENV } from '@/vendor/open-api';
import { hex_md5 } from '@/vendor/md5';
Expand Down Expand Up @@ -45,7 +45,8 @@ export default async function download(url, ua) {
}

const { isNode } = ENV();
ua = ua || 'Quantumult%20X/1.0.29 (iPhone14,5; iOS 15.4.1)';
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);
Expand All @@ -63,6 +64,7 @@ export default async function download(url, ua) {
if (!$arguments?.noCache && cached) {
resolve(cached);
} else {
$.info(`Downloading...\nUser-Agent: ${ua}\nURL: ${url}`);
http.get(url)
.then((resp) => {
const body = resp.body;
Expand Down

0 comments on commit 1fc5b76

Please sign in to comment.