mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 17:03:43 +00:00
fix(multiplayer): validate ticket timestamps
This commit is contained in:
@@ -53,6 +53,10 @@ func apply_ticket_update(update: Dictionary) -> bool:
|
||||
return _request_resync(self.ticket_id)
|
||||
if update.has("playlist") and not _valid_playlist(String(update["playlist"])):
|
||||
return _request_resync(self.ticket_id)
|
||||
if update.has("enqueued_at_unix") and not _valid_epoch(update["enqueued_at_unix"]):
|
||||
return _request_resync(self.ticket_id)
|
||||
if update.has("expires_at_unix") and not _valid_epoch(update["expires_at_unix"]):
|
||||
return _request_resync(self.ticket_id)
|
||||
if ticket_id.is_empty() or String(update["ticket_id"]) != ticket_id:
|
||||
return _request_resync(self.ticket_id)
|
||||
var incoming_revision := int(update["revision"])
|
||||
@@ -98,6 +102,8 @@ func apply_ticket_update(update: Dictionary) -> bool:
|
||||
func apply_proposal_update(update: Dictionary) -> bool:
|
||||
if not _has_string(update, "proposal_id") or not update.has("revision") or not _valid_revision(update["revision"]) or not update.has("state"):
|
||||
return _request_resync(proposal_id)
|
||||
if update.has("expires_at_unix") and not _valid_epoch(update["expires_at_unix"]):
|
||||
return _request_resync(proposal_id)
|
||||
var incoming_id := String(update["proposal_id"])
|
||||
if proposal_id.is_empty():
|
||||
proposal_id = incoming_id
|
||||
@@ -312,3 +318,11 @@ func _valid_revision(value: Variant) -> bool:
|
||||
|
||||
func _valid_playlist(value: String) -> bool:
|
||||
return value == "casual" or value == "ranked"
|
||||
|
||||
|
||||
func _valid_epoch(value: Variant) -> bool:
|
||||
if value is int:
|
||||
return int(value) >= 0
|
||||
if value is float:
|
||||
return is_finite(float(value)) and float(value) >= 0.0 and float(value) == floor(float(value))
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user