unifi

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2020 License: MIT Imports: 15 Imported by: 0

README

Go Library: unifi

It connects to a Unifi Controller, given a url, username and password. Returns an authenticated http Client you may use to query the device for data. Also contains some built-in methods for de-serializing common client and device data. The data is provided in a large struct you can consume in your application.

This library is designed to PULL data FROM the controller. It has no methods that update settings or change things on the controller. Someone expressed interest in adding methods to update data, and I'm okay with that. I'll even help add them. Tell me what you want to do, and we'll make it happen.

Pull requests, feature requests, code reviews and feedback are welcomed!

Here's a working example:

package main

import "log"
import "github.com/unifi-poller/unifi"

func main() {
	c := *unifi.Config{
		User: "admin",
		Pass: "superSecret1234",
		URL:  "https://127.0.0.1:8443/",
		// Log with log.Printf or make your own interface that accepts (msg, fmt)
		ErrorLog: log.Printf,
		DebugLog: log.Printf,
	}
	uni, err := unifi.NewUnifi(c)
	if err != nil {
		log.Fatalln("Error:", err)
	}

	sites, err := uni.GetSites()
	if err != nil {
		log.Fatalln("Error:", err)
	}
	clients, err := uni.GetClients(sites)
	if err != nil {
		log.Fatalln("Error:", err)
	}
	devices, err := uni.GetDevices(sites)
	if err != nil {
		log.Fatalln("Error:", err)
	}

	log.Println(len(sites), "Unifi Sites Found: ", sites)
	log.Println(len(clients), "Clients connected:")
	for i, client := range clients {
		log.Println(i+1, client.ID, client.Hostname, client.IP, client.Name, client.LastSeen)
	}

	log.Println(len(devices.USWs), "Unifi Switches Found")
	log.Println(len(devices.USGs), "Unifi Gateways Found")

	log.Println(len(devices.UAPs), "Unifi Wireless APs Found:")
	for i, uap := range devices.UAPs {
		log.Println(i+1, uap.Name, uap.IP)
	}
}

Documentation

Overview

Package unifi provides a set of types to unload (unmarshal) Ubiquiti UniFi controller data. Also provided are methods to easily get data for devices - things like access points and switches, and for clients - the things connected to those access points and switches. As a bonus, each device and client type provided has an attached method to create InfluxDB datapoints.

Index

Constants

View Source
const (
	// APIStatusPath shows Controller version.
	APIStatusPath string = "/status"
	// APIEventPath contains UniFi Event data.
	APIEventPath string = "/api/s/%s/stat/event"
	// APISiteList is the path to the api site list
	APISiteList string = "/api/self/sites"
	// APISiteDPI is site DPI data.
	APISiteDPI string = "/api/s/%s/stat/sitedpi"
	// APISiteDPI is site DPI data.
	APIClientDPI string = "/api/s/%s/stat/stadpi"
	// APIClientPath is Unifi Clients API Path
	APIClientPath string = "/api/s/%s/stat/sta"
	// APINetworkPath is where we get data about Unifi networks.
	APINetworkPath string = "/api/s/%s/rest/networkconf"
	// APIDevicePath is where we get data about Unifi devices.
	APIDevicePath string = "/api/s/%s/stat/device"
	// APILoginPath is Unifi Controller Login API Path
	APILoginPath string = "/api/login"
	// APILoginPathNew is how we log into UDM 5.12.55+
	APILoginPathNew string = "/api/auth/login"
	// APIEventPathIDS returns Intrusion Detection/Prevention Systems Events
	APIEventPathIDS string = "/api/s/%s/stat/ips/event"
	// APIEventPathAlarms contains the site alarms.
	APIEventPathAlarms string = "/api/s/%s/list/alarm"
	// APIPrefixNew is the prefix added to the new API paths; except login. duh.
	APIPrefixNew string = "/proxy/network"
	// APIAnomaliesPath returns site anomalies.
	APIAnomaliesPath string = "/api/s/%s/stat/anomalies"
)

This is a list of unifi API paths. The %s in each string must be replaced with a Site.Name.

Variables

View Source
var DPIApps = DPIMap{}/* 2279 elements not displayed */

DPIApps maps the applications to names. From: https://fw-download.ubnt.com/data/usg-dpi/1628-debian-v1.442.0-05f5a57eaef344358bd5a8e84a184c18.tar

View Source
var DPICats = DPIMap{
	0:   "Instant Messengers",
	1:   "Peer-to-Peer Networks",
	3:   "File Sharing",
	4:   "Media Streaming",
	5:   "Email Messaging",
	6:   "VoIP Services",
	7:   "Database Tools",
	8:   "Online Games",
	9:   "Management Protocols",
	10:  "Remote Access",
	11:  "Tunneling and Proxy",
	12:  "Investment Platforms",
	13:  "Web Services",
	14:  "Security Updates",
	15:  "Web IM",
	17:  "Business Tools",
	18:  "Network Protocols_18",
	19:  "Network Protocols_19",
	20:  "Network Protocols_20",
	23:  "Private Protocols",
	24:  "Social Networks",
	255: "Unknown_255",
}

DPICats maps the categories to descriptions. From: https://fw-download.ubnt.com/data/usg-dpi/1628-debian-v1.442.0-05f5a57eaef344358bd5a8e84a184c18.tar

Functions

This section is empty.

Types

type Alarm

type Alarm struct {
	Archived              FlexBool  `json:"archived"`
	DestPort              int       `json:"dest_port"`
	SrcPort               int       `json:"src_port"`
	FlowID                int64     `json:"flow_id"`
	InnerAlertGID         int64     `json:"inner_alert_gid"`
	InnerAlertRev         int64     `json:"inner_alert_rev"`
	InnerAlertSeverity    int64     `json:"inner_alert_severity"`
	InnerAlertSignatureID int64     `json:"inner_alert_signature_id"`
	Time                  int64     `json:"time"`
	Timestamp             int64     `json:"timestamp"`
	Datetime              time.Time `json:"datetime"`
	HandledTime           time.Time `json:"handled_time,omitempty"`
	AppProto              string    `json:"app_proto,omitempty"`
	Catname               string    `json:"catname"`
	DestIP                string    `json:"dest_ip"`
	DstMAC                string    `json:"dst_mac"`
	DstIPASN              string    `json:"dstipASN,omitempty"`
	DstIPCountry          string    `json:"dstipCountry,omitempty"`
	EventType             string    `json:"event_type"`
	HandledAdminID        string    `json:"handled_admin_id,omitempty"`
	Host                  string    `json:"host"`
	ID                    string    `json:"_id"`
	InIface               string    `json:"in_iface"`
	InnerAlertAction      string    `json:"inner_alert_action"`
	InnerAlertCategory    string    `json:"inner_alert_category"`
	InnerAlertSignature   string    `json:"inner_alert_signature"`
	Key                   string    `json:"key"`
	Msg                   string    `json:"msg"`
	Proto                 string    `json:"proto"`
	SiteID                string    `json:"site_id"`
	SiteName              string    `json:"-"`
	SourceName            string    `json:"-"`
	SrcIP                 string    `json:"src_ip"`
	SrcIPASN              string    `json:"srcipASN,omitempty"`
	SrcIPCountry          string    `json:"srcipCountry,omitempty"`
	SrcMAC                string    `json:"src_mac"`
	Subsystem             string    `json:"subsystem"`
	UniqueAlertID         string    `json:"unique_alertid"`
	USGIP                 string    `json:"usgip"`
	USGIPASN              string    `json:"usgipASN"`
	USGIPCountry          string    `json:"usgipCountry"`
	TxID                  FlexInt   `json:"tx_id,omitempty"`
	DestIPGeo             IPGeo     `json:"dstipGeo"`
	SourceIPGeo           IPGeo     `json:"usgipGeo"`
	USGIPGeo              IPGeo     `json:"srcipGeo,omitempty"`
}

type Anomaly

type Anomaly struct {
	Datetime   time.Time
	SourceName string
	SiteName   string
	Anomaly    string
	DeviceMAC  string
}

Anomaly is the reformatted data type that this library returns.

type Ap

type Ap struct {
	SiteID                   string    `json:"site_id"`
	O                        string    `json:"o"`
	Oid                      string    `json:"oid"`
	Ap                       string    `json:"ap"`
	Time                     FlexInt   `json:"time"`
	Datetime                 time.Time `json:"datetime"`
	Bytes                    FlexInt   `json:"bytes"`
	Duration                 FlexInt   `json:"duration"`
	WifiTxDropped            FlexInt   `json:"wifi_tx_dropped"`
	RxErrors                 FlexInt   `json:"rx_errors"`
	RxDropped                FlexInt   `json:"rx_dropped"`
	RxFrags                  FlexInt   `json:"rx_frags"`
	RxCrypts                 FlexInt   `json:"rx_crypts"`
	TxPackets                FlexInt   `json:"tx_packets"`
	TxBytes                  FlexInt   `json:"tx_bytes"`
	TxErrors                 FlexInt   `json:"tx_errors"`
	TxDropped                FlexInt   `json:"tx_dropped"`
	TxRetries                FlexInt   `json:"tx_retries"`
	RxPackets                FlexInt   `json:"rx_packets"`
	RxBytes                  FlexInt   `json:"rx_bytes"`
	UserRxDropped            FlexInt   `json:"user-rx_dropped"`
	GuestRxDropped           FlexInt   `json:"guest-rx_dropped"`
	UserRxErrors             FlexInt   `json:"user-rx_errors"`
	GuestRxErrors            FlexInt   `json:"guest-rx_errors"`
	UserRxPackets            FlexInt   `json:"user-rx_packets"`
	GuestRxPackets           FlexInt   `json:"guest-rx_packets"`
	UserRxBytes              FlexInt   `json:"user-rx_bytes"`
	GuestRxBytes             FlexInt   `json:"guest-rx_bytes"`
	UserRxCrypts             FlexInt   `json:"user-rx_crypts"`
	GuestRxCrypts            FlexInt   `json:"guest-rx_crypts"`
	UserRxFrags              FlexInt   `json:"user-rx_frags"`
	GuestRxFrags             FlexInt   `json:"guest-rx_frags"`
	UserTxPackets            FlexInt   `json:"user-tx_packets"`
	GuestTxPackets           FlexInt   `json:"guest-tx_packets"`
	UserTxBytes              FlexInt   `json:"user-tx_bytes"`
	GuestTxBytes             FlexInt   `json:"guest-tx_bytes"`
	UserTxErrors             FlexInt   `json:"user-tx_errors"`
	GuestTxErrors            FlexInt   `json:"guest-tx_errors"`
	UserTxDropped            FlexInt   `json:"user-tx_dropped"`
	GuestTxDropped           FlexInt   `json:"guest-tx_dropped"`
	UserTxRetries            FlexInt   `json:"user-tx_retries"`
	GuestTxRetries           FlexInt   `json:"guest-tx_retries"`
	MacFilterRejections      FlexInt   `json:"mac_filter_rejections"`
	UserMacFilterRejections  FlexInt   `json:"user-mac_filter_rejections"`
	GuestMacFilterRejections FlexInt   `json:"guest-mac_filter_rejections"`
	WifiTxAttempts           FlexInt   `json:"wifi_tx_attempts"`
	UserWifiTxDropped        FlexInt   `json:"user-wifi_tx_dropped"`
	GuestWifiTxDropped       FlexInt   `json:"guest-wifi_tx_dropped"`
	UserWifiTxAttempts       FlexInt   `json:"user-wifi_tx_attempts"`
	GuestWifiTxAttempts      FlexInt   `json:"guest-wifi_tx_attempts"`
}

