dump flap on errors

This commit is contained in:
Artem Titoulenko 2022-01-22 20:57:27 -05:00
parent 2b06886058
commit 0d201678de
3 changed files with 7 additions and 3 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ dist
aim-oscar aim-oscar
aim.db aim.db
vendor vendor
.DS_Store

View file

@ -170,7 +170,9 @@ func main() {
handleFn := func(ctx context.Context, flap *oscar.FLAP) context.Context { handleFn := func(ctx context.Context, flap *oscar.FLAP) context.Context {
session, err := oscar.SessionFromContext(ctx) session, err := oscar.SessionFromContext(ctx)
if err != nil { 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 { if user := models.UserFromContext(ctx); user != nil {

View file

@ -4,6 +4,7 @@ import (
"aim-oscar/util" "aim-oscar/util"
"context" "context"
"encoding/binary" "encoding/binary"
"fmt"
"io" "io"
"log" "log"
"net" "net"
@ -37,8 +38,7 @@ func (h *Handler) Handle(conn net.Conn) {
// send a hello // send a hello
hello := NewFLAP(1) hello := NewFLAP(1)
hello.Data.Write([]byte{0, 0, 0, 1}) hello.Data.Write([]byte{0, 0, 0, 1})
err := session.Send(hello) session.Send(hello)
util.PanicIfError(err)
session.GreetedClient = true session.GreetedClient = true
} }
@ -65,6 +65,7 @@ func (h *Handler) Handle(conn net.Conn) {
flapLength := int(dataLength) + 6 flapLength := int(dataLength) + 6
if len(buf) < flapLength { if len(buf) < flapLength {
log.Printf("not enough data, only %d bytes\n", len(buf)) log.Printf("not enough data, only %d bytes\n", len(buf))
fmt.Printf("%s\n", util.PrettyBytes(buf))
break break
} }