inform

package
v0.0.0-...-db9a0c6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2022 License: MIT Imports: 17 Imported by: 1

Documentation

Overview

Package inform handles data encoding/decoding for the UniFi inform request/response cycle such that payload information can be successfully exchanged.

Index

Constants

View Source
const InformContentType string = "application/x-binary"

InformContentType is the content type used for inform messages

Variables

View Source
var ErrNoMagic = errors.New("missing magic header")

ErrNoMagic is returned when magic header is missing

View Source
var ErrNotImplemented = errors.New("functionality required is not yet implemented")

ErrNotImplemented is returned when we have not yet implemented functionality but know how to recognize it

View Source
var ErrTruncatedPacket = errors.New("truncated packet")

ErrTruncatedPacket is returned when packet is too short

View Source
var ErrUnhandledVer = errors.New("unhandled payload version")

ErrUnhandledVer is returned when payload version in header does not match version known compatible with this library

Functions

This section is empty.

Types

type Header struct {
	Version      uint32
	HardwareAddr net.HardwareAddr

	EncryptedAES     bool
	ZLibCompressed   bool
	SnappyCompressed bool
	EncryptedGCM     bool
	// contains filtered or unexported fields
}

Header represents header of inform message from Ubiquiti UniFi device

func DecodeHeader

func DecodeHeader(rdr io.Reader) (inf Header, err error)

DecodeHeader parses a ubiquiti inform message

func (*Header) DecodePayload

func (ih *Header) DecodePayload(rdr io.Reader, key string) (payload []byte, err error)

DecodePayload decodes information from a UniFi inform payload (usually json text) using params from Header

func (*Header) NewResponse

func (ih *Header) NewResponse(ir informResponse) (encoded []byte, err error)

NewResponse serializes a unifi inform response

type NoOpResponse

type NoOpResponse struct {
	Kind            string `json:"_type"`
	IntervalSeconds uint64 `json:"interval"`
	ServerTime      string `json:"server_time_in_utc"`
}

NoOpResponse is a noop response...

func NewNoOpResponse

func NewNoOpResponse(sleepSeconds uint64) NoOpResponse

NewNoOpResponse generates a new NoOpResponse bundle

func (NoOpResponse) JSON

func (r NoOpResponse) JSON() (response []byte, err error)

JSON returns json representation of response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL