Skip to content

Commit

Permalink
turn on httpdns v2
Browse files Browse the repository at this point in the history
  • Loading branch information
nondanee committed Sep 20, 2019
1 parent bf2a97c commit a8b6305
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const dns = host => new Promise((resolve, reject) => require('dns').lookup(host,
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.keys(jsonBody.data).map(key => jsonBody.data[key]).reduce((result, value) => result.concat(value.ip || []), []))

Promise.all([httpdns].map(query => query(hook.target.host.join(','))).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)
Expand Down

0 comments on commit a8b6305

Please sign in to comment.