add support for PS3SGN

This commit is contained in:
wish
2023-04-15 11:27:43 +10:00
parent aeab3352ae
commit 90cb8525e5
2 changed files with 8 additions and 4 deletions

View File

@@ -108,7 +108,7 @@ func (s *Session) makeSignResponse(uid int) []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 { if s.client == VITA || s.client == PS3 {
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

@@ -18,6 +18,7 @@ type Client int
const ( const (
PC100 Client = iota PC100 Client = iota
VITA VITA
PS3
) )
// Session holds state for the sign server connection. // Session holds state for the sign server connection.
@@ -52,9 +53,12 @@ func (s *Session) handlePacket(pkt []byte) error {
switch reqType { switch reqType {
case "DLTSKEYSIGN:100", "DSGN:100": case "DLTSKEYSIGN:100", "DSGN:100":
s.handleDSGN(bf) s.handleDSGN(bf)
case "PS3SGN:100":
s.client = PS3
s.handlePSSGN(bf)
case "VITASGN:100": case "VITASGN:100":
s.client = VITA s.client = VITA
s.handleVITASGN(bf) s.handlePSSGN(bf)
case "DELETE:100": case "DELETE:100":
loginTokenString := string(bf.ReadNullTerminatedBytes()) loginTokenString := string(bf.ReadNullTerminatedBytes())
characterID := int(bf.ReadUint32()) characterID := int(bf.ReadUint32())
@@ -102,7 +106,7 @@ func (s *Session) authenticate(username string, password string) {
bf.WriteUint8(uint8(SIGN_EABORT)) bf.WriteUint8(uint8(SIGN_EABORT))
s.logger.Error("Error getting user details", zap.Error(err)) s.logger.Error("Error getting user details", zap.Error(err))
default: default:
if bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) == nil || s.client == VITA { if bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) == nil || s.client == VITA || s.client == PS3 {
s.logger.Debug("Passwords match!") s.logger.Debug("Passwords match!")
if newCharaReq { if newCharaReq {
err = s.server.newUserChara(username) err = s.server.newUserChara(username)
@@ -133,7 +137,7 @@ func (s *Session) authenticate(username string, password string) {
err = s.cryptConn.SendPacket(bf.Data()) err = s.cryptConn.SendPacket(bf.Data())
} }
func (s *Session) handleVITASGN(bf *byteframe.ByteFrame) { func (s *Session) handlePSSGN(bf *byteframe.ByteFrame) {
_ = bf.ReadNullTerminatedBytes() // 0000000256 _ = bf.ReadNullTerminatedBytes() // 0000000256
_ = bf.ReadNullTerminatedBytes() // 1 _ = bf.ReadNullTerminatedBytes() // 1
_ = bf.ReadBytes(82) _ = bf.ReadBytes(82)