deco

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: GPL-3.0 Imports: 11 Imported by: 1

README

This Go package provides a basic API wrapper for the tp-link M4 mesh router

Available methods

  • Performance: Get CPU and Memory usage
  • ClientList: Get connected clients
  • Custom: Make a custom request to the router
  • DeviceList: Get connected Decos
  • Wan: Get information about wan

TODO: look through the firmware for more endpoints

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for sending requests to the Deco-m4 API

func New

func New(target string) *Client

New creates a new Go client for the Deco-m4 API

func (*Client) Authenticate

func (c *Client) Authenticate(password string) error

Authenticate will generate the keys needed for the communication with the router.

func (*Client) ClientList

func (c *Client) ClientList() (*ClientListResp, error)

ClientList returns the list of connected devices

func (*Client) Custom

func (c *Client) Custom(path string, params EndpointArgs, body []byte) (interface{}, error)

Custom lets you make a custom request

func (*Client) Performance

func (c *Client) Performance() (*PerfResp, error)

Performance returns the current cpu and mem usage.

type ClientListResp

type ClientListResp struct {
	ErrorCode int `json:"error_code"`
	Result    struct {
		ClientList []struct {
			AccessHost     string `json:"access_host"`
			ClientMesh     bool   `json:"client_mesh"`
			ClientType     string `json:"client_type"`
			ConnectionType string `json:"band5"`
			DownSpeed      uint   `json:"down_speed"`
			EnablePriority bool   `json:"enable_priority"`
			Interface      string `json:"interface"`
			IP             string `json:"ip"`
			MAC            string `json:"mac"`
			Name           string `json:"name"`
			Online         bool   `json:"online"`
			OwnerID        string `json:"owner_id"`
			RemainTime     uint   `json:"remain_time"`
			SpaceID        string `json:"space_id"`
			UpSpeed        uint   `json:"up_speed"`
			WireType       string `json:"wire_type"`
		} `json:"client_list"`
	} `json:"result"`
}

ClientListResp is the structure of the client_list endpoint

type EndpointArgs

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

EndpointArgs holds the url params to be sent

type PerfResp

type PerfResp struct {
	ErrorCode int `json:"error_code"`
	Result    struct {
		CPU float32 `json:"cpu_usage"`
		MEM float32 `json:"mem_usage"`
	} `json:"result"`
}

PerfResp is the structure of the performance endpoint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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