Ap is a subtype of UAPStat to make unmarshalling of different controller versions possible.

type Client

type Client struct {
	SourceName       string   `json:"-"`
	Anomalies        int64    `json:"anomalies,omitempty"`
	ApMac            string   `json:"ap_mac"`
	ApName           string   `json:"-"`
	AssocTime        int64    `json:"assoc_time"`
	Blocked          bool     `json:"blocked,omitempty"`
	Bssid            string   `json:"bssid"`
	BytesR           int64    `json:"bytes-r"`
	Ccq              int64    `json:"ccq"`
	Channel          FlexInt  `json:"channel"`
	DevCat           FlexInt  `json:"dev_cat"`
	DevFamily        FlexInt  `json:"dev_family"`
	DevID            FlexInt  `json:"dev_id"`
	DevVendor        FlexInt  `json:"dev_vendor,omitempty"`
	DhcpendTime      FlexInt  `json:"dhcpend_time,omitempty"`
	Satisfaction     FlexInt  `json:"satisfaction,omitempty"`
	Essid            string   `json:"essid"`
	FirstSeen        int64    `json:"first_seen"`
	FixedIP          string   `json:"fixed_ip"`
	GwMac            string   `json:"gw_mac"`
	GwName           string   `json:"-"`
	Hostname         string   `json:"hostname"`
	ID               string   `json:"_id"`
	IP               string   `json:"ip"`
	IdleTime         int64    `json:"idle_time"`
	Is11R            FlexBool `json:"is_11r"`
	IsGuest          FlexBool `json:"is_guest"`
	IsGuestByUAP     FlexBool `json:"_is_guest_by_uap"`
	IsGuestByUGW     FlexBool `json:"_is_guest_by_ugw"`
	IsGuestByUSW     FlexBool `json:"_is_guest_by_usw"`
	IsWired          FlexBool `json:"is_wired"`
	LastSeen         int64    `json:"last_seen"`
	LastSeenByUAP    int64    `json:"_last_seen_by_uap"`
	LastSeenByUGW    int64    `json:"_last_seen_by_ugw"`
	LastSeenByUSW    int64    `json:"_last_seen_by_usw"`
	LatestAssocTime  int64    `json:"latest_assoc_time"`
	Mac              string   `json:"mac"`
	Name             string   `json:"name"`
	Network          string   `json:"network"`
	NetworkID        string   `json:"network_id"`
	Noise            int64    `json:"noise"`
	Note             string   `json:"note"`
	Noted            FlexBool `json:"noted"`
	OsClass          FlexInt  `json:"os_class"`
	OsName           FlexInt  `json:"os_name"`
	Oui              string   `json:"oui"`
	PowersaveEnabled FlexBool `json:"powersave_enabled"`
	QosPolicyApplied FlexBool `json:"qos_policy_applied"`
	Radio            string   `json:"radio"`
	RadioName        string   `json:"radio_name"`
	RadioProto       string   `json:"radio_proto"`
	RadioDescription string   `json:"-"`
	RoamCount        int64    `json:"roam_count"`
	Rssi             int64    `json:"rssi"`
	RxBytes          int64    `json:"rx_bytes"`
	RxBytesR         int64    `json:"rx_bytes-r"`
	RxPackets        int64    `json:"rx_packets"`
	RxRate           int64    `json:"rx_rate"`
	Signal           int64    `json:"signal"`
	SiteID           string   `json:"site_id"`
	SiteName         string   `json:"-"`
	SwDepth          int      `json:"sw_depth"`
	SwMac            string   `json:"sw_mac"`
	SwName           string   `json:"-"`
	SwPort           FlexInt  `json:"sw_port"`
	TxBytes          int64    `json:"tx_bytes"`
	TxBytesR         int64    `json:"tx_bytes-r"`
	TxPackets        int64    `json:"tx_packets"`
	TxRetries        int64    `json:"tx_retries"`
	TxPower          int64    `json:"tx_power"`
	TxRate           int64    `json:"tx_rate"`
	Uptime           int64    `json:"uptime"`
	UptimeByUAP      int64    `json:"_uptime_by_uap"`
	UptimeByUGW      int64    `json:"_uptime_by_ugw"`
	UptimeByUSW      int64    `json:"_uptime_by_usw"`
	UseFixedIP       FlexBool `json:"use_fixedip"`
	UserGroupID      string   `json:"usergroup_id"`
	UserID           string   `json:"user_id"`
	Vlan             FlexInt  `json:"vlan"`
	WifiTxAttempts   int64    `json:"wifi_tx_attempts"`
	WiredRxBytes     int64    `json:"wired-rx_bytes"`
	WiredRxBytesR    int64    `json:"wired-rx_bytes-r"`
	WiredRxPackets   int64    `json:"wired-rx_packets"`
	WiredTxBytes     int64    `json:"wired-tx_bytes"`
	WiredTxBytesR    int64    `json:"wired-tx_bytes-r"`
	WiredTxPackets   int64    `json:"wired-tx_packets"`
}

Client defines all the data a connected-network client contains.

type Config

type Config struct {
	User      string
	Pass      string
	URL       string
	VerifySSL bool
	New       bool
	ErrorLog  Logger
	DebugLog  Logger
}

Config is the data passed into our library. This configures things and allows us to connect to a controller and write log messages.

type DPIData

type DPIData struct {
	Cat       int   `json:"cat"`
	App       int   `json:"app"`
	RxBytes   int64 `json:"rx_bytes"`
	TxBytes   int64 `json:"tx_bytes"`
	RxPackets int64 `json:"rx_packets"`
	TxPackets int64 `json:"tx_packets"`
}

DPIData is the DPI data in the DPI table.

type DPIMap

type DPIMap map[int]string

DPIMap allows binding methods to the DPICat and DPIApps variables.

func (DPIMap) Get

func (d DPIMap) Get(cat int) string

Get returns a value, or an unknown placeholder.

func (DPIMap) GetApp

func (d DPIMap) GetApp(cat, app int) string

GetApp returns an app value, or an unknown placeholder.

func (DPIMap) Keys

func (d DPIMap) Keys() []string

Keys returns the map keys in a slice.

type DPITable

type DPITable struct {
	SourceName  string    `json:"-"`
	SiteName    string    `json:"-"`
	Name        string    `json:"-"`
	MAC         string    `json:"mac"`
	ByCat       []DPIData `json:"by_cat"`
	ByApp       []DPIData `json:"by_app"`
	LastUpdated int64     `json:"last_updated"`
}

DPITable contains DPI data for clients or sites, or .. things.

type Devices

type Devices struct {
	UAPs []*UAP
	USGs []*USG
	USWs []*USW
	UDMs []*UDM
}

Devices contains a list of all the unifi devices from a controller. Contains Access points, security gateways and switches.

type Event

type Event struct {
	IsAdmin               FlexBool  `json:"is_admin"`
	DestPort              int       `json:"dest_port"`
	SrcPort               int       `json:"src_port"`
	Bytes                 FlexInt   `json:"bytes"`
	Duration              FlexInt   `json:"duration"`
	FlowID                FlexInt   `json:"flow_id"`
	InnerAlertGID         FlexInt   `json:"inner_alert_gid"`
	InnerAlertRev         FlexInt   `json:"inner_alert_rev"`
	InnerAlertSeverity    FlexInt   `json:"inner_alert_severity"`
	InnerAlertSignatureID FlexInt   `json:"inner_alert_signature_id"`
	Channel               FlexInt   `json:"channel"`
	ChannelFrom           FlexInt   `json:"channel_from"`
	ChannelTo             FlexInt   `json:"channel_to"`
	Time                  int64     `json:"time"`
	Timestamp             int64     `json:"timestamp"`
	Datetime              time.Time `json:"datetime"`
	Admin                 string    `json:"admin"`
	Ap                    string    `json:"ap"`
	ApFrom                string    `json:"ap_from"`
	ApName                string    `json:"ap_name"`
	ApTo                  string    `json:"ap_to"`
	AppProto              string    `json:"app_proto"`
	Catname               string    `json:"catname"`
	DestIP                string    `json:"dest_ip"`
	DstMAC                string    `json:"dst_mac"`
	EventType             string    `json:"event_type"`
	Guest                 string    `json:"guest"`
	Gw                    string    `json:"gw"`
	GwName                string    `json:"gw_name"`
	Host                  string    `json:"host"`
	Hostname              string    `json:"hostname"`
	ID                    string    `json:"_id"`
	IP                    string    `json:"ip"`
	InIface               string    `json:"in_iface"`
	InnerAlertAction      string    `json:"inner_alert_action"`
	InnerAlertCategory    string    `json:"inner_alert_category"`
	InnerAlertSignature   string    `json:"inner_alert_signature"`
	Key                   string    `json:"key"`
	Msg                   string    `json:"msg"`
	Network               string    `json:"network"`
	Proto                 string    `json:"proto"`
	Radio                 string    `json:"radio"`
	RadioFrom             string    `json:"radio_from"`
	RadioTo               string    `json:"radio_to"`
	SiteID                string    `json:"site_id"`
	SiteName              string    `json:"-"`
	SourceName            string    `json:"-"`
	SrcIP                 string    `json:"src_ip"`
	SrcMAC                string    `json:"src_mac"`
	SrcIPASN              string    `json:"srcipASN"`
	SrcIPCountry          string    `json:"srcipCountry"`
	SSID                  string    `json:"ssid"`
	Subsystem             string    `json:"subsystem"`
	Sw                    string    `json:"sw"`
	SwName                string    `json:"sw_name"`
	UniqueAlertID         string    `json:"unique_alertid"`
	User                  string    `json:"user"`
	USGIP                 string    `json:"usgip"`
	USGIPASN              string    `json:"usgipASN"`
	USGIPCountry          string    `json:"usgipCountry"`
	DestIPGeo             IPGeo     `json:"dstipGeo"`
	SourceIPGeo           IPGeo     `json:"srcipGeo"`
	USGIPGeo              IPGeo     `json:"usgipGeo"`
}

