This commit is contained in:
root
2026-09-19 20:21:47 +02:00
commit 0798933b05
62 changed files with 7658 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
// Package comms validates the data that crosses the wormhole link. The
// content of uplinks and downlinks is opaque bytes defined by the player's
// ship program; only sizes are enforced.
package comms
import "fmt"
func CheckUplink(data []byte, limit int) error {
if len(data) > limit {
return fmt.Errorf("uplink is %d bytes, limit is %d", len(data), limit)
}
return nil
}
func CheckProgram(prog []byte, limit int) error {
switch {
case len(prog) == 0:
return fmt.Errorf("program is empty")
case len(prog)%4 != 0:
return fmt.Errorf("program length %d is not a multiple of 4", len(prog))
case len(prog) > limit:
return fmt.Errorf("program is %d bytes, limit is %d", len(prog), limit)
}
return nil
}