From c83eb2e0c9d7ed88ac234a657acde05beccb879f Mon Sep 17 00:00:00 2001 From: Skyxim Date: Tue, 7 Feb 2023 21:29:40 +0800 Subject: [PATCH] chore: adjust log --- component/sniffer/dispatcher.go | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/component/sniffer/dispatcher.go b/component/sniffer/dispatcher.go index 0d6badf5..4faedfb0 100644 --- a/component/sniffer/dispatcher.go +++ b/component/sniffer/dispatcher.go @@ -94,29 +94,19 @@ func (sd *SnifferDispatcher) TCPSniff(conn net.Conn, metadata *C.Metadata) { } func (sd *SnifferDispatcher) replaceDomain(metadata *C.Metadata, host string, overrideDest bool) { - dstIP := "" - if metadata.DstIP.IsValid() { - dstIP = metadata.DstIP.String() - } originHost := metadata.Host if originHost != host { - log.Infoln("[Sniffer] Sniff TCP [%s]-->[%s:%s] success, replace domain [%s]-->[%s]", - metadata.SourceDetail(), - dstIP, metadata.DstPort, - metadata.Host, host) - } else { - log.Debugln("[Sniffer] Sniff TCP [%s]-->[%s:%s] success, replace domain [%s]-->[%s]", - metadata.SourceDetail(), - dstIP, metadata.DstPort, - metadata.Host, host) + if overrideDest { + metadata.Host = host + } else { + metadata.SniffHost = host + } + metadata.DNSMode = C.DNSNormal } - - if overrideDest { - metadata.Host = host - } else { - metadata.SniffHost = host - } - metadata.DNSMode = C.DNSNormal + log.Debugln("[Sniffer] Sniff TCP [%s]-->[%s] success, replace domain [%s]-->[%s]", + metadata.SourceDetail(), + metadata.RemoteAddress(), + metadata.Host, host) } func (sd *SnifferDispatcher) Enable() bool {