Skip to content

Commit

Permalink
integrate ICQ into session mangagement
Browse files Browse the repository at this point in the history
  • Loading branch information
mk6i committed Aug 2, 2024
1 parent 58f68d7 commit f5202c9
Show file tree
Hide file tree
Showing 7 changed files with 401 additions and 154 deletions.
15 changes: 13 additions & 2 deletions foodgroup/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net"
"strconv"
"strings"

"github.com/mk6i/retro-aim-server/config"
Expand Down Expand Up @@ -81,7 +82,7 @@ type bosCookie struct {
ScreenName state.DisplayScreenName `oscar:"len_prefix=uint8"`
}

// RegisterBOSSession creates and returns a user's session.
// RegisterBOSSession adds a new session to the session registry.
func (s AuthService) RegisterBOSSession(authCookie []byte) (*state.Session, error) {
buf, err := s.cookieBaker.Crack(authCookie)
if err != nil {
Expand Down Expand Up @@ -109,6 +110,16 @@ func (s AuthService) RegisterBOSSession(authCookie []byte) (*state.Session, erro
sess.SetUserInfoFlag(wire.OServiceUserFlagUnconfirmed)
}

if c.ICQ == 1 {
sess.SetUserInfoFlag(wire.OServiceUserFlagICQ)

uin, err := strconv.Atoi(u.IdentScreenName.String())
if err != nil {
return nil, fmt.Errorf("error converting username to UIN: %w", err)
}
sess.SetUIN(uint32(uin))
}

return sess, nil
}

Expand Down Expand Up @@ -322,7 +333,7 @@ func (s AuthService) loginSuccessResponse(screenName string, isICQ bool, err err
}
cookie, err := s.cookieBaker.Issue(buf.Bytes())
if err != nil {
return wire.TLVRestBlock{}, fmt.Errorf("failed to make auth cookie: %w", err)
return wire.TLVRestBlock{}, fmt.Errorf("failed to issue auth cookie: %w", err)
}

return wire.TLVRestBlock{
Expand Down
Loading

0 comments on commit f5202c9

Please sign in to comment.