inform

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CBC = iota
	GCM
)
View Source
const (
	MagicNumber   uint32 = 1414414933
	InformVersion uint32 = 0
	DataVersion   uint32 = 1

	EncryptFlag uint16 = 1
	ZlibFlag    uint16 = 2
	SnappyFlag  uint16 = 4
	GcmFlag     uint16 = 8
)
View Source
const NetworkConfigDhcp = "dhcp"
View Source
const NetworkConfigDisabled = "disabled"
View Source
const NetworkConfigStatic = "static"

Variables

View Source
var (
	DefaultKey = Key([]byte{
		0xba, 0x86, 0xf2, 0xbb,
		0xe1, 0x07, 0xc7, 0xc5,
		0x7e, 0xb5, 0xf2, 0x69,
		0x07, 0x75, 0xc7, 0x12,
	})
)

Functions

func CompressSnappy

func CompressSnappy(data []byte) ([]byte, error)

func CompressZLib

func CompressZLib(data []byte) (result []byte, err error)

func DecompressSnappy

func DecompressSnappy(data []byte) ([]byte, error)

func DecompressZLib

func DecompressZLib(data []byte) (result []byte, err error)

func Decrypt

func Decrypt(mode int, iv IV, key Key, data []byte, aad []byte) (result []byte, err error)

func Encrypt

func Encrypt(mode int, iv IV, key Key, data []byte, aad []byte) ([]byte, error)

func ParseBool

func ParseBool(value interface{}) (bool, error)

func ParseFloat

func ParseFloat(value interface{}) (float64, error)

func ParseInt

func ParseInt(value interface{}) (int, error)

func ParseString

func ParseString(value interface{}) (string, error)

Types

type Cmd

type Cmd struct {
	ServerTime int    `json:"server_time_in_utc"`
	Command    string `json:"cmd"`
	UseAlert   bool   `json:"use_alert"`
	DeviceId   string `json:"device_id"`
	Time       int    `json:"time"`
	CmdId      string `json:"_id"`
	// contains filtered or unexported fields
}

func (Cmd) HttpCode

func (r Cmd) HttpCode() int

func (Cmd) IsSuccess

func (r Cmd) IsSuccess() bool

func (*Cmd) Marshal

func (msg *Cmd) Marshal() []byte

func (*Cmd) String

func (msg *Cmd) String() string

type EthernetTableEntry

type EthernetTableEntry struct {
	Name    string `json:"name"`
	Mac     string `json:"mac"`
	NumPort uint64 `json:"num_port"`
}

type HardwareAddr

type HardwareAddr []byte

func (HardwareAddr) HexString

func (m HardwareAddr) HexString() string

func (HardwareAddr) IsValid

func (m HardwareAddr) IsValid() bool

func (HardwareAddr) MarshalJSON

func (m HardwareAddr) MarshalJSON() ([]byte, error)

func (HardwareAddr) String

func (m HardwareAddr) String() string

type IV

type IV Key
var (
	NilIv IV = []byte{
		0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00,
	}
)

func GenerateIV

func GenerateIV() (IV, error)

type Inform