Event describes a UniFi Event. API Path: /api/s/default/stat/event.

type FlexBool

type FlexBool struct {
	Val bool
	Txt string
}

FlexBool provides a container and unmarshalling for fields that may be boolean or strings in the Unifi API.

func (*FlexBool) String

func (f *FlexBool) String() string

func (*FlexBool) UnmarshalJSON

func (f *FlexBool) UnmarshalJSON(b []byte) error

UnmarshalJSON method converts armed/disarmed, yes/no, active/inactive or 0/1 to true/false. Really it converts ready, ok, up, t, armed, yes, active, enabled, 1, true to true. Anything else is false.

type FlexInt

type FlexInt struct {
	Val float64
	Txt string
}

FlexInt provides a container and unmarshalling for fields that may be numbers or strings in the Unifi API.

func (*FlexInt) String

func (f *FlexInt) String() string

func (*FlexInt) UnmarshalJSON

func (f *FlexInt) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a string or number to an integer. Generally, do call this directly, it's used in the json interface.

type Gw

type Gw struct {
	SiteID       string    `json:"site_id"`
	O            string    `json:"o"`
	Oid          string    `json:"oid"`
	Gw           string    `json:"gw"`
	Time         FlexInt   `json:"time"`
	Datetime     time.Time `json:"datetime"`
	Duration     FlexInt   `json:"duration"`
	WanRxPackets FlexInt   `json:"wan-rx_packets"`
	WanRxBytes   FlexInt   `json:"wan-rx_bytes"`
	WanRxDropped FlexInt   `json:"wan-rx_dropped"`
	WanTxPackets FlexInt   `json:"wan-tx_packets"`
	WanTxBytes   FlexInt   `json:"wan-tx_bytes"`
	LanRxPackets FlexInt   `json:"lan-rx_packets"`
	LanRxBytes   FlexInt   `json:"lan-rx_bytes"`
	LanTxPackets FlexInt   `json:"lan-tx_packets"`
	LanTxBytes   FlexInt   `json:"lan-tx_bytes"`
	LanRxDropped FlexInt   `json:"lan-rx_dropped"`
	WanRxErrors  FlexInt   `json:"wan-rx_errors,omitempty"`
}

Gw is a subtype of USGStat to make unmarshalling of different controller versions possible.

type IDS

type IDS struct {
	Archived              FlexBool  `json:"archived"`
	DestPort              int       `json:"dest_port,omitempty"`
	SrcPort               int       `json:"src_port,omitempty"`
	FlowID                int64     `json:"flow_id"`
	InnerAlertRev         int64     `json:"inner_alert_rev"`
	InnerAlertSeverity    int64     `json:"inner_alert_severity"`
	InnerAlertGID         int64     `json:"inner_alert_gid"`
	InnerAlertSignatureID int64     `json:"inner_alert_signature_id"`
	Time                  int64     `json:"time"`
	Timestamp             int64     `json:"timestamp"`
	Datetime              time.Time `json:"datetime"`
	AppProto              string    `json:"app_proto,omitempty"`
	Catname               string    `json:"catname"`
	DestIP                string    `json:"dest_ip"`
	DstMAC                string    `json:"dst_mac"`
	DstIPASN              string    `json:"dstipASN"`
	DstIPCountry          string    `json:"dstipCountry"`
	EventType             string    `json:"event_type"`
	Host                  string    `json:"host"`
	ID                    string    `json:"_id"`
	InIface               string    `json:"in_iface"`
	InnerAlertAction      string    `json:"inner_alert_action"`
	InnerAlertCategory    string    `json:"inner_alert_category"`
	InnerAlertSignature   string    `json:"inner_alert_signature"`
	Key                   string    `json:"key"`
	Msg                   string    `json:"msg"`
	Proto                 string    `json:"proto"`
	SiteID                string    `json:"site_id"`
	SiteName              string    `json:"-"`
	SourceName            string    `json:"-"`
	SrcIP                 string    `json:"src_ip"`
	SrcIPASN              string    `json:"srcipASN"`
	SrcIPCountry          string    `json:"srcipCountry"`
	SrcMAC                string    `json:"src_mac"`
	Subsystem             string    `json:"subsystem"`
	UniqueAlertID         string    `json:"unique_alertid"`
	USGIP                 string    `json:"usgip"`
	USGIPASN              string    `json:"usgipASN"`
	USGIPCountry          string    `json:"usgipCountry"`
	DestIPGeo             IPGeo     `json:"dstipGeo"`
	SourceIPGeo           IPGeo     `json:"srcipGeo"`
	USGIPGeo              IPGeo     `json:"usgipGeo"`
}

IDS holds an Intrusion Prevention System Event.

type IPGeo

type IPGeo struct {
	Asn           int64   `json:"asn"`
	Latitude      float64 `json:"latitude"`
	Longitude     float64 `json:"longitude"`
	City          string  `json:"city"`
	ContinentCode string  `json:"continent_code"`
	CountryCode   string  `json:"country_code"`
	CountryName   string  `json:"country_name"`
	Organization  string  `json:"organization"`
}

IPGeo is part of the UniFi Event data. Each event may have up to three of these. One for source, one for dest and one for the USG location.

func (*IPGeo) UnmarshalJSON

func (v *IPGeo) UnmarshalJSON(data []byte) error

UnmarshalJSON is required because sometimes the unifi api returns an empty array instead of a struct filled with data.

type Logger

type Logger func(msg string, fmt ...interface{})

Logger is a base type to deal with changing log outputs. Create a logger that matches this interface to capture debug and error logs.

type Network

type Network struct {
	DhcpdDNSEnabled        FlexBool `json:"dhcpd_dns_enabled"`
	DhcpdEnabled           FlexBool `json:"dhcpd_enabled"`
	DhcpdGatewayEnabled    FlexBool `json:"dhcpd_gateway_enabled"`
	DhcpdIP1               string   `json:"dhcpd_ip_1"`
	DhcpdLeasetime         FlexInt  `json:"dhcpd_leasetime"`
	DhcpRelayEnabled       FlexBool `json:"dhcp_relay_enabled"`
	DhcpdTimeOffsetEnabled FlexBool `json:"dhcpd_time_offset_enabled"`
	DhcpGuardEnabled       FlexBool `json:"dhcpguard_enabled"`
	DomainName             string   `json:"domain_name"`
	Enabled                FlexBool `json:"enabled"`
	ID                     string   `json:"_id"`
	IPSubnet               string   `json:"ip_subnet"`
	IsNat                  FlexBool `json:"is_nat"`
	Name                   string   `json:"name"`
	Networkgroup           string   `json:"networkgroup"`
	Purpose                string   `json:"purpose"`
	SiteID                 string   `json:"site_id"`
	Vlan                   FlexInt  `json:"vlan"`
	VlanEnabled            FlexBool `json:"vlan_enabled"`
}

Network is metadata about a network managed by a UniFi controller

type NetworkTable

type NetworkTable []struct {
	ID                     string   `json:"_id"`
	AttrNoDelete           FlexBool `json:"attr_no_delete"`
	AttrHiddenID           string   `json:"attr_hidden_id"`
	Name                   string   `json:"name"`
	SiteID                 string   `json:"site_id"`
	VlanEnabled            FlexBool `json:"vlan_enabled"`
	Purpose                string   `json:"purpose"`
	IPSubnet               string   `json:"ip_subnet"`
	Ipv6InterfaceType      string   `json:"ipv6_interface_type"`
	DomainName             string   `json:"domain_name"`
	IsNat                  FlexBool `json:"is_nat"`
	DhcpdEnabled           FlexBool `json:"dhcpd_enabled"`
	DhcpdStart             string   `json:"dhcpd_start"`
	DhcpdStop              string   `json:"dhcpd_stop"`
	Dhcpdv6Enabled         FlexBool `json:"dhcpdv6_enabled"`
	Ipv6RaEnabled          FlexBool `json:"ipv6_ra_enabled"`
	LteLanEnabled          FlexBool `json:"lte_lan_enabled"`
	Networkgroup           string   `json:"networkgroup"`
	DhcpdLeasetime         FlexInt  `json:"dhcpd_leasetime"`
	DhcpdDNSEnabled        FlexBool `json:"dhcpd_dns_enabled"`
	DhcpdGatewayEnabled    FlexBool `json:"dhcpd_gateway_enabled"`
	DhcpdTimeOffsetEnabled FlexBool `json:"dhcpd_time_offset_enabled"`
	Ipv6PdStart            string   `json:"ipv6_pd_start"`
	Ipv6PdStop             string   `json:"ipv6_pd_stop"`
	DhcpdDNS1              string   `json:"dhcpd_dns_1"`
	DhcpdDNS2              string   `json:"dhcpd_dns_2"`
	DhcpdDNS3              string   `json:"dhcpd_dns_3"`
	DhcpdDNS4              string   `json:"dhcpd_dns_4"`
	Enabled                FlexBool `json:"enabled"`
	DhcpRelayEnabled       FlexBool `json:"dhcp_relay_enabled"`
	Mac                    string   `json:"mac"`
	IsGuest                FlexBool `json:"is_guest"`
	IP                     string   `json:"ip"`
	Up                     FlexBool `json:"up"`
	NumSta                 FlexInt  `json:"num_sta"`
	RxBytes                FlexInt  `json:"rx_bytes"`
	RxPackets              FlexInt  `json:"rx_packets"`
	TxBytes                FlexInt  `json:"tx_bytes"`
	TxPackets              FlexInt  `json:"tx_packets"`
}

NetworkTable is the list of networks on a gateway.

type Port

type Port struct {
	AggregatedBy FlexBool `json:"aggregated_by"`
	Autoneg      FlexBool `json:"autoneg,omitempty"`
	BytesR       FlexInt  `json:"bytes-r"`
	DNS          []string `json:"dns,omitempty"`
	Dot1XMode    string   `json:"dot1x_mode"`
	Dot1XStatus  string   `json:"dot1x_status"`
	Enable       FlexBool `json:"enable"`
	FlowctrlRx   FlexBool `json:"flowctrl_rx"`
	FlowctrlTx   FlexBool `json:"flowctrl_tx"`
	FullDuplex   FlexBool `json:"full_duplex"`
	IP           string   `json:"ip,omitempty"`
	Ifname       string   `json:"ifname,omitempty"`
	IsUplink     FlexBool `json:"is_uplink"`
	Mac          string   `json:"mac,omitempty"`
	Jumbo        FlexBool `json:"jumbo,omitempty"`
	Masked       FlexBool `json:"masked"`
	Media        string   `json:"media"`
	Name         string   `json:"name"`
	NetworkName  string   `json:"network_name,omitempty"`
	NumPort      int      `json:"num_port,omitempty"`
	OpMode       string   `json:"op_mode"`
	PoeCaps      FlexInt  `json:"poe_caps"`
	PoeClass     string   `json:"poe_class,omitempty"`
	PoeCurrent   FlexInt  `json:"poe_current,omitempty"`
	PoeEnable    FlexBool `json:"poe_enable,omitempty"`
	PoeGood      FlexBool `json:"poe_good,omitempty"`
	PoeMode      string   `json:"poe_mode,omitempty"`
	PoePower     FlexInt  `json:"poe_power,omitempty"`
	PoeVoltage   FlexInt  `json:"poe_voltage,omitempty"`
	PortDelta    struct {
		TimeDelta int64 `json:"time_delta"`
	} `json:"port_delta,omitempty"`
	PortIdx      FlexInt  `json:"port_idx"`
	PortPoe      FlexBool `json:"port_poe"`
	PortconfID   string   `json:"portconf_id"`
	RxBroadcast  FlexInt  `json:"rx_broadcast"`
	RxBytes      FlexInt  `json:"rx_bytes"`
	RxBytesR     FlexInt  `json:"rx_bytes-r"`
	RxDropped    FlexInt  `json:"rx_dropped"`
	RxErrors     FlexInt  `json:"rx_errors"`
	RxMulticast  FlexInt  `json:"rx_multicast"`
	RxPackets    FlexInt  `json:"rx_packets"`
	Satisfaction FlexInt  `json:"satisfaction,omitempty"`
	SfpFound     FlexBool `json:"sfp_found,omitempty"`
	Speed        FlexInt  `json:"speed"`
	SpeedCaps    FlexInt  `json:"speed_caps"`
	StpPathcost  FlexInt  `json:"stp_pathcost"`
	StpState     string   `json:"stp_state"`
	TxBroadcast  FlexInt  `json:"tx_broadcast"`
	TxBytes      FlexInt  `json:"tx_bytes"`
	TxBytesR     FlexInt  `json:"tx_bytes-r"`
	TxDropped    FlexInt  `json:"tx_dropped"`
	TxErrors     FlexInt  `json:"tx_errors"`
	TxMulticast  FlexInt  `json:"tx_multicast"`
	TxPackets    FlexInt  `json:"tx_packets"`
	Type         string   `json:"type,omitempty"`
	Up           FlexBool `json:"up"`
}

Port is a physical connection on a USW or UDM.

type RadioTable

type RadioTable []struct {
	AntennaGain        FlexInt  `json:"antenna_gain"`
	BuiltinAntGain     FlexInt  `json:"builtin_ant_gain"`
	BuiltinAntenna     FlexBool `json:"builtin_antenna"`
	Channel            FlexInt  `json:"channel"`
	CurrentAntennaGain FlexInt  `json:"current_antenna_gain"`
	HasDfs             FlexBool `json:"has_dfs"`
	HasFccdfs          FlexBool `json:"has_fccdfs"`
	HasHt160           FlexBool `json:"has_ht160"`
	Ht                 FlexInt  `json:"ht"`
	Is11Ac             FlexBool `json:"is_11ac"`
	MaxTxpower         FlexInt  `json:"max_txpower"`
	MinRssi            FlexInt  `json:"min_rssi,omitempty"`
	MinRssiEnabled     FlexBool `json:"min_rssi_enabled"`
	MinTxpower         FlexInt  `json:"min_txpower"`
	Name               string   `json:"name"`
	Nss                FlexInt  `json:"nss"`
	Radio              string   `json:"radio"`
	RadioCaps          FlexInt  `json:"radio_caps"`
	SensLevelEnabled   FlexBool `json:"sens_level_enabled"`
	TxPower            FlexInt  `json:"tx_power"`
	TxPowerMode        string   `json:"tx_power_mode"`
	VwireEnabled       FlexBool `json:"vwire_enabled"`
	WlangroupID        string   `json:"wlangroup_id"`
}

RadioTable is part of the data for UAPs and UDMs.

type RadioTableStats

type RadioTableStats []struct {
	Name         string      `json:"name"`
	Channel      FlexInt     `json:"channel"`
	Radio        string      `json:"radio"`
	AstTxto      interface{} `json:"ast_txto"`
	AstCst       interface{} `json:"ast_cst"`
	AstBeXmit    FlexInt     `json:"ast_be_xmit"`
	CuTotal      FlexInt     `json:"cu_total"`
	CuSelfRx     FlexInt     `json:"cu_self_rx"`
	CuSelfTx     FlexInt     `json:"cu_self_tx"`
	Gain         FlexInt     `json:"gain"`
	Satisfaction FlexInt     `json:"satisfaction"`
	State        string      `json:"state"`
	Extchannel   FlexInt     `json:"extchannel"`
	TxPower      FlexInt     `json:"tx_power"`
	TxPackets    FlexInt     `json:"tx_packets"`
	TxRetries    FlexInt     `json:"tx_retries"`
	NumSta       FlexInt     `json:"num_sta"`
	GuestNumSta  FlexInt     `json:"guest-num_sta"`
	UserNumSta   FlexInt     `json:"user-num_sta"`
}

RadioTableStats is part of the data shared between UAP and UDM.

type Site

type Site struct {
	SourceName   string   `json:"-"`
	ID           string   `json:"_id"`
	Name         string   `json:"name"`
	Desc         string   `json:"desc"`
	SiteName     string   `json:"-"`
	AttrHiddenID string   `json:"attr_hidden_id"`
	AttrNoDelete FlexBool `json:"attr_no_delete"`
	Health       []struct {
		Subsystem       string   `json:"subsystem"`
		NumUser         FlexInt  `json:"num_user,omitempty"`
		NumGuest        FlexInt  `json:"num_guest,omitempty"`
		NumIot          FlexInt  `json:"num_iot,omitempty"`
		TxBytesR        FlexInt  `json:"tx_bytes-r,omitempty"`
		RxBytesR        FlexInt  `json:"rx_bytes-r,omitempty"`
		Status          string   `json:"status"`
		NumAp           FlexInt  `json:"num_ap,omitempty"`
		NumAdopted      FlexInt  `json:"num_adopted,omitempty"`
		NumDisabled     FlexInt  `json:"num_disabled,omitempty"`
		NumDisconnected FlexInt  `json:"num_disconnected,omitempty"`
		NumPending      FlexInt  `json:"num_pending,omitempty"`
		NumGw           FlexInt  `json:"num_gw,omitempty"`
		WanIP           string   `json:"wan_ip,omitempty"`
		Gateways        []string `json:"gateways,omitempty"`
		Netmask         string   `json:"netmask,omitempty"`
		Nameservers     []string `json:"nameservers,omitempty"`
		NumSta          FlexInt  `json:"num_sta,omitempty"`
		GwMac           string   `json:"gw_mac,omitempty"`
		GwName          string   `json:"gw_name,omitempty"`
		GwSystemStats   struct {
			CPU    FlexInt `json:"cpu"`
			Mem    FlexInt `json:"mem"`
			Uptime FlexInt `json:"uptime"`
		} `json:"gw_system-stats,omitempty"`
		GwVersion             string   `json:"gw_version,omitempty"`
		Latency               FlexInt  `json:"latency,omitempty"`
		Uptime                FlexInt  `json:"uptime,omitempty"`
		Drops                 FlexInt  `json:"drops,omitempty"`
		XputUp                FlexInt  `json:"xput_up,omitempty"`
		XputDown              FlexInt  `json:"xput_down,omitempty"`
		SpeedtestStatus       string   `json:"speedtest_status,omitempty"`
		SpeedtestLastrun      FlexInt  `json:"speedtest_lastrun,omitempty"`
		SpeedtestPing         FlexInt  `json:"speedtest_ping,omitempty"`
		LanIP                 string   `json:"lan_ip,omitempty"`
		NumSw                 FlexInt  `json:"num_sw,omitempty"`
		RemoteUserEnabled     FlexBool `json:"remote_user_enabled,omitempty"`
		RemoteUserNumActive   FlexInt  `json:"remote_user_num_active,omitempty"`
		RemoteUserNumInactive FlexInt  `json:"remote_user_num_inactive,omitempty"`
		RemoteUserRxBytes     FlexInt  `json:"remote_user_rx_bytes,omitempty"`
		RemoteUserTxBytes     FlexInt  `json:"remote_user_tx_bytes,omitempty"`
		RemoteUserRxPackets   FlexInt  `json:"remote_user_rx_packets,omitempty"`
		RemoteUserTxPackets   FlexInt  `json:"remote_user_tx_packets,omitempty"`
		SiteToSiteEnabled     FlexBool `json:"site_to_site_enabled,omitempty"`
	} `json:"health"`
	NumNewAlarms FlexInt `json:"num_new_alarms"`
}

Site represents a site's data.

type SpeedtestStatus

type SpeedtestStatus struct {
	Latency        FlexInt `json:"latency"`
	Rundate        FlexInt `json:"rundate"`
	Runtime        FlexInt `json:"runtime"`
	ServerDesc     string  `json:"server_desc,omitempty"`
	StatusDownload FlexInt `json:"status_download"`
	StatusPing     FlexInt `json:"status_ping"`
	StatusSummary  FlexInt `json:"status_summary"`
	StatusUpload   FlexInt `json:"status_upload"`
	XputDownload   FlexInt `json:"xput_download"`
	XputUpload     FlexInt `json:"xput_upload"`
}

SpeedtestStatus is the speed test info on a USG or UDM.

type Sw

type Sw struct {
	SiteID      string    `json:"site_id"`
	O           string    `json:"o"`
	Oid         string    `json:"oid"`
	Sw          string    `json:"sw"`
	Time        FlexInt   `json:"time"`
	Datetime    time.Time `json:"datetime"`
	RxPackets   FlexInt   `json:"rx_packets"`
	RxBytes     FlexInt   `json:"rx_bytes"`
	RxErrors    FlexInt   `json:"rx_errors"`
	RxDropped   FlexInt   `json:"rx_dropped"`
	RxCrypts    FlexInt   `json:"rx_crypts"`
	RxFrags     FlexInt   `json:"rx_frags"`
	TxPackets   FlexInt   `json:"tx_packets"`
	TxBytes     FlexInt   `json:"tx_bytes"`
	TxErrors    FlexInt   `json:"tx_errors"`
	TxDropped   FlexInt   `json:"tx_dropped"`
	TxRetries   FlexInt   `json:"tx_retries"`
	RxMulticast FlexInt   `json:"rx_multicast"`
	RxBroadcast FlexInt   `json:"rx_broadcast"`
	TxMulticast FlexInt   `json:"tx_multicast"`
	TxBroadcast FlexInt   `json:"tx_broadcast"`
	Bytes       FlexInt   `json:"bytes"`
	Duration    FlexInt   `json:"duration"`
}

Sw is a subtype of USWStat to make unmarshalling of different controller versions possible.

type SysStats

type SysStats struct {
	Loadavg1  FlexInt `json:"loadavg_1"`
	Loadavg15 FlexInt `json:"loadavg_15"`
	Loadavg5  FlexInt `json:"loadavg_5"`
	MemBuffer FlexInt `json:"mem_buffer"`
	MemTotal  FlexInt `json:"mem_total"`
	MemUsed   FlexInt `json:"mem_used"`
}

SysStats is load info for a UDM, USG, USW.

type SystemStats

type SystemStats struct {
	CPU    FlexInt `json:"cpu"`
	Mem    FlexInt `json:"mem"`
	Uptime FlexInt `json:"uptime"`
}

SystemStats is system info for a UDM, USG, USW.

type Temperature

type Temperature struct {
	Name  string  `json:"name"`
	Type  string  `json:"type"`
	Value float64 `json:"value"`
}

type UAP

type UAP struct {
	SourceName   string   `json:"-"`
	ID           string   `json:"_id"`
	Adopted      FlexBool `json:"adopted"`
	AntennaTable []struct {
		Default   FlexBool `json:"default"`
		ID        FlexInt  `json:"id"`
		Name      string   `json:"name"`
		Wifi0Gain FlexInt  `json:"wifi0_gain"`
		Wifi1Gain FlexInt  `json:"wifi1_gain"`
	} `json:"antenna_table"`
	BandsteeringMode string `json:"bandsteering_mode,omitempty"`
	BoardRev         int    `json:"board_rev"`
	Cfgversion       string `json:"cfgversion"`
	ConfigNetwork    struct {
		Type string `json:"type"`
		IP   string `json:"ip"`
	} `json:"config_network"`
	CountrycodeTable []int `json:"countrycode_table"`
	EthernetTable    []struct {
		Mac     string  `json:"mac"`
		NumPort FlexInt `json:"num_port"`
		Name    string  `json:"name"`
	} `json:"ethernet_table"`
	FwCaps                int             `json:"fw_caps"`
	HasEth1               FlexBool        `json:"has_eth1"`
	HasSpeaker            FlexBool        `json:"has_speaker"`
	InformIP              string          `json:"inform_ip"`
	InformURL             string          `json:"inform_url"`
	IP                    string          `json:"ip"`
	LedOverride           string          `json:"led_override"`
	Mac                   string          `json:"mac"`
	MeshStaVapEnabled     FlexBool        `json:"mesh_sta_vap_enabled"`
	Model                 string          `json:"model"`
	Name                  string          `json:"name"`
	OutdoorModeOverride   string          `json:"outdoor_mode_override"`
	PortTable             []Port          `json:"port_table"`
	RadioTable            RadioTable      `json:"radio_table"`
	ScanRadioTable        []interface{}   `json:"scan_radio_table"`
	Serial                string          `json:"serial"`
	SiteID                string          `json:"site_id"`
	SiteName              string          `json:"-"`
	Type                  string          `json:"type"`
	Version               string          `json:"version"`
	VwireTable            []interface{}   `json:"vwire_table"`
	WifiCaps              int             `json:"wifi_caps"`
	WlangroupIDNa         string          `json:"wlangroup_id_na"`
	WlangroupIDNg         string          `json:"wlangroup_id_ng"`
	RequiredVersion       string          `json:"required_version"`
	HwCaps                int             `json:"hw_caps"`
	Unsupported           FlexBool        `json:"unsupported"`
	UnsupportedReason     FlexInt         `json:"unsupported_reason"`
	SysErrorCaps          int             `json:"sys_error_caps"`
	HasFan                FlexBool        `json:"has_fan"`
	HasTemperature        FlexBool        `json:"has_temperature"`
	DeviceID              string          `json:"device_id"`
	State                 FlexInt         `json:"state"`
	LastSeen              FlexInt         `json:"last_seen"`
	Upgradable            FlexBool        `json:"upgradable"`
	AdoptableWhenUpgraded FlexBool        `json:"adoptable_when_upgraded"`
	Rollupgrade           FlexBool        `json:"rollupgrade"`
	KnownCfgversion       string          `json:"known_cfgversion"`
	Uptime                FlexInt         `json:"uptime"`
	UUptime               FlexInt         `json:"_uptime"`
	Locating              FlexBool        `json:"locating"`
	ConnectRequestIP      string          `json:"connect_request_ip"`
	ConnectRequestPort    string          `json:"connect_request_port"`
	SysStats              SysStats        `json:"sys_stats"`
	SystemStats           SystemStats     `json:"system-stats"`
	SSHSessionTable       []interface{}   `json:"ssh_session_table"`
	Scanning              FlexBool        `json:"scanning"`
	SpectrumScanning      FlexBool        `json:"spectrum_scanning"`
	GuestToken            string          `json:"guest_token"`
	Meshv3PeerMac         string          `json:"meshv3_peer_mac"`
	Satisfaction          FlexInt         `json:"satisfaction"`
	Isolated              FlexBool        `json:"isolated"`
	RadioTableStats       RadioTableStats `json:"radio_table_stats"`
	Uplink                struct {
		FullDuplex       FlexBool `json:"full_duplex"`
		IP               string   `json:"ip"`
		Mac              string   `json:"mac"`
		MaxVlan          int      `json:"max_vlan"`
		Name             string   `json:"name"`
		Netmask          string   `json:"netmask"`
		NumPort          int      `json:"num_port"`
		RxBytes          FlexInt  `json:"rx_bytes"`
		RxDropped        FlexInt  `json:"rx_dropped"`
		RxErrors         FlexInt  `json:"rx_errors"`
		RxMulticast      FlexInt  `json:"rx_multicast"`
		RxPackets        FlexInt  `json:"rx_packets"`
		Speed            FlexInt  `json:"speed"`
		TxBytes          FlexInt  `json:"tx_bytes"`
		TxDropped        FlexInt  `json:"tx_dropped"`
		TxErrors         FlexInt  `json:"tx_errors"`
		TxPackets        FlexInt  `json:"tx_packets"`
		Up               FlexBool `json:"up"`
		MaxSpeed         FlexInt  `json:"max_speed"`
		Type             string   `json:"type"`
		TxBytesR         FlexInt  `json:"tx_bytes-r"`
		RxBytesR         FlexInt  `json:"rx_bytes-r"`
		UplinkMac        string   `json:"uplink_mac"`
		UplinkRemotePort int      `json:"uplink_remote_port"`
	} `json:"uplink"`
	VapTable      VapTable `json:"vap_table"`
	DownlinkTable []struct {
		PortIdx    int    `json:"port_idx"`
		Speed      int    `json:"speed"`
		FullDuplex bool   `json:"full_duplex"`
		Mac        string `json:"mac"`
	} `json:"downlink_table,omitempty"`
	VwireVapTable []interface{} `json:"vwire_vap_table"`
	BytesD        FlexInt       `json:"bytes-d"`
	TxBytesD      FlexInt       `json:"tx_bytes-d"`
	RxBytesD      FlexInt       `json:"rx_bytes-d"`
	BytesR        FlexInt       `json:"bytes-r"`
	LastUplink    struct {
		UplinkMac        string `json:"uplink_mac"`
		UplinkRemotePort int    `json:"uplink_remote_port"`
	} `json:"last_uplink"`
	Stat          UAPStat       `json:"stat"`
	TxBytes       FlexInt       `json:"tx_bytes"`
	RxBytes       FlexInt       `json:"rx_bytes"`
	Bytes         FlexInt       `json:"bytes"`
	VwireEnabled  FlexBool      `json:"vwireEnabled"`
	UplinkTable   []interface{} `json:"uplink_table"`
	NumSta        FlexInt       `json:"num_sta"`
	UserNumSta    FlexInt       `json:"user-num_sta"`
	GuestNumSta   FlexInt       `json:"guest-num_sta"`
	TwoPhaseAdopt FlexBool      `json:"two_phase_adopt,omitempty"`
}

UAP represents all the data from the Ubiquiti Controller for a Unifi Access Point. This was auto generated then edited by hand to get all the data types right.

type UAPStat

type UAPStat struct {
	*Ap
}

UAPStat holds the "stat" data for an access point. This is split out because of a JSON data format change from 5.10 to 5.11.

func (*UAPStat) UnmarshalJSON

func (v *UAPStat) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshalls 5.10 or 5.11 formatted Access Point Stat data.

type UDM

