feat: 拉取文件时 日志输出 User-Agent; 脚本上下文参数 $options 中新增 _req 字段, 包含请求信息

This commit is contained in:
xream 2025-04-08 12:47:02 +08:00
parent e054b71a62
commit 7486517f08
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
3 changed files with 36 additions and 6 deletions

View File

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

View File

@ -111,7 +111,17 @@ async function downloadSubscription(req, res) {
proxy,
noCache,
} = req.query;
let $options = {};
let $options = {
_req: {
method: req.method,
url: req.url,
path: req.path,
query: req.query,
params: req.params,
headers: req.headers,
body: req.body,
},
};
if (req.query.$options) {
try {
// 支持 `#${encodeURIComponent(JSON.stringify({arg1: "1"}))}`
@ -376,7 +386,17 @@ async function downloadCollection(req, res) {
noCache,
} = req.query;
let $options = {};
let $options = {
_req: {
method: req.method,
url: req.url,
path: req.path,
query: req.query,
params: req.params,
headers: req.headers,
body: req.body,
},
};
if (req.query.$options) {
try {
// 支持 `#${encodeURIComponent(JSON.stringify({arg1: "1"}))}`

View File

@ -52,8 +52,8 @@ function createFile(req, res) {
async function getFile(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
$.info(`正在下载文件:${name}`);
const reqUA = req.headers['user-agent'] || req.headers['User-Agent'];
$.info(`正在下载文件:${name}\n请求 User-Agent: ${reqUA}`);
let {
url,
subInfoUrl,
@ -65,7 +65,17 @@ async function getFile(req, res) {
proxy,
noCache,
} = req.query;
let $options = {};
let $options = {
_req: {
method: req.method,
url: req.url,
path: req.path,
query: req.query,
params: req.params,
headers: req.headers,
body: req.body,
},
};
if (req.query.$options) {
try {
// 支持 `#${encodeURIComponent(JSON.stringify({arg1: "1"}))}`