Skip to content

Commit

Permalink
netcheck, stunner: reduce log spam
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
  • Loading branch information
bradfitz committed Feb 28, 2020
1 parent 19b54d0 commit f3c0ea2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/tailscale/netcheck.go
Expand Up @@ -19,7 +19,7 @@ func runNetcheck(ctx context.Context, args []string) error {
defer cancel()
report, err := netcheck.GetReport(ctx, log.Printf)
if err != nil {
log.Fatal(err)
log.Fatalf("netcheck: %v", err)
}
fmt.Printf("\nReport:\n")
fmt.Printf("\t* UDP: %v\n", report.UDP)
Expand Down
5 changes: 3 additions & 2 deletions netcheck/netcheck.go
Expand Up @@ -91,7 +91,6 @@ func GetReport(ctx context.Context, logf logger.Logf) (*Report, error) {
logf("ReadFrom: unexpected addr %T", addr)
continue
}
logf("Packet from %v: %q", ua, buf[:n])
s.Receive(buf[:n], ua)
}

Expand Down Expand Up @@ -120,7 +119,9 @@ func GetReport(ctx context.Context, logf logger.Logf) (*Report, error) {
}

err = grp.Wait()
logf("stunner.Run: %v", err)
if err != nil {
return nil, err
}

mu.Lock()
defer mu.Unlock() // unnecessary, but feels weird without
Expand Down
5 changes: 4 additions & 1 deletion stunner/stunner.go
Expand Up @@ -112,7 +112,6 @@ func (s *Stunner) Receive(p []byte, fromAddr *net.UDPAddr) {
session := s.sessions[r.server]
if session != nil {
host := net.JoinHostPort(net.IP(addr).String(), fmt.Sprint(port))
s.logf("STUN server %s reports public endpoint %s after %v", r.server, host, d)
s.Endpoint(r.server, host, d)
session.cancel()
}
Expand All @@ -127,6 +126,10 @@ func (s *Stunner) resolver() *net.Resolver {

// Run starts a Stunner and blocks until all servers either respond
// or are tried multiple times and timeout.
//
// TODO: this always returns success now. It should return errors
// if certain servers are unavailable probably. Or if all are.
// Or some configured threshold are.
func (s *Stunner) Run(ctx context.Context) error {
s.sessions = map[string]*session{}
for _, server := range s.Servers {
Expand Down

0 comments on commit f3c0ea2

Please sign in to comment.