fix: code logic error
This commit is contained in:
parent
815a060309
commit
7166db2ac9
1 changed files with 9 additions and 4 deletions
|
@ -46,9 +46,13 @@ func (sd *SnifferDispatcher) Enable() bool {
|
||||||
func (sd *SnifferDispatcher) cover(conn *CN.BufferedConn, metadata *C.Metadata) {
|
func (sd *SnifferDispatcher) cover(conn *CN.BufferedConn, metadata *C.Metadata) {
|
||||||
for _, sniffer := range sd.sniffers {
|
for _, sniffer := range sd.sniffers {
|
||||||
if sniffer.SupportNetwork() == C.TCP {
|
if sniffer.SupportNetwork() == C.TCP {
|
||||||
conn.Peek(1)
|
_, err := conn.Peek(1)
|
||||||
len := conn.Buffered()
|
if err != nil {
|
||||||
bytes, err := conn.Peek(len)
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
bufferedLen := conn.Buffered()
|
||||||
|
bytes, err := conn.Peek(bufferedLen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnln("the data lenght not enough")
|
log.Warnln("the data lenght not enough")
|
||||||
continue
|
continue
|
||||||
|
@ -61,7 +65,6 @@ func (sd *SnifferDispatcher) cover(conn *CN.BufferedConn, metadata *C.Metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata.Host = host
|
metadata.Host = host
|
||||||
metadata.DstIP = nil
|
|
||||||
metadata.AddrType = C.AtypDomainName
|
metadata.AddrType = C.AtypDomainName
|
||||||
if resolver.FakeIPEnabled() {
|
if resolver.FakeIPEnabled() {
|
||||||
metadata.DNSMode = C.DNSFakeIP
|
metadata.DNSMode = C.DNSFakeIP
|
||||||
|
@ -70,6 +73,8 @@ func (sd *SnifferDispatcher) cover(conn *CN.BufferedConn, metadata *C.Metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
resolver.InsertHostByIP(metadata.DstIP, host)
|
resolver.InsertHostByIP(metadata.DstIP, host)
|
||||||
|
metadata.DstIP = nil
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue