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.db
vendor
.DS_Store

View file

@ -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 {

View file

@ -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
}