mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: adjust code
This commit is contained in:
parent
7166db2ac9
commit
83e0abaa8c
|
@ -15,6 +15,9 @@ func LoaderName() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetLoader(newLoader string) {
|
func SetLoader(newLoader string) {
|
||||||
|
if newLoader == "memc" {
|
||||||
|
newLoader = "memconservative"
|
||||||
|
}
|
||||||
geoLoaderName = newLoader
|
geoLoaderName = newLoader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ func (sd *SnifferDispatcher) Tcp(conn net.Conn, metadata *C.Metadata) {
|
||||||
if metadata.Host != "" {
|
if metadata.Host != "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sd.cover(bufConn, metadata)
|
sd.cover(bufConn, metadata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,24 +53,23 @@ func (sd *SnifferDispatcher) cover(conn *CN.BufferedConn, metadata *C.Metadata)
|
||||||
bufferedLen := conn.Buffered()
|
bufferedLen := conn.Buffered()
|
||||||
bytes, err := conn.Peek(bufferedLen)
|
bytes, err := conn.Peek(bufferedLen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnln("the data lenght not enough")
|
log.Debugln("[Sniffer] the data lenght not enough")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
host, err := sniffer.SniffTCP(bytes)
|
host, err := sniffer.SniffTCP(bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnln("Sniff data failed on Sniffer[%s]", sniffer.Protocol())
|
log.Debugln("[Sniffer][%s] Sniff data failed", sniffer.Protocol())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata.Host = host
|
metadata.Host = host
|
||||||
metadata.AddrType = C.AtypDomainName
|
metadata.AddrType = C.AtypDomainName
|
||||||
|
log.Debugln("[Sniffer][%s] %s --> %s", sniffer.Protocol(), metadata.DstIP, metadata.Host)
|
||||||
if resolver.FakeIPEnabled() {
|
if resolver.FakeIPEnabled() {
|
||||||
metadata.DNSMode = C.DNSFakeIP
|
metadata.DNSMode = C.DNSFakeIP
|
||||||
} else {
|
} else {
|
||||||
metadata.DNSMode = C.DNSMapping
|
metadata.DNSMode = C.DNSMapping
|
||||||
}
|
}
|
||||||
|
|
||||||
resolver.InsertHostByIP(metadata.DstIP, host)
|
resolver.InsertHostByIP(metadata.DstIP, host)
|
||||||
metadata.DstIP = nil
|
metadata.DstIP = nil
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user