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 !/app.js
!/server.js !/server.js
!/package.json !/package.json
!/package-lock.json
!/index.js !/index.js
!/generateConfig.js !/generateConfig.js
!/main.js !/main.js
!/data !/data
!/.env !/.env
!/pnpm-lock.yaml

View File

@ -16,7 +16,7 @@ updates:
# 自动合并小版本更新的 PR (可选) # 自动合并小版本更新的 PR (可选)
# 可以设置针对 patch 或 minor 版本更新自动合并 # 可以设置针对 patch 或 minor 版本更新自动合并
commit-message: commit-message:
prefix: "chore(packages):" # PR 合并提交信息的前缀 prefix: "build(packages):" # PR 合并提交信息的前缀
# 更新 GitHub Actions 依赖 # 更新 GitHub Actions 依赖
- package-ecosystem: "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 网易云音乐 NodeJS API Enhanced
最后更新于: 2026.2.15
## 灵感来自 ## 灵感来自
[disoul/electron-cloud-music](https://github.com/disoul/electron-cloud-music) [disoul/electron-cloud-music](https://github.com/disoul/electron-cloud-music)

View File

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