type Inform struct {
	BoardRevision     int           `json:"board_rev,omitempty"`
	BootRomVersion    string        `json:"bootrom_version"`
	ConfigVersion     string        `json:"cfgversion"`
	ConfigNetworkWan  NetworkConfig `json:"config_network_wan,omitempty"`
	ConfigNetworkWan2 NetworkConfig `json:"config_network_wan2,omitempty"`

	//CountryCode          int         `json:"country_code"`
	Default           bool `json:"default"`
	DiscoveryResponse bool `json:"discovery_response"`
	//Fingerprint          string      `json:"fingerprint"`
	EthernetTable           []EthernetTableEntry `json:"ethernet_table,omitempty"`
	FirmwareCapabilities    int32                `json:"fw_caps"`
	GuestToken              string               `json:"guest_token,omitempty"`
	HasDefaultRouteDistance bool                 `json:"has_default_route_distance"`
	HasHostfileUpdate       bool                 `json:"has_dnsmasq_hostfile_update"`
	HasDpi                  bool                 `json:"has_dpi"`
	HasEth1                 bool                 `json:"has_eth1"`
	HasPortA                bool                 `json:"has_porta"`
	HasSshDisable           bool                 `json:"has_ssh_disable"`
	HasVti                  bool                 `json:"has_vti"`
	//HasSpeaker           bool   `json:"has_speaker"` // Not present in rust implementation
	Hostname     string       `json:"hostname"`
	IntfTable    []Interface  `json:"if_table"`
	InformUrl    string       `json:"inform_url"`
	InformIp     string       `json:"inform_ip"`
	Ip           string       `json:"ip"`
	Isolated     bool         `json:"isolated"`
	LastError    string       `json:"last_error,omitempty"` // Not present in rust implementation
	Locating     bool         `json:"locating"`
	Mac          HardwareAddr `json:"mac"`
	Model        string       `json:"model"`
	ModelDisplay string       `json:"model_display"`
	Netmask      string       `json:"netmask"`
	QrId         string       `json:"qrid,omitempty"`
	//RadioTable           []Radio     `json:"radio_table"`
	PortTable          []Port   `json:"config_port_table"`
	RadiusCapabilities int32    `json:"radius_caps"`
	RequiredVersion    string   `json:"required_version"`
	SelfrunBeacon      bool     `json:"selfrun_beacon"`
	Serial             string   `json:"serial"`
	SpectrumScanning   bool     `json:"spectrum_scanning,omitempty"`
	State              int      `json:"state"`
	StreamToken        string   `json:"stream_token,omitempty"`
	SysStats           SysStats `json:"system-stats"`
	Time               int64    `json:"time"`
	Uplink             string   `json:"uplink"`
	Uptime             uint64   `json:"uptime"`
	//VApTable             []VAp       `json:"vap_table"`
	Version string `json:"version"`

	// Notify fields
	InformAsNotify bool   `json:"inform_as_notify,omitempty"`
	NotifyReason   string `json:"notif_reason,omitempty"`
	NotifyPayload  string `json:"notif_payload,omitempty"`

	// Speed test
	SpeedtestStatus *SpeedTestStatus `json:"speedtest-status,omitempty"`
}

func (Inform) Marshal

func (r Inform) Marshal() []byte

func (Inform) String

func (r Inform) String() string

type InformResponse

type InformResponse interface {
	Message
	IsSuccess() bool
	HttpCode() int
}

func ResponseFromHttpCode

func ResponseFromHttpCode(code int) InformResponse

type Interface

type Interface struct {
	FullDuplex  bool         `json:"full_duplex"`
	Ip          string       `json:"ip"`
	Mac         HardwareAddr `json:"mac"`
	Name        string       `json:"name"`
	Netmask     string       `json:"netmask"`
	NumPort     int          `json:"num_port"`
	RxBytes     uint64       `json:"rx_bytes"`
	RxDropped   uint64       `json:"rx_dropped"`
	RxErrors    uint64       `json:"rx_errors"`
	RxMulticast int          `json:"rx_multicast"`
	RxPackets   uint64       `json:"rx_packets"`
	Speed       uint64       `json:"speed"`
	TxBytes     uint64       `json:"tx_bytes"`
	TxDropped   uint64       `json:"tx_dropped"`
	TxErrors    uint64       `json:"tx_errors"`
	TxPackets   uint64       `json:"tx_packets"`
	Up          bool         `json:"up"`
	Enabled     bool         `json:"enabled"`
	Drops       uint64       `json:"drops"`
	Latency     uint64       `json:"latency"`
	Uptime      uint64       `json:"uptime"`
	Nameservers []string     `json:"namservers"`
	Gateways    []string     `json:"gateways"`
}