type UDM struct {
	SourceName            string   `json:"-"`
	SiteID                string   `json:"site_id"`
	SiteName              string   `json:"-"`
	Mac                   string   `json:"mac"`
	Adopted               FlexBool `json:"adopted"`
	Serial                string   `json:"serial"`
	IP                    string   `json:"ip"`
	Uptime                FlexInt  `json:"uptime"`
	Model                 string   `json:"model"`
	Version               string   `json:"version"`
	Name                  string   `json:"name"`
	Default               FlexBool `json:"default"`
	Locating              FlexBool `json:"locating"`
	Type                  string   `json:"type"`
	Unsupported           FlexBool `json:"unsupported"`
	UnsupportedReason     FlexInt  `json:"unsupported_reason"`
	DiscoveredVia         string   `json:"discovered_via"`
	AdoptIP               string   `json:"adopt_ip"`
	AdoptURL              string   `json:"adopt_url"`
	State                 FlexInt  `json:"state"`
	AdoptStatus           FlexInt  `json:"adopt_status"`
	UpgradeState          FlexInt  `json:"upgrade_state"`
	LastSeen              FlexInt  `json:"last_seen"`
	AdoptableWhenUpgraded FlexBool `json:"adoptable_when_upgraded"`
	Cfgversion            string   `json:"cfgversion"`
	ConfigNetwork         struct {
		Type string `json:"type"`
		IP   string `json:"ip"`
	} `json:"config_network"`
	VwireTable             []interface{} `json:"vwire_table"`
	Dot1XPortctrlEnabled   FlexBool      `json:"dot1x_portctrl_enabled"`
	JumboframeEnabled      FlexBool      `json:"jumboframe_enabled"`
	FlowctrlEnabled        FlexBool      `json:"flowctrl_enabled"`
	StpVersion             string        `json:"stp_version"`
	StpPriority            FlexInt       `json:"stp_priority"`
	PowerSourceCtrlEnabled FlexBool      `json:"power_source_ctrl_enabled"`
	LicenseState           string        `json:"license_state"`
	ID                     string        `json:"_id"`
	DeviceID               string        `json:"device_id"`
	AdoptState             FlexInt       `json:"adopt_state"`
	AdoptTries             FlexInt       `json:"adopt_tries"`
	AdoptManual            FlexBool      `json:"adopt_manual"`
	InformURL              string        `json:"inform_url"`
	InformIP               string        `json:"inform_ip"`
	RequiredVersion        string        `json:"required_version"`
	BoardRev               FlexInt       `json:"board_rev"`
	EthernetTable          []struct {
		Mac     string  `json:"mac"`
		NumPort FlexInt `json:"num_port"`
		Name    string  `json:"name"`
	} `json:"ethernet_table"`
	PortTable         []Port `json:"port_table"`
	EthernetOverrides []struct {
		Ifname       string `json:"ifname"`
		Networkgroup string `json:"networkgroup"`
	} `json:"ethernet_overrides"`
	UsgCaps    FlexInt  `json:"usg_caps"`
	HasSpeaker FlexBool `json:"has_speaker"`
	HasEth1    FlexBool `json:"has_eth1"`
	FwCaps     FlexInt  `json:"fw_caps"`
	HwCaps     FlexInt  `json:"hw_caps"`
	WifiCaps   FlexInt  `json:"wifi_caps"`
	SwitchCaps struct {
		MaxMirrorSessions    FlexInt `json:"max_mirror_sessions"`
		MaxAggregateSessions FlexInt `json:"max_aggregate_sessions"`
	} `json:"switch_caps"`
	HasFan            FlexBool      `json:"has_fan"`
	Temperatures      []Temperature `json:"temperatures,omitempty"`
	RulesetInterfaces interface{}   `json:"ruleset_interfaces"`
	/* struct {
		Br0  string `json:"br0"`
		Eth0 string `json:"eth0"`
		Eth1 string `json:"eth1"`
		Eth2 string `json:"eth2"`
		Eth3 string `json:"eth3"`
		Eth4 string `json:"eth4"`
		Eth5 string `json:"eth5"`
		Eth6 string `json:"eth6"`
		Eth7 string `json:"eth7"`
		Eth8 string `json:"eth8"`
	} */
	KnownCfgversion      string           `json:"known_cfgversion"`
	SysStats             SysStats         `json:"sys_stats"`
	SystemStats          SystemStats      `json:"system-stats"`
	GuestToken           string           `json:"guest_token"`
	Overheating          FlexBool         `json:"overheating"`
	SpeedtestStatus      SpeedtestStatus  `json:"speedtest-status"`
	SpeedtestStatusSaved FlexBool         `json:"speedtest-status-saved"`
	Wan1                 Wan              `json:"wan1"`
	Wan2                 Wan              `json:"wan2"`
	Uplink               Uplink           `json:"uplink"`
	ConnectRequestIP     string           `json:"connect_request_ip"`
	ConnectRequestPort   string           `json:"connect_request_port"`
	DownlinkTable        []interface{}    `json:"downlink_table"`
	WlangroupIDNa        string           `json:"wlangroup_id_na"`
	WlangroupIDNg        string           `json:"wlangroup_id_ng"`
	BandsteeringMode     string           `json:"bandsteering_mode"`
	RadioTable           *RadioTable      `json:"radio_table,omitempty"`
	RadioTableStats      *RadioTableStats `json:"radio_table_stats,omitempty"`
	VapTable             *VapTable        `json:"vap_table"`
	XInformAuthkey       string           `json:"x_inform_authkey"`
	NetworkTable         NetworkTable     `json:"network_table"`
	PortOverrides        []struct {
		PortIdx    FlexInt `json:"port_idx"`
		PortconfID string  `json:"portconf_id"`
	} `json:"port_overrides"`
	Stat            UDMStat `json:"stat"`
	TxBytes         FlexInt `json:"tx_bytes"`
	RxBytes         FlexInt `json:"rx_bytes"`
	Bytes           FlexInt `json:"bytes"`
	BytesD          FlexInt `json:"bytes-d"`
	TxBytesD        FlexInt `json:"tx_bytes-d"`
	RxBytesD        FlexInt `json:"rx_bytes-d"`
	BytesR          FlexInt `json:"bytes-r"`
	NumSta          FlexInt `json:"num_sta"`            // USG
	WlanNumSta      FlexInt `json:"wlan-num_sta"`       // UAP
	LanNumSta       FlexInt `json:"lan-num_sta"`        // USW
	UserWlanNumSta  FlexInt `json:"user-wlan-num_sta"`  // UAP
	UserLanNumSta   FlexInt `json:"user-lan-num_sta"`   // USW
	UserNumSta      FlexInt `json:"user-num_sta"`       // USG
	GuestWlanNumSta FlexInt `json:"guest-wlan-num_sta"` // UAP
	GuestLanNumSta  FlexInt `json:"guest-lan-num_sta"`  // USW
	GuestNumSta     FlexInt `json:"guest-num_sta"`      // USG
	NumDesktop      FlexInt `json:"num_desktop"`        // USG
	NumMobile       FlexInt `json:"num_mobile"`         // USG
	NumHandheld     FlexInt `json:"num_handheld"`       // USG
}

UDM represents all the data from the Ubiquiti Controller for a Unifi Dream Machine. The UDM shares several structs/type-data with USW and USG.

type UDMStat

type UDMStat struct {
	*Gw `json:"gw"`
	*Sw `json:"sw"`
	*Ap `json:"ap,omitempty"`
}

UDMStat holds the "stat" data for a dream machine. A dream machine is a USG + USW + Controller.

type USG

type USG struct {
	SourceName    string   `json:"-"`
	ID            string   `json:"_id"`
	Adopted       FlexBool `json:"adopted"`
	Cfgversion    string   `json:"cfgversion"`
	ConfigNetwork struct {
		Type string `json:"type"`
		IP   string `json:"ip"`
	} `json:"config_network"`
	EthernetTable []struct {
		Mac     string  `json:"mac"`
		NumPort FlexInt `json:"num_port"`
		Name    string  `json:"name"`
	} `json:"ethernet_table"`
	FwCaps              FlexInt `json:"fw_caps"`
	InformIP            string  `json:"inform_ip"`
	InformURL           string  `json:"inform_url"`
	IP                  string  `json:"ip"`
	LedOverride         string  `json:"led_override"`
	LicenseState        string  `json:"license_state"`
	Mac                 string  `json:"mac"`
	Model               string  `json:"model"`
	Name                string  `json:"name"`
	OutdoorModeOverride string  `json:"outdoor_mode_override"`
	Serial              string  `json:"serial"`
	SiteID              string  `json:"site_id"`
	SiteName            string  `json:"-"`
	Type                string  `json:"type"`
	UsgCaps             FlexInt `json:"usg_caps"`
	Version             string  `json:"version"`
	RequiredVersion     string  `json:"required_version"`
	EthernetOverrides   []struct {
		Ifname       string `json:"ifname"`
		Networkgroup string `json:"networkgroup"`
	} `json:"ethernet_overrides"`
	HwCaps                FlexInt         `json:"hw_caps"`
	BoardRev              FlexInt         `json:"board_rev"`
	Unsupported           FlexBool        `json:"unsupported"`
	UnsupportedReason     FlexInt         `json:"unsupported_reason"`
	DeviceID              string          `json:"device_id"`
	State                 FlexInt         `json:"state"`
	LastSeen              FlexInt         `json:"last_seen"`
	Upgradable            FlexBool        `json:"upgradable"`
	AdoptableWhenUpgraded FlexBool        `json:"adoptable_when_upgraded"`
	Rollupgrade           FlexBool        `json:"rollupgrade"`
	KnownCfgversion       string          `json:"known_cfgversion"`
	Uptime                FlexInt         `json:"uptime"`
	Locating              FlexBool        `json:"locating"`
	ConnectRequestIP      string          `json:"connect_request_ip"`
	ConnectRequestPort    string          `json:"connect_request_port"`
	SysStats              SysStats        `json:"sys_stats"`
	SystemStats           SystemStats     `json:"system-stats"`
	GuestToken            string          `json:"guest_token"`
	SpeedtestStatus       SpeedtestStatus `json:"speedtest-status"`
	SpeedtestStatusSaved  FlexBool        `json:"speedtest-status-saved"`
	Wan1                  Wan             `json:"wan1"`
	Wan2                  Wan             `json:"wan2"`
	PortTable             []struct {
		Name        string   `json:"name"`
		Ifname      string   `json:"ifname"`
		IP          string   `json:"ip"`
		Netmask     string   `json:"netmask"`
		Mac         string   `json:"mac"`
		Up          FlexBool `json:"up"`
		Speed       FlexInt  `json:"speed"`
		FullDuplex  FlexBool `json:"full_duplex"`
		RxBytes     FlexInt  `json:"rx_bytes"`
		RxDropped   FlexInt  `json:"rx_dropped"`
		RxErrors    FlexInt  `json:"rx_errors"`
		RxPackets   FlexInt  `json:"rx_packets"`
		TxBytes     FlexInt  `json:"tx_bytes"`
		TxDropped   FlexInt  `json:"tx_dropped"`
		TxErrors    FlexInt  `json:"tx_errors"`
		TxPackets   FlexInt  `json:"tx_packets"`
		RxMulticast FlexInt  `json:"rx_multicast"`
		Enable      FlexBool `json:"enable"`
		DNS         []string `json:"dns,omitempty"`
		Gateway     string   `json:"gateway,omitempty"`
	} `json:"port_table"`
	NetworkTable NetworkTable `json:"network_table"`
	Uplink       Uplink       `json:"uplink"`
	Stat         USGStat      `json:"stat"`
	TxBytes      FlexInt      `json:"tx_bytes"`
	RxBytes      FlexInt      `json:"rx_bytes"`
	Bytes        FlexInt      `json:"bytes"`
	NumSta       FlexInt      `json:"num_sta"`
	UserNumSta   FlexInt      `json:"user-num_sta"`
	GuestNumSta  FlexInt      `json:"guest-num_sta"`
	NumDesktop   FlexInt      `json:"num_desktop"`
	NumMobile    FlexInt      `json:"num_mobile"`
	NumHandheld  FlexInt      `json:"num_handheld"`
}

USG represents all the data from the Ubiquiti Controller for a Unifi Security Gateway.

type USGStat

type USGStat struct {
	*Gw
}

USGStat holds the "stat" data for a gateway. This is split out because of a JSON data format change from 5.10 to 5.11.

func (*USGStat) UnmarshalJSON

