From 0649a919f40500aadcf85752caecf210303ee835 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sun, 22 Nov 2020 23:38:12 +0800 Subject: [PATCH] Fix: should not log rule when rule = nil --- tunnel/tunnel.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 9844e8f6..1339701a 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -218,7 +218,11 @@ func handleUDPConn(packet *inbound.PacketAdapter) { rawPc, err := proxy.DialUDP(metadata) if err != nil { - log.Warnln("[UDP] dial %s (match %s/%s) to %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.String(), err.Error()) + if rule == nil { + log.Warnln("[UDP] dial %s to %s error: %s", proxy.Name(), metadata.String(), err.Error()) + } else { + log.Warnln("[UDP] dial %s (match %s/%s) to %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.String(), err.Error()) + } return } pc := newUDPTracker(rawPc, DefaultManager, metadata, rule) @@ -263,7 +267,11 @@ func handleTCPConn(localConn C.ServerAdapter) { remoteConn, err := proxy.Dial(metadata) if err != nil { - log.Warnln("[TCP] dial %s (match %s/%s) to %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.String(), err.Error()) + if rule == nil { + log.Warnln("[TCP] dial %s to %s error: %s", proxy.Name(), metadata.String(), err.Error()) + } else { + log.Warnln("[TCP] dial %s (match %s/%s) to %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.String(), err.Error()) + } return } remoteConn = newTCPTracker(remoteConn, DefaultManager, metadata, rule)