File tree Expand file tree Collapse file tree 4 files changed +6
-35
lines changed
packages/mitmproxy/src/lib Expand file tree Collapse file tree 4 files changed +6
-35
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ module.exports = class BaseDNS {
8484
8585 async _lookupInternal ( hostname ) {
8686 // 获取当前域名的预设IP列表
87- let hostnamePreSetIpList = matchUtil . matchHostname ( this . preSetIpList , hostname , ' matched preSetIpList' )
87+ let hostnamePreSetIpList = matchUtil . matchHostname ( this . preSetIpList , hostname , ` matched preSetIpList( ${ this . dnsName } )` )
8888 if ( hostnamePreSetIpList && ( hostnamePreSetIpList . length > 0 || hostnamePreSetIpList . length === undefined ) ) {
8989 if ( hostnamePreSetIpList . length > 0 ) {
9090 hostnamePreSetIpList = hostnamePreSetIpList . slice ( )
Original file line number Diff line number Diff line change @@ -68,16 +68,14 @@ module.exports = {
6868 return dnsMap
6969 } ,
7070 hasDnsLookup ( dnsConfig , hostname ) {
71- let providerName = null
72-
7371 // 先匹配 预设IP配置
74- const hostnamePreSetIpList = matchUtil . matchHostname ( dnsConfig . preSetIpList , hostname , 'matched preSetIpList' )
72+ const hostnamePreSetIpList = matchUtil . matchHostname ( dnsConfig . preSetIpList , hostname , 'matched preSetIpList(hasDnsLookup) ' )
7573 if ( hostnamePreSetIpList ) {
7674 return dnsConfig . dnsMap . PreSet
7775 }
7876
7977 // 再匹配 DNS映射配置
80- providerName = matchUtil . matchHostname ( dnsConfig . mapping , hostname , 'get dns providerName' )
78+ const providerName = matchUtil . matchHostname ( dnsConfig . mapping , hostname , 'get dns providerName' )
8179
8280 // 由于DNS中的usa已重命名为cloudflare,所以做以下处理,为了向下兼容
8381 if ( providerName === 'usa' && dnsConfig . dnsMap . usa == null && dnsConfig . dnsMap . cloudflare != null ) {
Original file line number Diff line number Diff line change 1- const matchUtil = require ( '../../utils/util.match' )
21const BaseDNS = require ( './base' )
32
4- function mapToList ( ipMap ) {
5- const ipList = [ ]
6- for ( const key in ipMap ) {
7- if ( ipMap [ key ] ) { // 配置为 ture 时才生效
8- ipList . push ( key )
9- }
10- }
11- return ipList
12- }
13-
143module . exports = class DNSOverPreSetIpList extends BaseDNS {
154 constructor ( preSetIpList ) {
16- super ( )
17- this . preSetIpList = preSetIpList
5+ super ( 'PreSet' , null , preSetIpList )
186 this . name = 'PreSet'
197 this . type = 'PreSet'
208 }
219
22- async _lookup ( hostname ) {
23- // 获取当前域名的预设IP列表
24- let hostnamePreSetIpList = matchUtil . matchHostname ( this . preSetIpList , hostname , 'matched preSetIpList' )
25- if ( hostnamePreSetIpList && ( hostnamePreSetIpList . length > 0 || hostnamePreSetIpList . length === undefined ) ) {
26- if ( hostnamePreSetIpList . length > 0 ) {
27- hostnamePreSetIpList = hostnamePreSetIpList . slice ( )
28- } else {
29- hostnamePreSetIpList = mapToList ( hostnamePreSetIpList )
30- }
31-
32- if ( hostnamePreSetIpList . length > 0 ) {
33- return hostnamePreSetIpList
34- }
35- }
36-
37- // 未预设当前域名的IP列表
10+ async _lookup ( _hostname ) {
3811 return [ ]
3912 }
4013}
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ class SpeedTester {
7979 }
8080
8181 async getFromOneDns ( dns ) {
82- return await dns . _lookup ( this . hostname )
82+ return await dns . _lookupInternal ( this . hostname )
8383 }
8484
8585 async test ( ) {
You can’t perform that action at this time.
0 commit comments