package module
v1.0.1 Latest Latest

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 8 Imported by: 0


GOlang client library to operate over TPLink Easy Smart Switches that provides a website for management. The library basically uses HTTP calls to the site for login, logout, return information, create backups...


// create a client for your switch
client := tlsg10x.New(<host>, <user>, <pass>, nil)
// Retrieve port statistics
err := client.PortsStats()

Tested on

TL-SG108E 4.0
TL-SG108E 6.0

Supported Operations

  • Login
  • Logout
  • Get Ports Settings
  • Get Ports Statistics
  • Create a backup to a local file




This section is empty.


This section is empty.


This section is empty.


type Api

type Api interface {
	PortsStats() ([]PortStats, error)
	PortsSettings() ([]PortSettings, error)
	CreateBackup() ([]byte, error)

Defines the api operations

type Client

type Client struct {
	Host     string
	Username string
	Password string
	// contains filtered or unexported fields

func New

func New(h, u, p string, httpClient *http.Client) *Client

new tlsg108e client

func (*Client) CreateBackup

func (t *Client) CreateBackup() ([]byte, error)

creates a backup of the connected device

func (*Client) Login

func (t *Client) Login() error

do a login into switch webpage it calls to http://<host>/logon.cgi

func (*Client) Logout

func (t *Client) Logout() error

Logouts from site

func (*Client) PortsSettings

func (t *Client) PortsSettings() ([]PortSettings, error)

get port settings and info

func (*Client) PortsStats

func (t *Client) PortsStats() ([]PortStats, error)

get ports statistics

func (*Client) SystemInfo

func (t *Client) SystemInfo() (*SystemInfo, error)

retrieve switch system information

type LinkStatus

type LinkStatus int64
const (
	LinkDown LinkStatus = 0
	Auto     LinkStatus = 1
	At10MH   LinkStatus = 2
	At10MF   LinkStatus = 3
	At100MH  LinkStatus = 4
	At100MF  LinkStatus = 5
	At1000MF LinkStatus = 6

func (LinkStatus) String

func (s LinkStatus) String() string

type OnOff

type OnOff int64
const (
	Off OnOff = 0
	On  OnOff = 1

func (OnOff) String

func (s OnOff) String() string

type PortSettings

type PortSettings struct {
	Name        string
	State       PortStatus
	TrunkInfo   int
	SpeedCfg    LinkStatus
	SpeedAct    LinkStatus
	FlowCtrlCfg OnOff
	FlowCtrlAct OnOff

Ports Settings

type PortStats

type PortStats struct {
	Name       string
	State      PortStatus
	LinkStatus LinkStatus
	TxGoodPkt  int
	TxBadPkt   int
	RxGoodPkt  int
	RxBadPkt   int

type PortStatus

type PortStatus int64
const (
	PortDisabled PortStatus = 0
	PortEnabled  PortStatus = 1

func (PortStatus) String

func (s PortStatus) String() string

type SystemInfo

type SystemInfo struct {
	Name       string
	MacAddress string
	IPAddress  string
	NetMask    string
	Gateway    string
	Firmware   string
	Hardware   string

System information


Path Synopsis

Jump to

Keyboard shortcuts

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