From df16045704cbe5f8f5873d0b18c2fe7f0dba2e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Thu, 11 Jul 2024 11:29:24 +0800 Subject: [PATCH] =?UTF-8?q?optimize:=20DNS=E6=9F=A5=E8=AF=A2=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=A2=9E=E5=8A=A0cost=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/mitmproxy/src/lib/dns/https.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/mitmproxy/src/lib/dns/https.js b/packages/mitmproxy/src/lib/dns/https.js index f6f90c2..5421e87 100644 --- a/packages/mitmproxy/src/lib/dns/https.js +++ b/packages/mitmproxy/src/lib/dns/https.js @@ -38,22 +38,23 @@ module.exports = class DNSOverHTTPS extends BaseDNS { } // 未预设当前域名的IP列表,则从dns服务器获取 + const start = new Date() try { const result = await dohQueryAsync({ url: this.dnsServer }, [{ type: 'A', name: hostname }]) if (result.answers.length === 0) { // 说明没有获取到ip - log.info('该域名没有ip地址解析:', hostname) + log.info('该域名没有ip地址解析:', hostname, ', cost:', (new Date() - start), 'ms') return [] } const ret = result.answers.filter(item => item.type === 'A').map(item => item.data) if (ret.length === 0) { - log.info('该域名没有IPv4地址解析:', hostname) + log.info('该域名没有IPv4地址解析:', hostname, ', cost:', (new Date() - start), 'ms') } else { - log.info('获取到域名地址:', hostname, JSON.stringify(ret)) + log.info('获取到域名地址:', hostname, JSON.stringify(ret), ', cost:', (new Date() - start), 'ms') } return ret } catch (e) { - log.warn('DNS query error:', hostname, ', dns:', this.dnsServer, ', error:', e) + log.warn('DNS query error:', hostname, ', dns:', this.dnsServer, ', cost:', (new Date() - start), 'ms, error:', e) return [] } }