diff --git a/app.js b/app.js index e75f7731..2c649ccf 100644 --- a/app.js +++ b/app.js @@ -39,7 +39,7 @@ if(config.matchOrder){ const candidate = config.matchOrder if(candidate.some((key, index) => index != candidate.indexOf(key))){ console.log('Please check the duplication in match order.') - process.exit(1) + process.exit(1) } else if(candidate.some(key => !provider.includes(key))){ console.log('Please check the availability of match sources.') @@ -66,10 +66,11 @@ server.authentication = config.token || null global.endpoint = config.endpoint if(config.endpoint) server.whitelist.push(escape(config.endpoint)) -const dns = host => new Promise((resolve, reject) => require('dns').lookup(host, {all: true}, (error, records) => error? reject(error) : resolve(records.map(record => record.address)))) -const httpdns = host => require('./request')('POST', 'http://music.httpdns.c.163.com/d', {}, host).then(response => response.json()).then(jsonBody => jsonBody.dns[0].ips) +const dns = host => new Promise((resolve, reject) => require('dns').lookup(host, {all: true}, (error, records) => error ? reject(error) : resolve(records.map(record => record.address)))) +const httpdns = host => require('./request')('POST', 'https://music.httpdns.c.163.com/d', {}, host).then(response => response.json()).then(jsonBody => jsonBody.dns.reduce((result, domain) => result.concat(domain.ips), [])) +const httpdns2 = host => require('./request')('GET', 'https://httpdns.n.netease.com/httpdns/v2/d?domain=' + host).then(response => response.json()).then(jsonBody => Object.values(jsonBody.data).reduce((result, value) => result.concat(value.ip || []), [])) -Promise.all([httpdns(hook.target.host[0])].concat(hook.target.host.map(host => dns(host)))) +Promise.all([httpdns, httpdns2].map(query => query(hook.target.host.join(','))).concat(hook.target.host.map(host => dns(host)))) .then(result => { let extra = Array.from(new Set(result.reduce((merged, array) => merged.concat(array), []))) hook.target.host = hook.target.host.concat(extra)