update legacy WIIU code

This commit is contained in:
wish
2023-07-25 00:45:11 +10:00
parent 7edf07d853
commit 2eeab72c1c

View File

@@ -112,23 +112,24 @@ func (s *Session) authenticate(username string, password string) {
func (s *Session) handleWIIUSGN(bf *byteframe.ByteFrame) { func (s *Session) handleWIIUSGN(bf *byteframe.ByteFrame) {
_ = bf.ReadBytes(1) _ = bf.ReadBytes(1)
wiiuKey := string(bf.ReadBytes(64)) wiiuKey := string(bf.ReadBytes(64))
var reqUsername string var uid uint32
err := s.server.db.QueryRow(`SELECT username FROM users WHERE wiiu_key = $1`, wiiuKey).Scan(&reqUsername) err := s.server.db.QueryRow(`SELECT id FROM users WHERE wiiu_key = $1`, wiiuKey).Scan(&uid)
if err == sql.ErrNoRows { if err != nil {
resp := byteframe.NewByteFrame() if err == sql.ErrNoRows {
resp.WriteUint8(uint8(SIGN_ECOGLINK)) s.logger.Info("Unlinked Wii U attempted to authenticate", zap.String("Key", wiiuKey))
s.cryptConn.SendPacket(resp.Data()) s.sendCode(SIGN_ECOGLINK)
return
}
s.sendCode(SIGN_EABORT)
return return
} }
s.authenticate(reqUsername, "") s.cryptConn.SendPacket(s.makeSignResponse(uid))
} }
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 len(bf.DataFromCurrent()) < 128 {
resp := byteframe.NewByteFrame() s.sendCode(SIGN_EABORT)
resp.WriteUint8(uint8(SIGN_EABORT))
s.cryptConn.SendPacket(resp.Data())
return return
} }
_ = bf.ReadNullTerminatedBytes() // VITA = 0000000256, PS3 = 0000000255 _ = bf.ReadNullTerminatedBytes() // VITA = 0000000256, PS3 = 0000000255