From 4a3d53c7ee6826c3ad29ebbe3e26530cabb898c4 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Tue, 23 Aug 2022 20:12:28 +0800 Subject: [PATCH 1/2] chore: log error --- component/sniffer/dispatcher.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/component/sniffer/dispatcher.go b/component/sniffer/dispatcher.go index cca8f719..82a400e6 100644 --- a/component/sniffer/dispatcher.go +++ b/component/sniffer/dispatcher.go @@ -76,9 +76,13 @@ func (sd *SnifferDispatcher) TCPSniff(conn net.Conn, metadata *C.Metadata) { } func (sd *SnifferDispatcher) replaceDomain(metadata *C.Metadata, host string) { + dstIP := "" + if metadata.DstIP.IsValid() { + dstIP = metadata.DstIP.String() + } log.Debugln("[Sniffer] Sniff TCP [%s:%s]-->[%s:%s] success, replace domain [%s]-->[%s]", metadata.SrcIP, metadata.SrcPort, - metadata.DstIP, metadata.DstPort, + dstIP, metadata.DstPort, metadata.Host, host) metadata.AddrType = C.AtypDomainName From dd2b4f9476b952cb43dcba5f16f11fb7e48372ba Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sun, 2 Oct 2022 20:08:41 +0800 Subject: [PATCH 2/2] chore: pure udp metadata --- tunnel/tunnel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index b83da180..aec6da01 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -269,7 +269,7 @@ func handleUDPConn(packet *inbound.PacketAdapter) { ctx, cancel := context.WithTimeout(context.Background(), C.DefaultUDPTimeout) defer cancel() - rawPc, err := proxy.ListenPacketContext(ctx, metadata) + rawPc, err := proxy.ListenPacketContext(ctx, metadata.Pure()) if err != nil { if rule == nil { log.Warnln("[UDP] dial %s to %s error: %s", proxy.Name(), metadata.RemoteAddress(), err.Error())