Skip to content

Commit c14de2e

Browse files
committed
p2p/nat: tweak port mapping log messages and levels
People stil get confused about the messages. This commit changes the levels so that the only thing printed at the default level (info) is a successful mapping.
1 parent e7c7b54 commit c14de2e

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎p2p/nat/nat.go‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ func Map(m Interface, c chan struct{}, protocol string, extport, intport int, na
8686
refresh := time.NewTimer(mapUpdateInterval)
8787
defer func() {
8888
refresh.Stop()
89-
glog.V(logger.Debug).Infof("Deleting port mapping: %s %d -> %d (%s) using %s\n", protocol, extport, intport, name, m)
89+
glog.V(logger.Debug).Infof("deleting port mapping: %s %d -> %d (%s) using %s\n", protocol, extport, intport, name, m)
9090
m.DeleteMapping(protocol, extport, intport)
9191
}()
92-
glog.V(logger.Debug).Infof("add mapping: %s %d -> %d (%s) using %s\n", protocol, extport, intport, name, m)
9392
if err := m.AddMapping(protocol, intport, extport, name, mapTimeout); err != nil {
94-
glog.V(logger.Warn).Infof("network port %d could not be mapped: %v\n", intport, err)
95-
glog.V(logger.Debug).Infof("mapping with %v returned %v\n", m, err)
93+
glog.V(logger.Debug).Infof("network port %s:%d could not be mapped: %v\n", protocol, intport, err)
94+
} else {
95+
glog.V(logger.Info).Infof("mapped network port %s:%d -> %d (%s) using %s\n", protocol, extport, intport, name, m)
9696
}
9797
for {
9898
select {
@@ -101,10 +101,9 @@ func Map(m Interface, c chan struct{}, protocol string, extport, intport int, na
101101
return
102102
}
103103
case <-refresh.C:
104-
glog.V(logger.Detail).Infof("refresh mapping: %s %d -> %d (%s) using %s\n", protocol, extport, intport, name, m)
104+
glog.V(logger.Detail).Infof("refresh port mapping %s:%d -> %d (%s) using %s\n", protocol, extport, intport, name, m)
105105
if err := m.AddMapping(protocol, intport, extport, name, mapTimeout); err != nil {
106-
glog.V(logger.Warn).Infof("network port %d could not be mapped: %v\n", intport, err)
107-
glog.V(logger.Debug).Infof("mapping with %v returned %v\n", m, err)
106+
glog.V(logger.Debug).Infof("network port %s:%d could not be mapped: %v\n", protocol, intport, err)
108107
}
109108
refresh.Reset(mapUpdateInterval)
110109
}

0 commit comments

Comments
 (0)