From 0d201678de3bd988659b29f1ef53c675e10e1a01 Mon Sep 17 00:00:00 2001 From: Artem Titoulenko Date: Sat, 22 Jan 2022 20:57:27 -0500 Subject: [PATCH] dump flap on errors --- .gitignore | 1 + main.go | 4 +++- oscar/server.go | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c830eef..4dfe302 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dist aim-oscar aim.db vendor +.DS_Store diff --git a/main.go b/main.go index e4c6c44..20b2a6c 100644 --- a/main.go +++ b/main.go @@ -170,7 +170,9 @@ func main() { handleFn := func(ctx context.Context, flap *oscar.FLAP) context.Context { session, err := oscar.SessionFromContext(ctx) if err != nil { - util.PanicIfError(err) + // TODO + log.Printf("no session in context. FLAP dump:\n%s\n", flap) + return ctx } if user := models.UserFromContext(ctx); user != nil { diff --git a/oscar/server.go b/oscar/server.go index cb586bb..243039a 100644 --- a/oscar/server.go +++ b/oscar/server.go @@ -4,6 +4,7 @@ import ( "aim-oscar/util" "context" "encoding/binary" + "fmt" "io" "log" "net" @@ -37,8 +38,7 @@ func (h *Handler) Handle(conn net.Conn) { // send a hello hello := NewFLAP(1) hello.Data.Write([]byte{0, 0, 0, 1}) - err := session.Send(hello) - util.PanicIfError(err) + session.Send(hello) session.GreetedClient = true } @@ -65,6 +65,7 @@ func (h *Handler) Handle(conn net.Conn) { flapLength := int(dataLength) + 6 if len(buf) < flapLength { log.Printf("not enough data, only %d bytes\n", len(buf)) + fmt.Printf("%s\n", util.PrettyBytes(buf)) break }