@@ -26,9 +26,12 @@ function createIpChecker (tester) {
2626}
2727
2828module . exports = {
29- createLookupFunc ( res , dns , action , target , port , isDnsIntercept ) {
29+ createLookupFunc ( res , dnsFamily , action , target , port , isDnsIntercept ) {
3030 target = target ? ( `, target: ${ target } ` ) : ''
3131
32+ const dns = dnsFamily . dns
33+ const family = dnsFamily . family || 4
34+
3235 return ( hostname , options , callback ) => {
3336 const tester = speedTest . getSpeedTester ( hostname , port )
3437 if ( tester ) {
@@ -38,7 +41,6 @@ module.exports = {
3841 if ( res ) {
3942 res . setHeader ( 'DS-DNS-Lookup' , `IpTester: ${ aliveIpObj . host } ${ aliveIpObj . dns === '预设IP' ? 'PreSet' : aliveIpObj . dns } ` )
4043 }
41- const family = aliveIpObj . host . includes ( ':' ) ? 6 : 4
4244 callback ( null , aliveIpObj . host , family )
4345 return
4446 } else {
@@ -48,19 +50,22 @@ module.exports = {
4850
4951 const ipChecker = createIpChecker ( tester )
5052
51- dns . lookup ( hostname , { ipChecker } ) . then ( ( ip ) => {
53+ // TODO: 临时打印下日志
54+ if ( hostname . includes ( 'googlevideo.com' ) || hostname . includes ( 'gvt1.com' ) ) {
55+ log . debug ( `[${ hostname } ] 使用的lookup参数:dns: ${ dns . dnsName } , family: ${ family } ` )
56+ }
57+ dns . lookup ( hostname , { ipChecker, family } ) . then ( ( ip ) => {
5258 if ( isDnsIntercept ) {
5359 isDnsIntercept . dns = dns
5460 isDnsIntercept . hostname = hostname
5561 isDnsIntercept . ip = ip
5662 }
5763
5864 if ( ip !== hostname ) {
59- log . info ( `----- ${ action } : ${ hostname } , use ip from dns '${ dns . dnsName } ': ${ ip } ${ target } -----` )
65+ log . info ( `----- ${ action } : ${ hostname } , use ip from dns '${ dns . dnsName } ': ${ ip } (family: ${ family } ) ${ target } -----` )
6066 if ( res ) {
6167 res . setHeader ( 'DS-DNS-Lookup' , `DNS: ${ ip } ${ dns . dnsName === '预设IP' ? 'PreSet' : dns . dnsName } ` )
6268 }
63- const family = ip . includes ( ':' ) ? 6 : 4
6469 callback ( null , ip , family )
6570 } else {
6671 // 使用默认dns
0 commit comments