type Key

type Key []byte

Key management

func KeyFromString

func KeyFromString(keyString string) (Key, error)

func (Key) IsDefault

func (k Key) IsDefault() bool

func (Key) IsValid

func (k Key) IsValid() bool

func (Key) String

func (k Key) String() string

type ManagementConfig

type ManagementConfig map[string]string

func (ManagementConfig) MarshalJSON

func (m ManagementConfig) MarshalJSON() ([]byte, error)

type Message

type Message interface {
	Marshal() []byte
	String() string
}

func Unmarshal

func Unmarshal(data []byte) (Message, error)

type NetworkConfig

type NetworkConfig struct {
	Type    string `json:"type"`
	Ip      string `json:"ip,omitempty"`
	Netmask string `json:"netmask,omitempty"`
	Gateway string `json:"gateway,omitempty"`
	Dns1    string `json:"dns1,omitempty"`
	Dns2    string `json:"dns2,omitempty"`
	IfName  string `json:"ifname,omitempty"`
}

func (NetworkConfig) MarshalJSON

func (n NetworkConfig) MarshalJSON() ([]byte, error)

type Noop

type Noop struct {
	ServerTime int `json:"server_time_in_utc"`
	Interval   int `json:"interval"`
	// contains filtered or unexported fields
}

func (Noop) HttpCode

func (r Noop) HttpCode() int

func (Noop) IsSuccess

func (r Noop) IsSuccess() bool

func (*Noop) Marshal

func (msg *Noop) Marshal() []byte

func (*Noop) String

func (msg *Noop) String() string

type Packet

type Packet struct {
	Msg Message
	// contains filtered or unexported fields
}

func NewPacket

func NewPacket(ap HardwareAddr, msg Message, k Key, mode int) *Packet

func (Packet) IsEncrypted

func (p Packet) IsEncrypted() bool

func (Packet) IsGcmEncrypted

func (p Packet) IsGcmEncrypted() bool

func (Packet) IsSnappy

func (p Packet) IsSnappy() bool

func (Packet) IsZLib

func (p Packet) IsZLib() bool

func (Packet) Marshal

func (p Packet) Marshal() (result []byte, err error)

func (*Packet) Unmarshal

func (p *Packet) Unmarshal(data []byte, keyFetcher func(addr HardwareAddr) (Key, error)) (err error)

type Port

type Port struct {
	IfName string `json:"ifname"`
	Name   string `json:"name"`
}

type SetParam

type SetParam struct {
	ManagementConfig `json:"mgmt_cfg"`
	ServerTime       int `json:"server_time_in_utc"`
	// contains filtered or unexported fields
}

func (SetParam) HttpCode

func (r SetParam) HttpCode() int

func (SetParam) IsSuccess

func (r SetParam) IsSuccess() bool

func (*SetParam) Marshal

func (msg *SetParam) Marshal() []byte

func (*SetParam) String

func (msg *SetParam) String() string

type SpeedTestStatus

type SpeedTestStatus struct {
	Latency        uint64  `json:"latency"`
	RunDate        uint64  `json:"rundate"`
	RunTime        uint64  `json:"runtime"`
	StatusDownload uint64  `json:"status_download"`
	StatusPing     uint64  `json:"status_ping"`
	StatusUpload   uint64  `json:"status_upload"`
	XputDownload   float64 `json:"xput_download"`
	XputUpload     float64 `json:"xput_upload"`
}

type SysStats

type SysStats struct {
	LoadAvg1  float64 `json:"loadavg_1"`
	LoadAvg5  float64 `json:"loadavg_5"`
	LoadAvg15 float64 `json:"loadavg_15"`
	MemBuffer uint64  `json:"mem_buffer"`
	MemTotal  uint64  `json:"mem_total"`
	MemUsed   uint64  `json:"mem_used"`
	Mem       uint64  `json:"mem"`
	Cpu       uint64  `json:"cpu"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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