From 77b38b3285527c060bb2a45de81b65d640c32ee1 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Wed, 25 Dec 2019 12:01:48 +0800 Subject: [PATCH] Chore: distinguish udp request in log (#449) --- dns/iputil.go | 2 +- tunnel/tunnel.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dns/iputil.go b/dns/iputil.go index 3c34cf16..f186e5a0 100644 --- a/dns/iputil.go +++ b/dns/iputil.go @@ -7,7 +7,7 @@ import ( ) var ( - errIPNotFound = errors.New("cannot found ip") + errIPNotFound = errors.New("couldn't find ip") errIPVersion = errors.New("ip version error") ) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index a578a490..69765e70 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -182,7 +182,7 @@ func (t *Tunnel) handleUDPConn(localConn C.ServerAdapter) { wg.Add(1) proxy, rule, err := t.resolveMetadata(metadata) if err != nil { - log.Warnln("Parse metadata failed: %s", err.Error()) + log.Warnln("[UDP] Parse metadata failed: %s", err.Error()) t.natTable.Delete(lockKey) wg.Done() return @@ -190,7 +190,7 @@ func (t *Tunnel) handleUDPConn(localConn C.ServerAdapter) { rawPc, nAddr, err := proxy.DialUDP(metadata) if err != nil { - log.Warnln("dial %s error: %s", proxy.Name(), err.Error()) + log.Warnln("[UDP] dial %s error: %s", proxy.Name(), err.Error()) t.natTable.Delete(lockKey) wg.Done() return @@ -199,9 +199,9 @@ func (t *Tunnel) handleUDPConn(localConn C.ServerAdapter) { pc = newUDPTracker(rawPc, DefaultManager, metadata, rule) if rule != nil { - log.Infoln("%s --> %v match %s using %s", metadata.SrcIP.String(), metadata.String(), rule.RuleType().String(), rawPc.Chains().String()) + log.Infoln("[UDP] %s --> %v match %s using %s", metadata.SrcIP.String(), metadata.String(), rule.RuleType().String(), rawPc.Chains().String()) } else { - log.Infoln("%s --> %v doesn't match any rule using DIRECT", metadata.SrcIP.String(), metadata.String()) + log.Infoln("[UDP] %s --> %v doesn't match any rule using DIRECT", metadata.SrcIP.String(), metadata.String()) } t.natTable.Set(key, pc, addr)