mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 20:50:00 +00:00
TUN-8641: Expose methods to simplify V3 Datagram parsing on the edge
This commit is contained in:
@@ -75,3 +75,15 @@ func (id RequestID) MarshalBinaryTo(data []byte) error {
|
||||
binary.BigEndian.PutUint64(data[8:], id.lo)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (id *RequestID) UnmarshalBinary(data []byte) error {
|
||||
if len(data) != 16 {
|
||||
return fmt.Errorf("invalid length slice provided to unmarshal: %d (expected 16)", len(data))
|
||||
}
|
||||
|
||||
*id = RequestID{
|
||||
binary.BigEndian.Uint64(data[:8]),
|
||||
binary.BigEndian.Uint64(data[8:]),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user