Browse Source

discovery: more verbose logging

bboozzoo/golang
Maciek Borzecki 7 years ago
parent
commit
64c7ebfac6
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      discovery/listener.go

+ 13
- 0
discovery/listener.go View File

@ -16,6 +16,7 @@ import (
"net" "net"
"github.com/bboozzoo/mconnect/logger" "github.com/bboozzoo/mconnect/logger"
"github.com/bboozzoo/mconnect/protocol/packet"
) )
type Listener struct { type Listener struct {
@ -48,4 +49,16 @@ func (l *Listener) Receive(ctx context.Context) {
log.Printf("got %v bytes from %v", count, addr) log.Printf("got %v bytes from %v", count, addr)
log.Printf("data:\n%s", string(buf)) log.Printf("data:\n%s", string(buf))
p, err := packet.FromData(buf)
if err != nil {
log.Errorf("failed to parse packet: %v", err)
return
}
log.Printf("packet: %+v", p)
identity, err := p.AsIdentity()
if err != nil {
log.Errorf("failed to parse identity packet: %v", err)
return
}
log.Printf("identity: %+v", identity)
} }

Loading…
Cancel
Save