huaweihg659

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

go-huawei-hg659

Go client to interact with a Huawei HG659 router

Usage

go get -u github.com/axatol/go-huawei-hg659

Example

package main

import huaweihg659 "github.com/axatol/go-huawei-hg659"

func main() {
  ctx := context.Background()
  client := huaweihg659.NewClient("http://192.168.1.1")

  if err := client.Login("username", "password"); err != nil {
    panic(err)
  }

  devices, err := client.ListKnownLANDevices(ctx)
  if err != nil {
    panic(err)
  }

  fmt.Printf("%#v\n", devices)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodePassword

func EncodePassword(username, password, csrfParam, csrfToken string) string

Types

type Client

type Client struct {
	Address *url.URL
	// contains filtered or unexported fields
}

func NewClient

func NewClient(address string, options ...ClientOption) (*Client, error)

func (*Client) GetBroadcastedWifiNetworks

func (c *Client) GetBroadcastedWifiNetworks(ctx context.Context) ([]WifiNetwork, error)

func (*Client) GetConnectedDeviceCount

func (c *Client) GetConnectedDeviceCount(ctx context.Context) (*DeviceCount, error)

func (*Client) GetDeviceInfo

func (c *Client) GetDeviceInfo(ctx context.Context) (*DeviceInfo, error)

func (*Client) GetInternetDiagnosis

func (c *Client) GetInternetDiagnosis(ctx context.Context) (*InternetDiagnosis, error)

func (*Client) GetLANStatistics

func (c *Client) GetLANStatistics(ctx context.Context) ([]LANStatistics, error)

func (*Client) GetUMTSStatistics

func (c *Client) GetUMTSStatistics(ctx context.Context) (*UMTSStatistics, error)

func (*Client) GetWifiStatistics

func (c *Client) GetWifiStatistics(ctx context.Context) ([]WifiStatistics, error)

func (*Client) ListDHCPReservation

func (c *Client) ListDHCPReservation(ctx context.Context) ([]DHCPReservation, error)

func (*Client) ListKnownLANDevices

func (c *Client) ListKnownLANDevices(ctx context.Context) ([]LANDevice, error)

func (*Client) Login

func (c *Client) Login(ctx context.Context, username, password string) error

func (*Client) SessionID

func (c *Client) SessionID() string

type ClientOption added in v0.0.3

type ClientOption func(*Client)

func WithHTTPRoundTriper added in v0.0.4

func WithHTTPRoundTriper(rt http.RoundTripper) ClientOption

type DHCPReservation

type DHCPReservation struct {
	Addr       string `json:"Yiaddr"`     // e.g. "192.168.1.41"
	ID         string `json:"ID"`         // e.g. "InternetGatewayDevice.LANDevice.1.LANHostConfigManagement.DHCPStaticAddress.5."
	ActualName string `json:"ActualName"` // e.g. "bar_Ethernet"
	Chaddr     string `json:"Chaddr"`     // e.g. "AA:BB:CC:DD:EE:FF"
	Enable     bool   `json:"Enable"`     // e.g. true
}

type DeviceCount

type DeviceCount struct {
	ActiveDeviceNumbers int64 `json:"ActiveDeviceNumbers"` // e.g. 15
	DatacardNumber      int64 `json:"DatacardNumber"`      // e.g. 0
	LANActiveNumber     int64 `json:"LanActiveNumber"`     // e.g. 5
	PhoneNumber         int64 `json:"PhoneNumber"`         // e.g. 2
	PrinterNumbers      int64 `json:"PrinterNumbers"`      // e.g. 0
	USBNumbers          int64 `json:"UsbNumbers"`          // e.g. 0
	UserNumber          int64 `json:"UserNumber"`          // e.g. 2
}

type DeviceInfo

type DeviceInfo struct {
	DeviceName      string `json:"DeviceName"`      // e.g. "HG659"
	SerialNumber    string `json:"SerialNumber"`    // e.g. "J3N8W10123456789"
	ManufacturerOUI string `json:"ManufacturerOUI"` // e.g. "00E0FC"
	UpTime          int64  `json:"UpTime"`          // e.g. 3697479
	SoftwareVersion string `json:"SoftwareVersion"` // e.g. "V100R00123456789"
	HardwareVersion string `json:"HardwareVersion"` // e.g. "VER.B"
}

type InternetDiagnosis

type InternetDiagnosis struct {
	ConnectionStatus     string `json:"ConnectionStatus"`       // e.g. "Connected"
	DNSServers           string `json:"DNSServers"`             // e.g. ""
	DefaultGateway       string `json:"DefaultGateway"`         // e.g. ""
	DownMaxBitRate       string `json:"DownMaxBitRate"`         // e.g. "1000"
	DuplexMode           string `json:"DuplexMode"`             // e.g. "Full"
	ErrReason            string `json:"ErrReason"`              // e.g. "Success"
	ExternalIPAddress    string `json:"ExternalIPAddress"`      // e.g. ""
	HasInternetWan       bool   `json:"HasInternetWan"`         // e.g. true
	LinkStatus           string `json:"LinkStatus"`             // e.g. "Up"
	MACAddress           string `json:"MACAddress"`             // e.g. ""
	MaxBitRate           string `json:"MaxBitRate"`             // e.g. "1000"
	Status               string `json:"Status"`                 // e.g. "Connected"
	StatusCode           string `json:"StatusCode"`             // e.g. "Connected"
	UpMaxBitRate         string `json:"UpMaxBitRate"`           // e.g. "1000"
	Uptime               int64  `json:"Uptime"`                 // e.g. 350840
	WANAccessType        string `json:"WANAccessType"`          // e.g. "Ethernet"
	IPv4Enable           bool   `json:"X_IPv4Enable"`           // e.g. true
	IPv6Address          string `json:"X_IPv6Address"`          // e.g. ""
	IPv6AddressingType   string `json:"X_IPv6AddressingType"`   // e.g. "SLAAC"
	IPv6ConnectionStatus string `json:"X_IPv6ConnectionStatus"` // e.g. "Pending Disconnect"
	IPv6DNSServers       string `json:"X_IPv6DNSServers"`       // e.g. ""
	IPv6DefaultGateway   string `json:"X_IPv6DefaultGateway"`   // e.g. ""
	IPv6Enable           bool   `json:"X_IPv6Enable"`           // e.g. false
	IPv6PrefixLength     int64  `json:"X_IPv6PrefixLength"`     // e.g. 0
	IPv6PrefixList       string `json:"X_IPv6PrefixList"`       // e.g. ""
}

type LANDevice

type LANDevice struct {
	Active                bool   `json:"Active"`                // e.g. true
	QOSClassID            string `json:"QosclassID"`            // e.g. ""
	DeviceMaxDownloadRate int64  `json:"DeviceMaxDownLoadRate"` // e.g. 0
	HostName              string `json:"HostName"`              // e.g. "Foo_Wireless"
	Active46              bool   `json:"Active46"`              // e.g. true
	LeaseTime             int64  `json:"LeaseTime"`             // e.g. 14867
	ID                    string `json:"ID"`                    // e.g. "InternetGatewayDevice.LANDevice.1.Hosts.Host.1."
	IPv6Addrs             []any  `json:"Ipv6Addrs"`             // e.g. []
	ClassQueue            int64  `json:"ClassQueue"`            // e.g. -1
	Layer2Interface       string `json:"Layer2Interface"`       // e.g. "SSID1"
	ActualName            string `json:"ActualName"`            // e.g. ""
	IPAddress             string `json:"IPAddress"`             // e.g. "192.168.1.12"
	PolicerID             string `json:"PolicerID"`             // e.g. ""
	Domain                string `json:"domain"`                // e.g. "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1"
	DeviceDownRateEnable  bool   `json:"DeviceDownRateEnable"`  // e.g. false
	MACAddress            string `json:"MACAddress"`            // e.g. "AA:BB:CC:DD:EE:FF"
	ParentControlEnable   bool   `json:"ParentControlEnable"`   // e.g. false
	MACFilterID           string `json:"MacFilterID"`           // e.g. ""
	AddressSource         string `json:"AddressSource"`         // e.g. "DHCP"
	V6Active              bool   `json:"V6Active"`              // e.g. false
	IconType              string `json:"IconType"`              // e.g. ""
	IPv6Address           string `json:"IPv6Address"`           // e.g. ""
	VendorClassID         string `json:"VendorClassID"`         // e.g. "android-dhcp-13"
}

type LANStatistics

type LANStatistics struct {
	ReceiveBytes   int64  `json:"receivebytes"`   // e.g. 1115521851
	SendBytes      int64  `json:"sendbytes"`      // e.g. 532335628
	ReceivePacket  int64  `json:"receivepacket"`  // e.g. 7775540
	SendDiscard    int64  `json:"senddiscard"`    // e.g. 0
	SendError      int64  `json:"senderror"`      // e.g. 0
	ID             string `json:"ID"`             // e.g. "LAN1"
	ReceiveError   int64  `json:"receiveerror"`   // e.g. 0
	ReceiveDiscard int64  `json:"receivediscard"` // e.g. 0
	SendPacket     int64  `json:"sendpacket"`     // e.g. 30813230
}

type UMTSStatistics

type UMTSStatistics struct {
	BytesReceived   int64  `json:"BytesReceived"`   // e.g. 0
	UpstreamRate    string `json:"UpstreamRate"`    // e.g. "0.000000"
	PacketsSent     int64  `json:"PacketsSent"`     // e.g. 0
	BytesSent       int64  `json:"BytesSent"`       // e.g. 0
	PacketsReceived int64  `json:"PacketsReceived"` // e.g. 0
	HasDatacard     bool   `json:"HasDatacard"`     // e.g. false
	DownstreamRate  string `json:"DownstreamRate"`  // e.g. "0.000000"
}

type WifiNetwork

type WifiNetwork struct {
	Numbers       string `json:"Numbers"`       // e.g. "10"
	WifiEnable    bool   `json:"WifiEnable"`    // e.g. true
	WifiFrequency int8   `json:"WifiFrequency"` // e.g. 5
	WifiSSID      string `json:"WifiSsid"`      // e.g. "Blah"
}

type WifiStatistics

type WifiStatistics struct {
	ReceiveBytes   int64  `json:"receivebytes"`   // e.g. 1432834374
	SendBytes      int64  `json:"sendbytes"`      // e.g. 3297610140
	WifiMode       string `json:"wifimode"`       // e.g. "5GHz"
	SendDiscard    int64  `json:"senddiscard"`    // e.g. 0
	SendError      int64  `json:"senderror"`      // e.g. 19046
	Name           string `json:"name"`           // e.g. "Blah"
	ReceivePacket  int64  `json:"receivepacket"`  // e.g. 160109751
	SendPacket     int64  `json:"sendpacket"`     // e.g. 403167409
	ReceiveDiscard int64  `json:"receivediscard"` // e.g. 0
	ReceiveError   int64  `json:"receiveerror"`   // e.g. 0
}

Jump to

Keyboard shortcuts

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