Skip to content

Commit

Permalink
Merge pull request #119 from ZeruLight/feature/ps4
Browse files Browse the repository at this point in the history
Feature/ps4
  • Loading branch information
stratic-dev authored Mar 24, 2024
2 parents 449c3e4 + 4d134d0 commit 853758a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 3 additions & 2 deletions server/signserver/dsgn_resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
_config "erupe-ce/config"
"erupe-ce/server/channelserver"
"fmt"
"go.uber.org/zap"
"strings"
"time"

"go.uber.org/zap"
)

func (s *Session) makeSignResponse(uid uint32) []byte {
Expand Down Expand Up @@ -135,7 +136,7 @@ func (s *Session) makeSignResponse(uid uint32) []byte {
bf.WriteUint32(s.server.getLastCID(uid))
bf.WriteUint32(s.server.getUserRights(uid))
ps.Uint16(bf, "", false) // filters
if s.client == VITA || s.client == PS3 {
if s.client == VITA || s.client == PS3 || s.client == PS4 {
var psnUser string
s.server.db.QueryRow("SELECT psn_id FROM users WHERE id = $1", uid).Scan(&psnUser)
bf.WriteBytes(stringsupport.PaddedString(psnUser, 20, true))
Expand Down
20 changes: 14 additions & 6 deletions server/signserver/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"erupe-ce/common/byteframe"
"erupe-ce/network"

"go.uber.org/zap"
)

Expand All @@ -20,6 +21,7 @@ const (
PC100 client = iota
VITA
PS3
PS4
WIIU
)

Expand Down Expand Up @@ -56,6 +58,9 @@ func (s *Session) handlePacket(pkt []byte) error {
switch reqType[:len(reqType)-3] {
case "DLTSKEYSIGN:", "DSGN:", "SIGN:":
s.handleDSGN(bf)
case "PS4SGN:":
s.client = PS4
s.handlePSSGN(bf)
case "PS3SGN:":
s.client = PS3
s.handlePSSGN(bf)
Expand Down Expand Up @@ -127,13 +132,16 @@ func (s *Session) handleWIIUSGN(bf *byteframe.ByteFrame) {

func (s *Session) handlePSSGN(bf *byteframe.ByteFrame) {
// Prevent reading malformed request
if len(bf.DataFromCurrent()) < 128 {
s.sendCode(SIGN_EABORT)
return
if s.client != PS4 {
if len(bf.DataFromCurrent()) < 128 {
s.sendCode(SIGN_EABORT)
return
}

_ = bf.ReadNullTerminatedBytes() // VITA = 0000000256, PS3 = 0000000255
_ = bf.ReadBytes(2) // VITA = 1, PS3 = !
_ = bf.ReadBytes(82)
}
_ = bf.ReadNullTerminatedBytes() // VITA = 0000000256, PS3 = 0000000255
_ = bf.ReadBytes(2) // VITA = 1, PS3 = !
_ = bf.ReadBytes(82)
s.psn = string(bf.ReadNullTerminatedBytes())
var uid uint32
err := s.server.db.QueryRow(`SELECT id FROM users WHERE psn_id = $1`, s.psn).Scan(&uid)
Expand Down

0 comments on commit 853758a

Please sign in to comment.