feat: 支持显示加密方式

This commit is contained in:
ElyPrism 2026-06-18 23:46:11 +08:00
parent 6fc4231142
commit eb07a525eb
No known key found for this signature in database
2 changed files with 14 additions and 13 deletions

View File

@ -10,6 +10,7 @@ const { cookieToJson } = require('./util/index')
const fileUpload = require('express-fileupload') const fileUpload = require('express-fileupload')
const decode = require('safe-decode-uri-component') const decode = require('safe-decode-uri-component')
const logger = require('./util/logger.js') const logger = require('./util/logger.js')
const { APP_CONF } = require('./util/config.json')
/** /**
* The version check result. * The version check result.
@ -299,15 +300,15 @@ async function constructServer(moduleDefs) {
) )
try { try {
let usedCrypto = ''
const moduleResponse = await moduleDef.module(query, (...params) => { const moduleResponse = await moduleDef.module(query, (...params) => {
// 参数注入客户端IP
const obj = [...params] const obj = [...params]
const options = obj[2] || {} const options = obj[2] || {}
usedCrypto = options.crypto || ''
let ip = '' let ip = ''
if (options.randomCNIP) { if (options.randomCNIP) {
ip = global.cnIp ip = global.cnIp
// logger.info('Using random Chinese IP for request:', ip)
} else { } else {
ip = req.ip ip = req.ip
@ -317,7 +318,6 @@ async function constructServer(moduleDefs) {
if (ip == '::1') { if (ip == '::1') {
ip = global.cnIp ip = global.cnIp
} }
// logger.info('Requested from ip:', ip)
} }
obj[2] = { obj[2] = {
@ -327,7 +327,10 @@ async function constructServer(moduleDefs) {
return request(...obj) return request(...obj)
}) })
logger.info(`Request Success: ${decode(req.originalUrl)}`) const displayCrypto = usedCrypto || (APP_CONF.encrypt ? 'eapi' : 'api')
logger.info(
`Request Success: [${displayCrypto}] ${decode(req.originalUrl)}`,
)
// 夹带私货部分如果开启了通用解锁并且是获取歌曲URL的接口则尝试解锁如果需要的话ヾ(≧▽≦*)o // 夹带私货部分如果开启了通用解锁并且是获取歌曲URL的接口则尝试解锁如果需要的话ヾ(≧▽≦*)o
if ( if (
@ -422,7 +425,7 @@ async function serveNcmApi(options) {
options.checkVersion && options.checkVersion &&
checkVersion().then(({ npmVersion, ourVersion, status }) => { checkVersion().then(({ npmVersion, ourVersion, status }) => {
if (status == VERSION_CHECK_RESULT.NOT_LATEST) { if (status == VERSION_CHECK_RESULT.NOT_LATEST) {
logger.info( logger.warn(
`最新版本: ${npmVersion}, 当前版本: ${ourVersion}, 请及时更新`, `最新版本: ${npmVersion}, 当前版本: ${ourVersion}, 请及时更新`,
) )
} }
@ -444,11 +447,9 @@ async function serveNcmApi(options) {
`) `)
logger.info(` logger.info(
- Server started successfully @ http://${host ? host : 'localhost'}:${port} `Server started successfully @ http://${host ? host : 'localhost'}:${port}`,
- Environment: ${process.env.NODE_ENV || 'development'} )
- Node Version: ${process.version}
- Process ID: ${process.pid}`)
}) })
return appExt return appExt

View File

@ -62,9 +62,9 @@ const chinaIPRanges = (function loadChinaIPRanges() {
// attach total for convenience // attach total for convenience
arr.totalCount = total arr.totalCount = total
logger.info( // logger.info(
`Loaded ${arr.length} Chinese IP ranges from china_ip_ranges.txt, total ${total} IPs`, // `Loaded ${arr.length} Chinese IP ranges from china_ip_ranges.txt, total ${total} IPs`,
) // )
return arr return arr
} catch (error) { } catch (error) {
logger.error('Failed to load china_ip_ranges.txt:', error.message) logger.error('Failed to load china_ip_ranges.txt:', error.message)