fix(eslint): fix files which have eslint problems

This commit is contained in:
MoeFurina 2025-11-15 13:25:09 +08:00
parent fe28194445
commit 9d18639464
5 changed files with 52 additions and 38 deletions

View File

@ -17,7 +17,7 @@ module.exports = async (query, request) => {
if (query.unblock === 'true') { if (query.unblock === 'true') {
try { try {
const result = await match(query.id, source) const result = await match(query.id, source)
logger.info('开始解灰', query.id, result) logger.info('Starting unblock(uses modules unblock):', query.id, result)
// avoid optional chaining for compatibility // avoid optional chaining for compatibility
let url let url
if (Array.isArray(result)) { if (Array.isArray(result)) {

View File

@ -1,6 +1,6 @@
{ {
"name": "@neteasecloudmusicapienhanced/api", "name": "@neteasecloudmusicapienhanced/api",
"version": "4.29.16", "version": "4.29.17",
"description": "为停更的网易云音乐 NodeJs API 提供持续的维护!", "description": "为停更的网易云音乐 NodeJs API 提供持续的维护!",
"scripts": { "scripts": {
"dev": "nodemon app.js", "dev": "nodemon app.js",

View File

@ -235,7 +235,7 @@ async function consturctServer(moduleDefs) {
if (ip == '::1') { if (ip == '::1') {
ip = global.cnIp ip = global.cnIp
} }
// logger.info(ip) logger.info('Requested from ip:', ip)
obj[3] = { obj[3] = {
...obj[3], ...obj[3],
ip, ip,
@ -258,11 +258,11 @@ async function consturctServer(moduleDefs) {
const source = process.env.UNBLOCK_SOURCE const source = process.env.UNBLOCK_SOURCE
? process.env.UNBLOCK_SOURCE.split(',') ? process.env.UNBLOCK_SOURCE.split(',')
: ['pyncmd', 'bodian', 'kuwo', 'qq', 'migu', 'kugou'] : ['pyncmd', 'bodian', 'kuwo', 'qq', 'migu', 'kugou']
logger.info('Starting unblock:', source) logger.info('Starting unblock(uses general unblock):', source)
const { url } = await match(req.query.id, source) const { url } = await match(req.query.id, source)
song.url = url song.url = url
song.freeTrialInfo = 'null' song.freeTrialInfo = 'null'
logger.info('Unblock success!') logger.info('Unblock success! url:', song.url)
} }
if (song.url && song.url.includes('kuwo')) { if (song.url && song.url.includes('kuwo')) {
const proxy = process.env.PROXY_URL const proxy = process.env.PROXY_URL

View File

@ -6,8 +6,8 @@ describe('测试获取歌曲是否正常', () => {
const qs = { const qs = {
id: 2709812973, id: 2709812973,
level: 'exhigh', level: 'exhigh',
realip: '125.88.253.199', //realip: '125.88.253.199',
// realIP: global.cnIp, realIP: global.cnIp,
} }
axios axios

View File

@ -33,11 +33,20 @@ const chinaIPRangesRaw = [
// 将原始字符串段转换为数值段并计算总数(在模块初始化时完成一次) // 将原始字符串段转换为数值段并计算总数(在模块初始化时完成一次)
function ipToInt(ip) { function ipToInt(ip) {
const parts = ip.split('.').map(Number) const parts = ip.split('.').map(Number)
return ((parts[0] << 24) >>> 0) + (parts[1] << 16) + (parts[2] << 8) + parts[3] const a = (parts[0] << 24) >>> 0
const b = parts[1] << 16
const c = parts[2] << 8
const d = parts[3]
return a + b + c + d
} }
function intToIp(int) { function intToIp(int) {
return [ (int >>> 24) & 0xFF, (int >>> 16) & 0xFF, (int >>> 8) & 0xFF, int & 0xFF ].join('.') return [
(int >>> 24) & 0xff,
(int >>> 16) & 0xff,
(int >>> 8) & 0xff,
int & 0xff,
].join('.')
} }
const chinaIPRanges = (function buildRanges() { const chinaIPRanges = (function buildRanges() {
@ -47,7 +56,7 @@ const chinaIPRanges = (function buildRanges() {
const r = chinaIPRangesRaw[i] const r = chinaIPRangesRaw[i]
const start = ipToInt(r[0]) const start = ipToInt(r[0])
const end = ipToInt(r[1]) const end = ipToInt(r[1])
const count = r[2] || (end - start + 1) const count = r[2] || end - start + 1
arr.push({ start, end, count, location: r[3] || '' }) arr.push({ start, end, count, location: r[3] || '' })
total += count total += count
} }
@ -139,7 +148,12 @@ module.exports = {
const segSize = chosen.end - chosen.start + 1 const segSize = chosen.end - chosen.start + 1
const ipInt = chosen.start + Math.floor(random() * segSize) const ipInt = chosen.start + Math.floor(random() * segSize)
const ip = intToIp(ipInt) const ip = intToIp(ipInt)
logger.info('Generated Random Chinese IP:', ip, 'location:', chosen.location) logger.info(
'Generated Random Chinese IP:',
ip,
'location:',
chosen.location,
)
return ip return ip
}, },
// 生成chainId的函数 // 生成chainId的函数