init ps4 support

This commit is contained in:
stratic-dev
2024-03-20 19:12:57 +00:00
parent fc13b1bdd9
commit 7d7fd50ba8
2 changed files with 18 additions and 8 deletions

View File

@@ -7,9 +7,10 @@ import (
_config "erupe-ce/config" _config "erupe-ce/config"
"erupe-ce/server/channelserver" "erupe-ce/server/channelserver"
"fmt" "fmt"
"go.uber.org/zap"
"strings" "strings"
"time" "time"
"go.uber.org/zap"
) )
func (s *Session) makeSignResponse(uid uint32) []byte { func (s *Session) makeSignResponse(uid uint32) []byte {
@@ -135,7 +136,7 @@ func (s *Session) makeSignResponse(uid uint32) []byte {
bf.WriteUint32(s.server.getLastCID(uid)) bf.WriteUint32(s.server.getLastCID(uid))
bf.WriteUint32(s.server.getUserRights(uid)) bf.WriteUint32(s.server.getUserRights(uid))
ps.Uint16(bf, "", false) // filters 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 var psnUser string
s.server.db.QueryRow("SELECT psn_id FROM users WHERE id = $1", uid).Scan(&psnUser) s.server.db.QueryRow("SELECT psn_id FROM users WHERE id = $1", uid).Scan(&psnUser)
bf.WriteBytes(stringsupport.PaddedString(psnUser, 20, true)) bf.WriteBytes(stringsupport.PaddedString(psnUser, 20, true))

View File

@@ -11,6 +11,7 @@ import (
"erupe-ce/common/byteframe" "erupe-ce/common/byteframe"
"erupe-ce/network" "erupe-ce/network"
"go.uber.org/zap" "go.uber.org/zap"
) )
@@ -20,6 +21,7 @@ const (
PC100 client = iota PC100 client = iota
VITA VITA
PS3 PS3
PS4
WIIU WIIU
) )
@@ -56,6 +58,9 @@ func (s *Session) handlePacket(pkt []byte) error {
switch reqType[:len(reqType)-3] { switch reqType[:len(reqType)-3] {
case "DLTSKEYSIGN:", "DSGN:", "SIGN:": case "DLTSKEYSIGN:", "DSGN:", "SIGN:":
s.handleDSGN(bf) s.handleDSGN(bf)
case "PS4SGN:":
s.client = PS4
s.handlePSSGN(bf)
case "PS3SGN:": case "PS3SGN:":
s.client = PS3 s.client = PS3
s.handlePSSGN(bf) s.handlePSSGN(bf)
@@ -127,13 +132,17 @@ func (s *Session) handleWIIUSGN(bf *byteframe.ByteFrame) {
func (s *Session) handlePSSGN(bf *byteframe.ByteFrame) { func (s *Session) handlePSSGN(bf *byteframe.ByteFrame) {
// Prevent reading malformed request // Prevent reading malformed request
if len(bf.DataFromCurrent()) < 128 { if s.client != PS4 {
s.sendCode(SIGN_EABORT) dataLength := len(bf.DataFromCurrent()) //PS4 is 24
return if dataLength < 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()) s.psn = string(bf.ReadNullTerminatedBytes())
var uid uint32 var uid uint32
err := s.server.db.QueryRow(`SELECT id FROM users WHERE psn_id = $1`, s.psn).Scan(&uid) err := s.server.db.QueryRow(`SELECT id FROM users WHERE psn_id = $1`, s.psn).Scan(&uid)