mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2025-12-08 00:03:09 +00:00
fix(eslint): fix files which have eslint problems
This commit is contained in:
parent
fe28194445
commit
9d18639464
@ -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)) {
|
||||||
|
|||||||
@ -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",
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -2,42 +2,51 @@ const logger = require('./logger')
|
|||||||
// 预先定义常量和函数引用
|
// 预先定义常量和函数引用
|
||||||
// 中国 IP 段(来源:data/ChineseIPGenerate.csv)
|
// 中国 IP 段(来源:data/ChineseIPGenerate.csv)
|
||||||
const chinaIPRangesRaw = [
|
const chinaIPRangesRaw = [
|
||||||
// 开始IP,结束IP,IP个数,位置
|
// 开始IP, 结束IP, IP个数, 位置
|
||||||
['1.0.1.0','1.0.3.255',768,'福州'],
|
['1.0.1.0', '1.0.3.255', 768, '福州'],
|
||||||
['1.0.8.0','1.0.15.255',2048,'广州'],
|
['1.0.8.0', '1.0.15.255', 2048, '广州'],
|
||||||
['1.0.32.0','1.0.63.255',8192,'广州'],
|
['1.0.32.0', '1.0.63.255', 8192, '广州'],
|
||||||
['1.1.0.0','1.1.0.255',256,'福州'],
|
['1.1.0.0', '1.1.0.255', 256, '福州'],
|
||||||
['1.1.2.0','1.1.63.255',15872,'广州'],
|
['1.1.2.0', '1.1.63.255', 15872, '广州'],
|
||||||
['1.2.0.0','1.2.2.255',768,'北京'],
|
['1.2.0.0', '1.2.2.255', 768, '北京'],
|
||||||
['1.2.4.0','1.2.127.255',31744,'广州'],
|
['1.2.4.0', '1.2.127.255', 31744, '广州'],
|
||||||
['1.3.0.0','1.3.255.255',65536,'广州'],
|
['1.3.0.0', '1.3.255.255', 65536, '广州'],
|
||||||
['1.4.1.0','1.4.127.255',32512,'广州'],
|
['1.4.1.0', '1.4.127.255', 32512, '广州'],
|
||||||
['1.8.0.0','1.8.255.255',65536,'北京'],
|
['1.8.0.0', '1.8.255.255', 65536, '北京'],
|
||||||
['1.10.0.0','1.10.9.255',2560,'福州'],
|
['1.10.0.0', '1.10.9.255', 2560, '福州'],
|
||||||
['1.10.11.0','1.10.127.255',29952,'广州'],
|
['1.10.11.0', '1.10.127.255', 29952, '广州'],
|
||||||
['1.12.0.0','1.15.255.255',262144,'上海'],
|
['1.12.0.0', '1.15.255.255', 262144, '上海'],
|
||||||
['1.18.128.0','1.18.128.255',256,'北京'],
|
['1.18.128.0', '1.18.128.255', 256, '北京'],
|
||||||
['1.24.0.0','1.31.255.255',524288,'赤峰'],
|
['1.24.0.0', '1.31.255.255', 524288, '赤峰'],
|
||||||
['1.45.0.0','1.45.255.255',65536,'北京'],
|
['1.45.0.0', '1.45.255.255', 65536, '北京'],
|
||||||
['1.48.0.0','1.51.255.255',262144,'济南'],
|
['1.48.0.0', '1.51.255.255', 262144, '济南'],
|
||||||
['1.56.0.0','1.63.255.255',524288,'伊春'],
|
['1.56.0.0', '1.63.255.255', 524288, '伊春'],
|
||||||
['1.68.0.0','1.71.255.255',262144,'忻州'],
|
['1.68.0.0', '1.71.255.255', 262144, '忻州'],
|
||||||
['1.80.0.0','1.95.255.255',1048576,'北京'],
|
['1.80.0.0', '1.95.255.255', 1048576, '北京'],
|
||||||
['1.116.0.0','1.117.255.255',131072,'上海'],
|
['1.116.0.0', '1.117.255.255', 131072, '上海'],
|
||||||
['1.119.0.0','1.119.255.255',65536,'北京'],
|
['1.119.0.0', '1.119.255.255', 65536, '北京'],
|
||||||
['1.180.0.0','1.185.255.255',393216,'桂林'],
|
['1.180.0.0', '1.185.255.255', 393216, '桂林'],
|
||||||
['1.188.0.0','1.199.255.255',786432,'洛阳'],
|
['1.188.0.0', '1.199.255.255', 786432, '洛阳'],
|
||||||
['1.202.0.0','1.207.255.255',393216,'铜仁'],
|
['1.202.0.0', '1.207.255.255', 393216, '铜仁'],
|
||||||
]
|
]
|
||||||
|
|
||||||
// 将原始字符串段转换为数值段并计算总数(在模块初始化时完成一次)
|
// 将原始字符串段转换为数值段并计算总数(在模块初始化时完成一次)
|
||||||
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
|
||||||
}
|
}
|
||||||
@ -115,7 +124,7 @@ module.exports = {
|
|||||||
const total = chinaIPRanges.totalCount || 0
|
const total = chinaIPRanges.totalCount || 0
|
||||||
if (!total) {
|
if (!total) {
|
||||||
// 兜底:回退到旧逻辑(随机 116.x 前缀)
|
// 兜底:回退到旧逻辑(随机 116.x 前缀)
|
||||||
const fallback = `116.${getRandomInt(25,94)}.${generateIPSegment()}.${generateIPSegment()}`
|
const fallback = `116.${getRandomInt(25, 94)}.${generateIPSegment()}.${generateIPSegment()}`
|
||||||
logger.info('Generated Random Chinese IP (fallback):', fallback)
|
logger.info('Generated Random Chinese IP (fallback):', fallback)
|
||||||
return fallback
|
return fallback
|
||||||
}
|
}
|
||||||
@ -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的函数
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user