fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m20s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m20s
This commit is contained in:
@@ -146,17 +146,16 @@ func (gw *Gateway) HandleWS(w http.ResponseWriter, r *http.Request) {
|
||||
continue // Ignoriere böswilligen Input
|
||||
}
|
||||
|
||||
// 🔒 SECURITY: Setze IMMER die korrekten IDs (überschreibe Client-Werte)
|
||||
input := game.ClientInput{
|
||||
Type: inputType,
|
||||
RoomID: roomID, // Server setzt den Raum (nicht Client!)
|
||||
PlayerID: playerID, // Server setzt die Player-ID (nicht Client!)
|
||||
}
|
||||
// 🔒 SECURITY: Alle Input-Felder übernehmen, aber IDs immer vom Server setzen
|
||||
// Remarshal des raw-Objekts in ClientInput um alle Felder (inkl. STATE-Felder) zu übernehmen
|
||||
inputBytes, _ := json.Marshal(raw)
|
||||
var input game.ClientInput
|
||||
json.Unmarshal(inputBytes, &input)
|
||||
|
||||
// Sequence-Nummer vom Client übernehmen (für Client Prediction)
|
||||
if seq, ok := raw["sequence"].(float64); ok {
|
||||
input.Sequence = uint32(seq)
|
||||
}
|
||||
// Security-kritische Felder vom Server überschreiben (nie Client-Werten vertrauen)
|
||||
input.Type = inputType
|
||||
input.RoomID = roomID // Server setzt den Raum
|
||||
input.PlayerID = playerID // Server setzt die Player-ID
|
||||
|
||||
bytes, _ := json.Marshal(input)
|
||||
gw.NC.Publish(fmt.Sprintf("game.room.%s.input", roomID), bytes)
|
||||
|
||||
Reference in New Issue
Block a user