func (v *USGStat) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshalls 5.10 or 5.11 formatted Gateway Stat data.

type USW

type USW struct {
	SourceName    string   `json:"-"`
	SiteName      string   `json:"-"`
	ID            string   `json:"_id"`
	Adopted       FlexBool `json:"adopted"`
	BoardRev      FlexInt  `json:"board_rev"`
	Cfgversion    string   `json:"cfgversion"`
	ConfigNetwork struct {
		Type string `json:"type"`
		IP   string `json:"ip"`
	} `json:"config_network"`
	Dot1XPortctrlEnabled FlexBool `json:"dot1x_portctrl_enabled"`
	EthernetTable        []struct {
		Mac     string  `json:"mac"`
		NumPort FlexInt `json:"num_port,omitempty"`
		Name    string  `json:"name"`
	} `json:"ethernet_table"`
	FlowctrlEnabled     FlexBool `json:"flowctrl_enabled"`
	FwCaps              FlexInt  `json:"fw_caps"`
	HasFan              FlexBool `json:"has_fan"`
	HasTemperature      FlexBool `json:"has_temperature"`
	InformIP            string   `json:"inform_ip"`
	InformURL           string   `json:"inform_url"`
	IP                  string   `json:"ip"`
	JumboframeEnabled   FlexBool `json:"jumboframe_enabled"`
	LedOverride         string   `json:"led_override"`
	LicenseState        string   `json:"license_state"`
	Mac                 string   `json:"mac"`
	Model               string   `json:"model"`
	Name                string   `json:"name"`
	OutdoorModeOverride string   `json:"outdoor_mode_override"`
	PortOverrides       []struct {
		Name       string  `json:"name,omitempty"`
		PoeMode    string  `json:"poe_mode,omitempty"`
		PortIdx    FlexInt `json:"port_idx"`
		PortconfID string  `json:"portconf_id"`
	} `json:"port_overrides"`
	PortTable       []Port  `json:"port_table"`
	Serial          string  `json:"serial"`
	SiteID          string  `json:"site_id"`
	StpPriority     FlexInt `json:"stp_priority"`
	StpVersion      string  `json:"stp_version"`
	Type            string  `json:"type"`
	Version         string  `json:"version"`
	RequiredVersion string  `json:"required_version"`
	SwitchCaps      struct {
		FeatureCaps          FlexInt `json:"feature_caps"`
		MaxMirrorSessions    FlexInt `json:"max_mirror_sessions"`
		MaxAggregateSessions FlexInt `json:"max_aggregate_sessions"`
	} `json:"switch_caps"`
	HwCaps                FlexInt     `json:"hw_caps"`
	Unsupported           FlexBool    `json:"unsupported"`
	UnsupportedReason     FlexInt     `json:"unsupported_reason"`
	SysErrorCaps          FlexInt     `json:"sys_error_caps"`
	DeviceID              string      `json:"device_id"`
	State                 FlexInt     `json:"state"`
	LastSeen              FlexInt     `json:"last_seen"`
	Upgradable            FlexBool    `json:"upgradable,omitempty"`
	AdoptableWhenUpgraded FlexBool    `json:"adoptable_when_upgraded,omitempty"`
	Rollupgrade           FlexBool    `json:"rollupgrade,omitempty"`
	KnownCfgversion       string      `json:"known_cfgversion"`
	Uptime                FlexInt     `json:"uptime"`
	Locating              FlexBool    `json:"locating"`
	ConnectRequestIP      string      `json:"connect_request_ip"`
	ConnectRequestPort    string      `json:"connect_request_port"`
	SysStats              SysStats    `json:"sys_stats"`
	SystemStats           SystemStats `json:"system-stats"`
	FanLevel              FlexInt     `json:"fan_level"`
	GeneralTemperature    FlexInt     `json:"general_temperature"`
	Overheating           FlexBool    `json:"overheating"`
	TotalMaxPower         FlexInt     `json:"total_max_power"`
	DownlinkTable         []struct {
		PortIdx    FlexInt  `json:"port_idx"`
		Speed      FlexInt  `json:"speed"`
		FullDuplex FlexBool `json:"full_duplex"`
		Mac        string   `json:"mac"`
	} `json:"downlink_table"`
	Uplink     Uplink `json:"uplink"`
	LastUplink struct {
		UplinkMac string `json:"uplink_mac"`
	} `json:"last_uplink"`
	UplinkDepth FlexInt `json:"uplink_depth"`
	Stat        USWStat `json:"stat"`
	TxBytes     FlexInt `json:"tx_bytes"`
	RxBytes     FlexInt `json:"rx_bytes"`
	Bytes       FlexInt `json:"bytes"`
	NumSta      FlexInt `json:"num_sta"`
	UserNumSta  FlexInt `json:"user-num_sta"`
	GuestNumSta FlexInt `json:"guest-num_sta"`
}

USW represents all the data from the Ubiquiti Controller for a Unifi Switch.

type USWStat

type USWStat struct {
	*Sw
}

USWStat holds the "stat" data for a switch. This is split out because of a JSON data format change from 5.10 to 5.11.

func (*USWStat) UnmarshalJSON

func (v *USWStat) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshalls 5.10 or 5.11 formatted Switch Stat data.

type Unifi

type Unifi struct {
	*http.Client
	*Config
	// contains filtered or unexported fields
}

Unifi is what you get in return for providing a password! Unifi represents a controller that you can make authenticated requests to. Use this to make additional requests for devices, clients or other custom data. Do not set the loggers to nil. Set them to DiscardLogs if you want no logs.

func NewUnifi

func NewUnifi(config *Config) (*Unifi, error)

NewUnifi creates a http.Client with authenticated cookies. Used to make additional, authenticated requests to the APIs. Start here.

func (*Unifi) GetAlarms

func (u *Unifi) GetAlarms(sites []*Site) ([]*Alarm, error)

GetAlarms returns Alarms for a list of Sites.

func (*Unifi) GetAlarmsSite

func (u *Unifi) GetAlarmsSite(site *Site) ([]*Alarm, error)

GetAlarmsSite retreives the Alarms for a single Site.

func (*Unifi) GetAnomalies

func (u *Unifi) GetAnomalies(sites []*Site, timeRange ...time.Time) ([]*Anomaly, error)

GetAnomalies returns Anomalies for a list of Sites.

func (*Unifi) GetAnomaliesSite

func (u *Unifi) GetAnomaliesSite(site *Site, timeRange ...time.Time) ([]*Anomaly, error)

GetAnomaliesSite retreives the Anomalies for a single Site.

func (*Unifi) GetClients

func (u *Unifi) GetClients(sites []*Site) ([]*Client, error)

GetClients returns a response full of clients' data from the UniFi Controller.

func (*Unifi) GetClientsDPI

func (u *Unifi) GetClientsDPI(sites []*Site) ([]*DPITable, error)

GetClientsDPI garners dpi data for clients.

func (*Unifi) GetData

func (u *Unifi) GetData(apiPath string, v interface{}, params ...string) error

GetData makes a unifi request and unmarshals the response into a provided pointer.

func (*Unifi) GetDevices

func (u *Unifi) GetDevices(sites []*Site) (*Devices, error)

GetDevices returns a response full of devices' data from the UniFi Controller.

func (*Unifi) GetEvents

func (u *Unifi) GetEvents(sites []*Site, hours time.Duration) ([]*Event, error)

GetEvents returns a response full of UniFi Events for the last 1 hour from multiple sites.

func (*Unifi) GetIDS

func (u *Unifi) GetIDS(sites []*Site, timeRange ...time.Time) ([]*IDS, error)

GetIDS returns Intrusion Detection Systems events for a list of Sites. timeRange may have a length of 0, 1 or 2. The first time is Start, the second is End. Events between start and end are returned. End defaults to time.Now().

func (*Unifi) GetIDSSite

func (u *Unifi) GetIDSSite(site *Site, timeRange ...time.Time) ([]*IDS, error)

GetIDSSite retreives the Intrusion Detection System Data for a single Site. timeRange may have a length of 0, 1 or 2. The first time is Start, the second is End. Events between start and end are returned. End defaults to time.Now().

func (*Unifi) GetJSON

func (u *Unifi) GetJSON(apiPath string, params ...string) ([]byte, error)

GetJSON returns the raw JSON from a path. This is useful for debugging.

func (*Unifi) GetNetworks

func (u *Unifi) GetNetworks(sites []*Site) ([]Network, error)

GetNetworks returns a response full of network data from the UniFi Controller.

func (*Unifi) GetServerData

func (u *Unifi) GetServerData() error

GetServerData sets the controller's version and UUID. Only call this if you previously called Login and suspect the controller version has changed.

func (*Unifi) GetSiteDPI

func (u *Unifi) GetSiteDPI(sites []*Site) ([]*DPITable, error)

GetSiteDPI garners dpi data for sites.

func (*Unifi) GetSiteEvents

func (u *Unifi) GetSiteEvents(site *Site, hours time.Duration) ([]*Event, error)

GetSiteEvents retrieves the last 1 hour's worth of events from a single site.

func (*Unifi) GetSites

func (u *Unifi) GetSites() ([]*Site, error)

GetSites returns a list of configured sites on the UniFi controller.

func (*Unifi) Login

func (u *Unifi) Login() error

Login is a helper method. It can be called to grab a new authentication cookie.

func (*Unifi) UniReq

func (u *Unifi) UniReq(apiPath string, params string) (req *http.Request, err error)

UniReq is a small helper function that adds an Accept header. Use this if you're unmarshalling UniFi data into custom types. And if you're doing that... sumbut a pull request with your new struct. :) This is a helper method that is exposed for convenience.

type Uplink struct {
	BytesR           FlexInt  `json:"bytes-r"`
	Drops            FlexInt  `json:"drops"`
	Enable           FlexBool `json:"enable,omitempty"`
	FullDuplex       FlexBool `json:"full_duplex"`
	Gateways         []string `json:"gateways,omitempty"`
	IP               string   `json:"ip"`
	Latency          FlexInt  `json:"latency"`
	Mac              string   `json:"mac,omitempty"`
	MaxSpeed         FlexInt  `json:"max_speed"`
	Name             string   `json:"name"`
	Nameservers      []string `json:"nameservers"`
	Netmask          string   `json:"netmask"`
	NumPort          FlexInt  `json:"num_port"`
	RxBytes          FlexInt  `json:"rx_bytes"`
	RxBytesR         FlexInt  `json:"rx_bytes-r"`
	RxDropped        FlexInt  `json:"rx_dropped"`
	RxErrors         FlexInt  `json:"rx_errors"`
	RxMulticast      FlexInt  `json:"rx_multicast"`
	RxPackets        FlexInt  `json:"rx_packets"`
	Speed            FlexInt  `json:"speed"`
	SpeedtestLastrun FlexInt  `json:"speedtest_lastrun,omitempty"`
	SpeedtestPing    FlexInt  `json:"speedtest_ping,omitempty"`
	SpeedtestStatus  string   `json:"speedtest_status,omitempty"`
	TxBytes          FlexInt  `json:"tx_bytes"`
	TxBytesR         FlexInt  `json:"tx_bytes-r"`
	TxDropped        FlexInt  `json:"tx_dropped"`
	TxErrors         FlexInt  `json:"tx_errors"`
	TxPackets        FlexInt  `json:"tx_packets"`
	Type             string   `json:"type"`
	Up               FlexBool `json:"up"`
	Uptime           FlexInt  `json:"uptime"`
	XputDown         FlexInt  `json:"xput_down,omitempty"`
	XputUp           FlexInt  `json:"xput_up,omitempty"`
}

