unifi

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

Forked from https://github.com/dsymonds/unifi

Added flag to not perform the file permission check on config file

Installation

To get it,

go get github.com/jorie1234/unifi

Documentation

Overview

Package unifi provides programmatic access to UniFi hardware.

Index

Constants

This section is empty.

Variables

View Source
var DefaultAuthFile = filepath.Join(os.Getenv("HOME"), ".unifi-auth")

DefaultAuthFile is a default place to store authentication information. Pass this to FileAuthStore if an alternate path isn't required.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API is an interface to a UniFi controller.

func NewAPI

func NewAPI(as AuthStore) (*API, error)

NewAPI constructs a new API.

func (*API) EnableWirelessNetwork

func (api *API) EnableWirelessNetwork(site, id string, enable bool) error

func (*API) ListClients

func (api *API) ListClients(site string) ([]Client, error)

func (*API) ListWirelessNetworks

func (api *API) ListWirelessNetworks(site string) ([]WirelessNetwork, error)

func (*API) WriteConfig

func (api *API) WriteConfig() error

WriteConfig writes the configuration to the configured AuthStore.

type Auth

type Auth struct {
	Username, Password string
	ControllerHost     string
	Cookies            []*http.Cookie
}

Auth holds the authentication information for accessing a UniFi controller.

type AuthStore

type AuthStore interface {
	Load() (*Auth, error)
	Save(*Auth) error
}

An AuthStore is an interface for loading and saving authentication information. See FileAuthStore for a file-based implementation.

func FileAuthStore

func FileAuthStore(filename string, checkPerm bool) AuthStore

FileAuthStore returns an AuthStore that stores authentication information in a named file.

type Client

type Client struct {
	ID       string `json:"_id"`
	Name     string `json:"name"`
	Hostname string `json:"hostname"`
	Wired    bool   `json:"is_wired"`

	MAC string `json:"mac"`
	IP  string `json:"ip"`

	LastSeen time.Time

	SiteID           string `json:"site_id"`
	AssocTime        int    `json:"assoc_time"`
	LatestAssocTime  int    `json:"latest_assoc_time"`
	Oui              string `json:"oui"`
	UserID           string `json:"user_id"`
	Mac              string `json:"mac"`
	IsGuest          bool   `json:"is_guest"`
	FirstSeen        int    `json:"first_seen"`
	IsWired          bool   `json:"is_wired"`
	UptimeByUap      int    `json:"_uptime_by_uap"`
	LastSeenByUap    int    `json:"_last_seen_by_uap"`
	IsGuestByUap     bool   `json:"_is_guest_by_uap"`
	ApMac            string `json:"ap_mac"`
	Channel          int    `json:"channel"`
	Radio            string `json:"radio"`
	RadioName        string `json:"radio_name"`
	Essid            string `json:"essid"`
	Bssid            string `json:"bssid"`
	PowersaveEnabled bool   `json:"powersave_enabled"`
	Is11R            bool   `json:"is_11r"`
	Ccq              int    `json:"ccq"`
	Rssi             int    `json:"rssi"`
	Noise            int    `json:"noise"`
	Signal           int    `json:"signal"`
	TxRate           int    `json:"tx_rate"`
	RxRate           int    `json:"rx_rate"`
	TxPower          int    `json:"tx_power"`
	Idletime         int    `json:"idletime"`
	DhcpendTime      int    `json:"dhcpend_time"`
	Satisfaction     int    `json:"satisfaction"`
	Anomalies        int    `json:"anomalies"`
	Vlan             int    `json:"vlan"`
	RadioProto       string `json:"radio_proto"`
	Uptime           int    `json:"uptime"`
	TxBytes          int64  `json:"tx_bytes"`
	RxBytes          int    `json:"rx_bytes"`
	TxPackets        int    `json:"tx_packets"`
	TxRetries        int    `json:"tx_retries"`
	WifiTxAttempts   int    `json:"wifi_tx_attempts"`
	RxPackets        int    `json:"rx_packets"`
	BytesR           int    `json:"bytes-r"`
	TxBytesR         int    `json:"tx_bytes-r"`
	RxBytesR         int    `json:"rx_bytes-r"`
	Authorized       bool   `json:"authorized"`
	QosPolicyApplied bool   `json:"qos_policy_applied"`
}

func (*Client) UnmarshalJSON

func (c *Client) UnmarshalJSON(data []byte) error

type WirelessNetwork

type WirelessNetwork struct {
	ID      string `json:"_id"`
	Name    string `json:"name"`
	Enabled bool   `json:"enabled"`

	Security string `json:"security"`
	WPAMode  string `json:"wpa_mode"`

	Guest bool `json:"is_guest,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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