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

This commit is contained in:
MoeFurina
2026-02-15 00:06:42 +08:00
parent f08f192328
commit bc9d7b949f
7 changed files with 20 additions and 15 deletions
+15 -12
View File
@@ -227,20 +227,23 @@ async function consturctServer(moduleDefs) {
const moduleResponse = await moduleDef.module(query, (...params) => {
// 参数注入客户端IP
const obj = [...params]
// 获取请求中的 IP 参数
let ip = req.ip
const options = obj[2] || {}
if (!options.randomCNIP) {
let ip = req.ip
if (ip.substring(0, 7) == '::ffff:') {
ip = ip.substring(7)
}
if (ip == '::1') {
ip = global.cnIp
}
// logger.info('Requested from ip:', ip)
obj[2] = {
...(obj[2] || {}),
ip,
if (ip.substring(0, 7) == '::ffff:') {
ip = ip.substring(7)
}
if (ip == '::1') {
ip = global.cnIp
}
// logger.info('Requested from ip:', ip)
obj[2] = {
...options,
ip,
}
}
return request(...obj)
})
logger.info(`Request Success: ${decode(req.originalUrl)}`)