// 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 }