feat: 自动更新默认 User-Agent

This commit is contained in:
xream committed 2026-04-10 15:01:50 +08:00
1 parent bdd5635abc
commit 78c7b62b84
4 files changed
+34 -3

No files matched your search

+31
View File
@@ -27,6 +27,37 @@ jobs:
run: |
npm install -g pnpm
cd backend && pnpm i --no-frozen-lockfile
- name: Sync latest mihomo version
run: |
MIHOMO_VERSION="$(curl -fsSL https://github.com/MetaCubeX/mihomo/releases/latest/download/version.txt | tr -d '\r\n')"
test -n "$MIHOMO_VERSION"
echo "Using mihomo version: $MIHOMO_VERSION"
cd backend
MIHOMO_VERSION="$MIHOMO_VERSION" node <<'NODE'
const fs = require('fs');
const files = ['src/utils/download.js', 'src/utils/flow.js'];
const version = process.env.MIHOMO_VERSION;
let replacements = 0;
for (const file of files) {
const source = fs.readFileSync(file, 'utf8');
const next = source.replace(/clash\.meta\/[^"']+/g, () => {
replacements += 1;
return `clash.meta/${version}`;
});
if (next !== source) {
fs.writeFileSync(file, next);
}
}
if (replacements === 0) {
throw new Error('No clash.meta version strings were updated.');
}
console.log(`Updated ${replacements} clash.meta version string(s).`);
NODE
- name: Test
run: |
cd backend
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.21.85",
"version": "2.21.86",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
+1 -1
View File
@@ -102,7 +102,7 @@ export default async function download(
if ($.env.isNode) {
proxy = proxy || eval('process.env.SUB_STORE_BACKEND_DEFAULT_PROXY');
}
const userAgent = ua || defaultUserAgent || 'clash.meta';
const userAgent = ua || defaultUserAgent || 'clash.meta/v1.19.23';
let customHeaders;
if ($arguments?.headers) {
try {
+1 -1
View File
@@ -67,7 +67,7 @@ export async function getFlowHeaders(
if ($.env.isNode) {
proxy = proxy || eval('process.env.SUB_STORE_BACKEND_DEFAULT_PROXY');
}
const userAgent = ua || defaultFlowUserAgent || 'clash.meta/v1.19.16';
const userAgent = ua || defaultFlowUserAgent || 'clash.meta/v1.19.23';
const requestTimeout = timeout || defaultTimeout || 8000;
const id = hex_md5(userAgent + url);
const cached = headersResourceCache.get(id);