discosrv: Clean up debug logging

This commit is contained in:
Jakob Borg 2014-04-16 15:06:54 +02:00
parent 1bf128612d
commit 116203aef8
2 changed files with 8 additions and 5 deletions

View File

@ -107,16 +107,14 @@ func limit(addr *net.UDPAddr) bool {
if bkt.TakeAvailable(1) != 1 { if bkt.TakeAvailable(1) != 1 {
// Rate limit exceeded; ignore packet // Rate limit exceeded; ignore packet
if debug { if debug {
log.Printf("Rate limit exceeded for", key) log.Println("Rate limit exceeded for", key)
} }
limited++ limited++
return true return true
} else if debug {
log.Printf("Rate limit OK for", key)
} }
} else { } else {
if debug { if debug {
log.Printf("New limiter for", key) log.Println("New limiter for", key)
} }
// One packet per ten seconds average rate, burst ten packets // One packet per ten seconds average rate, burst ten packets
limiter.Add(key, ratelimit.NewBucket(10*time.Second, 10)) limiter.Add(key, ratelimit.NewBucket(10*time.Second, 10))

View File

@ -131,7 +131,7 @@ func (d *Discoverer) sendExternalAnnouncements() {
for errCounter < maxErrors { for errCounter < maxErrors {
if debug { if debug {
dlog.Println("send announcement -> ", remote) dlog.Printf("send announcement -> %v\n%s", remote, hex.Dump(buf))
} }
_, err = conn.WriteTo(buf, remote) _, err = conn.WriteTo(buf, remote)
if err != nil { if err != nil {
@ -140,6 +140,11 @@ func (d *Discoverer) sendExternalAnnouncements() {
} else { } else {
errCounter = 0 errCounter = 0
} }
if debug {
time.Sleep(1 * time.Second)
res := d.externalLookup(d.MyID)
dlog.Println("external lookup check:", res)
}
time.Sleep(d.ExtBroadcastIntv) time.Sleep(d.ExtBroadcastIntv)
} }
log.Printf("discover/write: %v: stopping due to too many errors: %v", remote, err) log.Printf("discover/write: %v: stopping due to too many errors: %v", remote, err)