fix: 修复注入随机ip不生效

This commit is contained in:
ElyPrism 2026-02-15 00:06:42 +08:00
parent f08f192328
commit bc9d7b949f
No known key found for this signature in database
7 changed files with 20 additions and 15 deletions

View File

@ -7,9 +7,9 @@
!/app.js
!/server.js
!/package.json
!/package-lock.json
!/index.js
!/generateConfig.js
!/main.js
!/data
!/.env
!/pnpm-lock.yaml

View File

@ -16,7 +16,7 @@ updates:
# 自动合并小版本更新的 PR (可选)
# 可以设置针对 patch 或 minor 版本更新自动合并
commit-message:
prefix: "chore(packages):" # PR 合并提交信息的前缀
prefix: "build(packages):" # PR 合并提交信息的前缀
# 更新 GitHub Actions 依赖
- package-ecosystem: "github-actions"

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,6 +2,8 @@
网易云音乐 NodeJS API Enhanced
最后更新于: 2026.2.15
## 灵感来自
[disoul/electron-cloud-music](https://github.com/disoul/electron-cloud-music)

View File

@ -227,7 +227,8 @@ async function consturctServer(moduleDefs) {
const moduleResponse = await moduleDef.module(query, (...params) => {
// 参数注入客户端IP
const obj = [...params]
// 获取请求中的 IP 参数
const options = obj[2] || {}
if (!options.randomCNIP) {
let ip = req.ip
if (ip.substring(0, 7) == '::ffff:') {
@ -238,9 +239,11 @@ async function consturctServer(moduleDefs) {
}
// logger.info('Requested from ip:', ip)
obj[2] = {
...(obj[2] || {}),
...options,
ip,
}
}
return request(...obj)
})
logger.info(`Request Success: ${decode(req.originalUrl)}`)