mirror of
https://github.com/amigan/aim-oscar-server.git
synced 2025-01-31 13:02:44 -05:00
dump flap on errors
This commit is contained in:
parent
2b06886058
commit
0d201678de
3 changed files with 7 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ dist
|
||||||
aim-oscar
|
aim-oscar
|
||||||
aim.db
|
aim.db
|
||||||
vendor
|
vendor
|
||||||
|
.DS_Store
|
||||||
|
|
4
main.go
4
main.go
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue