netcheck, stunner: reduce log spam

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/115/head
Brad Fitzpatrick 5 years ago
parent 19b54d0ae7
commit f3c0ea23d9

@ -19,7 +19,7 @@ func runNetcheck(ctx context.Context, args []string) error {
defer cancel() defer cancel()
report, err := netcheck.GetReport(ctx, log.Printf) report, err := netcheck.GetReport(ctx, log.Printf)
if err != nil { if err != nil {
log.Fatal(err) log.Fatalf("netcheck: %v", err)
} }
fmt.Printf("\nReport:\n") fmt.Printf("\nReport:\n")
fmt.Printf("\t* UDP: %v\n", report.UDP) fmt.Printf("\t* UDP: %v\n", report.UDP)

@ -91,7 +91,6 @@ func GetReport(ctx context.Context, logf logger.Logf) (*Report, error) {
logf("ReadFrom: unexpected addr %T", addr) logf("ReadFrom: unexpected addr %T", addr)
continue continue
} }
logf("Packet from %v: %q", ua, buf[:n])
s.Receive(buf[:n], ua) s.Receive(buf[:n], ua)
} }
@ -120,7 +119,9 @@ func GetReport(ctx context.Context, logf logger.Logf) (*Report, error) {
} }
err = grp.Wait() err = grp.Wait()
logf("stunner.Run: %v", err) if err != nil {
return nil, err
}
mu.Lock() mu.Lock()
defer mu.Unlock() // unnecessary, but feels weird without defer mu.Unlock() // unnecessary, but feels weird without

@ -112,7 +112,6 @@ func (s *Stunner) Receive(p []byte, fromAddr *net.UDPAddr) {
session := s.sessions[r.server] session := s.sessions[r.server]
if session != nil { if session != nil {
host := net.JoinHostPort(net.IP(addr).String(), fmt.Sprint(port)) 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) s.Endpoint(r.server, host, d)
session.cancel() session.cancel()
} }
@ -127,6 +126,10 @@ func (s *Stunner) resolver() *net.Resolver {
// Run starts a Stunner and blocks until all servers either respond // Run starts a Stunner and blocks until all servers either respond
// or are tried multiple times and timeout. // 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 { func (s *Stunner) Run(ctx context.Context) error {
s.sessions = map[string]*session{} s.sessions = map[string]*session{}
for _, server := range s.Servers { for _, server := range s.Servers {

Loading…
Cancel
Save