Documentation ¶
Index ¶
Constants ¶
const ( AESEncrypted flags = 1 << iota // packet's payload is AES-CBC encrypted ZlibCompressed // the packet's payload is compressed SnappyCompressed // payload is compressed with Google's snappy algorithm Encrypted = AESEncrypted // deprecated: see AESEncrypted Compressed = ZlibCompressed // deprecated: see ZlibCompressed )
Various packet flags.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Packet ¶
type Packet struct { PacketVersion uint32 // version of the packet PayloadVersion uint32 // version of the payload MAC net.HardwareAddr // Unifi device's MAC address Flags flags // 0x01 = encrypted, 0x02 = compressed IV []byte // AES-128-CBC initialization vector Payload []byte // payload (usually JSON) }
Packet represents an HTTP POST request from an Unifi device to the controllers /inform URL.
func ParsePacket ¶
ParsePacket tries to decode the input into a Packet instance.
The returned Packet is nil if there's an error. You should not access its payload directly, but use the Data() function, which takes care of decrypting and decompressing (if necessary).
Use ReadPacket if you have an io.Reader.
func ReadPacket ¶
ReadPacket tries to decode the input into a Packet instance.
The reader is read from twice: once to fetch the header (which has a fixed size), and another time to read the body (its length is encoded in the header). This means, that the reader is not necessarily consumed until EOF.
The returned Packet is nil if there's an error. You should not access its payload directly, but use the Data() function, which takes care of decrypting and decompressing (if necessary).
Use ParsePacket if you have already obtained a full copy of the packet.