diff --git a/protocols.go b/protocols.go index 985a9cd..0e74b5a 100644 --- a/protocols.go +++ b/protocols.go @@ -41,7 +41,7 @@ const ( P_PLAINTEXTV2 = 7367777 P_WEBRTC_DIRECT = 280 P_WEBRTC = 281 - P_MEMORY = 0x0309 // 777 decimal + P_MEMORY = 777 ) var ( diff --git a/transcoders.go b/transcoders.go index a6bde0d..03b39ae 100644 --- a/transcoders.go +++ b/transcoders.go @@ -490,7 +490,7 @@ func validateHTTPPath(b []byte) error { return nil // We can represent any byte slice when we escape it. } -var TranscoderMemory = NewTranscoderFromFunctions(memoryStB, memoryBtS, nil) +var TranscoderMemory = NewTranscoderFromFunctions(memoryStB, memoryBtS, memoryValidate) func memoryStB(s string) ([]byte, error) { z, err := strconv.ParseUint(s, 10, 64) @@ -509,3 +509,12 @@ func memoryBtS(b []byte) (string, error) { z := binary.BigEndian.Uint64(b) return strconv.FormatUint(z, 10), nil } + +func memoryValidate(b []byte) error { + // Ensure the byte array is exactly 8 bytes long for a uint64 in big-endian format + if len(b) != 8 { + return errors.New("invalid length: must be exactly 8 bytes") + } + + return nil +}