Uplink is the Internet connection (or uplink) on a UniFi device.

type VapTable

type VapTable []struct {
	AnomaliesBarChart struct {
		HighDNSLatency    FlexInt `json:"high_dns_latency"`
		HighTCPLatency    FlexInt `json:"high_tcp_latency"`
		HighTCPPacketLoss FlexInt `json:"high_tcp_packet_loss"`
		HighWifiLatency   FlexInt `json:"high_wifi_latency"`
		HighWifiRetries   FlexInt `json:"high_wifi_retries"`
		LowPhyRate        FlexInt `json:"low_phy_rate"`
		PoorStreamEff     FlexInt `json:"poor_stream_eff"`
		SleepyClient      FlexInt `json:"sleepy_client"`
		StaArpTimeout     FlexInt `json:"sta_arp_timeout"`
		StaDNSTimeout     FlexInt `json:"sta_dns_timeout"`
		StaIPTimeout      FlexInt `json:"sta_ip_timeout"`
		WeakSignal        FlexInt `json:"weak_signal"`
	} `json:"anomalies_bar_chart"`
	AnomaliesBarChartNow struct {
		HighDNSLatency    FlexInt `json:"high_dns_latency"`
		HighTCPLatency    FlexInt `json:"high_tcp_latency"`
		HighTCPPacketLoss FlexInt `json:"high_tcp_packet_loss"`
		HighWifiLatency   FlexInt `json:"high_wifi_latency"`
		HighWifiRetries   FlexInt `json:"high_wifi_retries"`
		LowPhyRate        FlexInt `json:"low_phy_rate"`
		PoorStreamEff     FlexInt `json:"poor_stream_eff"`
		SleepyClient      FlexInt `json:"sleepy_client"`
		StaArpTimeout     FlexInt `json:"sta_arp_timeout"`
		StaDNSTimeout     FlexInt `json:"sta_dns_timeout"`
		StaIPTimeout      FlexInt `json:"sta_ip_timeout"`
		WeakSignal        FlexInt `json:"weak_signal"`
	} `json:"anomalies_bar_chart_now"`
	ReasonsBarChart struct {
		PhyRate       FlexInt `json:"phy_rate"`
		Signal        FlexInt `json:"signal"`
		SleepyClient  FlexInt `json:"sleepy_client"`
		StaArpTimeout FlexInt `json:"sta_arp_timeout"`
		StaDNSLatency FlexInt `json:"sta_dns_latency"`
		StaDNSTimeout FlexInt `json:"sta_dns_timeout"`
		StaIPTimeout  FlexInt `json:"sta_ip_timeout"`
		StreamEff     FlexInt `json:"stream_eff"`
		TCPLatency    FlexInt `json:"tcp_latency"`
		TCPPacketLoss FlexInt `json:"tcp_packet_loss"`
		WifiLatency   FlexInt `json:"wifi_latency"`
		WifiRetries   FlexInt `json:"wifi_retries"`
	} `json:"reasons_bar_chart"`
	ReasonsBarChartNow struct {
		PhyRate       FlexInt `json:"phy_rate"`
		Signal        FlexInt `json:"signal"`
		SleepyClient  FlexInt `json:"sleepy_client"`
		StaArpTimeout FlexInt `json:"sta_arp_timeout"`
		StaDNSLatency FlexInt `json:"sta_dns_latency"`
		StaDNSTimeout FlexInt `json:"sta_dns_timeout"`
		StaIPTimeout  FlexInt `json:"sta_ip_timeout"`
		StreamEff     FlexInt `json:"stream_eff"`
		TCPLatency    FlexInt `json:"tcp_latency"`
		TCPPacketLoss FlexInt `json:"tcp_packet_loss"`
		WifiLatency   FlexInt `json:"wifi_latency"`
		WifiRetries   FlexInt `json:"wifi_retries"`
	} `json:"reasons_bar_chart_now"`
	RxTCPStats struct {
		Goodbytes FlexInt `json:"goodbytes"`
		LatAvg    FlexInt `json:"lat_avg"`
		LatMax    FlexInt `json:"lat_max"`
		LatMin    FlexInt `json:"lat_min"`
		Stalls    FlexInt `json:"stalls"`
	} `json:"rx_tcp_stats"`
	TxTCPStats struct {
		Goodbytes FlexInt `json:"goodbytes"`
		LatAvg    FlexInt `json:"lat_avg"`
		LatMax    FlexInt `json:"lat_max"`
		LatMin    FlexInt `json:"lat_min"`
		Stalls    FlexInt `json:"stalls"`
	} `json:"tx_tcp_stats"`
	WifiTxLatencyMov struct {
		Avg        FlexInt `json:"avg"`
		Max        FlexInt `json:"max"`
		Min        FlexInt `json:"min"`
		Total      FlexInt `json:"total"`
		TotalCount FlexInt `json:"total_count"`
	} `json:"wifi_tx_latency_mov"`
	ApMac               string      `json:"ap_mac"`
	AvgClientSignal     FlexInt     `json:"avg_client_signal"`
	Bssid               string      `json:"bssid"`
	Ccq                 int         `json:"ccq"`
	Channel             FlexInt     `json:"channel"`
	DNSAvgLatency       FlexInt     `json:"dns_avg_latency"`
	Essid               string      `json:"essid"`
	Extchannel          int         `json:"extchannel"`
	ID                  string      `json:"id"`
	IsGuest             FlexBool    `json:"is_guest"`
	IsWep               FlexBool    `json:"is_wep"`
	MacFilterRejections int         `json:"mac_filter_rejections"`
	MapID               interface{} `json:"map_id"`
	Name                string      `json:"name"`
	NumSatisfactionSta  FlexInt     `json:"num_satisfaction_sta"`
	NumSta              int         `json:"num_sta"`
	Radio               string      `json:"radio"`
	RadioName           string      `json:"radio_name"`
	RxBytes             FlexInt     `json:"rx_bytes"`
	RxCrypts            FlexInt     `json:"rx_crypts"`
	RxDropped           FlexInt     `json:"rx_dropped"`
	RxErrors            FlexInt     `json:"rx_errors"`
	RxFrags             FlexInt     `json:"rx_frags"`
	RxNwids             FlexInt     `json:"rx_nwids"`
	RxPackets           FlexInt     `json:"rx_packets"`
	Satisfaction        FlexInt     `json:"satisfaction"`
	SatisfactionNow     FlexInt     `json:"satisfaction_now"`
	SiteID              string      `json:"site_id"`
	State               string      `json:"state"`
	T                   string      `json:"t"`
	TxBytes             FlexInt     `json:"tx_bytes"`
	TxCombinedRetries   FlexInt     `json:"tx_combined_retries"`
	TxDataMpduBytes     FlexInt     `json:"tx_data_mpdu_bytes"`
	TxDropped           FlexInt     `json:"tx_dropped"`
	TxErrors            FlexInt     `json:"tx_errors"`
	TxPackets           FlexInt     `json:"tx_packets"`
	TxPower             FlexInt     `json:"tx_power"`
	TxRetries           FlexInt     `json:"tx_retries"`
	TxRtsRetries        FlexInt     `json:"tx_rts_retries"`
	TxSuccess           FlexInt     `json:"tx_success"`
	TxTotal             FlexInt     `json:"tx_total"`
	Up                  FlexBool    `json:"up"`
	Usage               string      `json:"usage"`
	WifiTxAttempts      FlexInt     `json:"wifi_tx_attempts"`
	WifiTxDropped       FlexInt     `json:"wifi_tx_dropped"`
	WlanconfID          string      `json:"wlanconf_id"`
}

VapTable holds much of the UAP wireless data. Shared by UDM.

type Wan

type Wan struct {
	Autoneg     FlexBool `json:"autoneg"`
	BytesR      FlexInt  `json:"bytes-r"`
	DNS         []string `json:"dns"`
	Enable      FlexBool `json:"enable"`
	FlowctrlRx  FlexBool `json:"flowctrl_rx"`
	FlowctrlTx  FlexBool `json:"flowctrl_tx"`
	FullDuplex  FlexBool `json:"full_duplex"`
	Gateway     string   `json:"gateway"` // may be deprecated
	IP          string   `json:"ip"`
	Ifname      string   `json:"ifname"`
	IsUplink    FlexBool `json:"is_uplink"`
	Mac         string   `json:"mac"`
	MaxSpeed    FlexInt  `json:"max_speed"`
	Media       string   `json:"media"`
	Name        string   `json:"name"`
	Netmask     string   `json:"netmask"` // may be deprecated
	NumPort     int      `json:"num_port"`
	PortIdx     int      `json:"port_idx"`
	PortPoe     FlexBool `json:"port_poe"`
	RxBroadcast FlexInt  `json:"rx_broadcast"`
	RxBytes     FlexInt  `json:"rx_bytes"`
	RxBytesR    FlexInt  `json:"rx_bytes-r"`
	RxDropped   FlexInt  `json:"rx_dropped"`
	RxErrors    FlexInt  `json:"rx_errors"`
	RxMulticast FlexInt  `json:"rx_multicast"`
	RxPackets   FlexInt  `json:"rx_packets"`
	Speed       FlexInt  `json:"speed"`
	TxBroadcast FlexInt  `json:"tx_broadcast"`
	TxBytes     FlexInt  `json:"tx_bytes"`
	TxBytesR    FlexInt  `json:"tx_bytes-r"`
	TxDropped   FlexInt  `json:"tx_dropped"`
	TxErrors    FlexInt  `json:"tx_errors"`
	TxMulticast FlexInt  `json:"tx_multicast"`
	TxPackets   FlexInt  `json:"tx_packets"`
	Type        string   `json:"type"`
	Up          FlexBool `json:"up"`
}

Wan is a Wan interface on a USG or UDM.

Jump to

Keyboard shortcuts

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