dahua_panel

package module
v0.0.0-...-839245e Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2018 License: MIT Imports: 9 Imported by: 0

README

Dahua Panel

Build Status GitHub issues GitHub license Twitter

Simple client to manage VTO2111D Dahua Panel

Getting Started

go get github.com/denisrudov/dahua_panel

or even simpler

import github.com/denisrudov/dahua_panel

in your code and then

dep ensure

Authors

  • Denis Rudov

feel free to contribute :)

How to use

Just create client with credentials and IP address of a dahua panel

client := NewDahuaClient("admin", "adminpassword", "192.168.0.91")

To log in

client.Login()

To update maintain parameters

if client.Login() {
    maintainParams := dahua_panel.NewMaintainParams()

    if err := client.UpdateMaintainParams(maintainParams); err != nil {
       log.Println(err)
    }
}

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Index

Constants

View Source
const (
	MaintainParamName = "AutoMaintain" // Setting param Name

	ClientType    = "Web3.0" // Client Type constant
	LoginEndpoint = "/RPC2_Login"
	AuthorityType = "Default"
	PasswordType  = "Default"
)

Variables

This section is empty.

Functions

func NewMaintainParams

func NewMaintainParams() *maintainParams

func NewSettingRequest

func NewSettingRequest(maintainParams *maintainParams, id int, session string, requestType ...string) *settingRequest

Types

type AdditionalParams

type AdditionalParams struct {
	Params
	Realm         string `json:"realm"`
	Random        string `json:"random"`
	PasswordType  string `json:"passwordType"`
	AuthorityType string `json:"authorityType"`
}

type Dahua

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

func NewDahuaClient

func NewDahuaClient(username, password, address string) *Dahua

Make default Dahua Panel client

func (*Dahua) GetMaintainParams

func (d *Dahua) GetMaintainParams() (*maintainParams, error)

Get Maintain Params from Dahua Panel

func (*Dahua) GetSettings

func (d *Dahua) GetSettings() map[string]interface{}

func (*Dahua) Login

func (d *Dahua) Login() (rez bool)

Login to Dahua Panel

func (*Dahua) UpdateMaintainParams

func (d *Dahua) UpdateMaintainParams(optional ...*maintainParams) (rez error)

Update Maintain Params

type LoginRequest

type LoginRequest struct {
	Method  string `json:"method"`
	Params  `json:"params"`
	ID      int         `json:"id"`
	Session interface{} `json:"session"`
}

type LoginResponse

type LoginResponse struct {
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
	ID     int `json:"id"`
	Params struct {
		Authorization string `json:"authorization"`
		Encryption    string `json:"encryption"`
		Mac           string `json:"mac"`
		Random        string `json:"random"`
		Realm         string `json:"realm"`
	} `json:"params"`
	Result  bool   `json:"result"`
	Session string `json:"session"`
}

type Params

type Params struct {
	UserName   string `json:"userName"`
	Password   string `json:"password"`
	ClientType string `json:"clientType"`
}

type SecondLoginRequest

type SecondLoginRequest struct {
	Method  string           `json:"method"`
	Params  AdditionalParams `json:"params"`
	ID      int              `json:"id"`
	Session interface{}      `json:"session"`
}

type SecondLoginResponse

type SecondLoginResponse struct {
	ID     int `json:"id"`
	Params struct {
		KeepAliveInterval int `json:"keepAliveInterval"`
	} `json:"params"`
	Result  bool   `json:"result"`
	Session string `json:"session"`
}

type TableData

type TableData struct {
	AutoRebootDay      int  `json:"AutoRebootDay"`
	AutoRebootEnable   bool `json:"IsAutoRebootEnable"`
	AutoRebootHour     int  `json:"AutoRebootHour"`
	AutoRebootMinute   int  `json:"AutoRebootMinute"`
	AutoShutdownDay    int  `json:"AutoShutdownDay"`
	AutoShutdownHour   int  `json:"AutoShutdownHour"`
	AutoShutdownMinute int  `json:"AutoShutdownMinute"`
	AutoStartUpDay     int  `json:"AutoStartUpDay"`
	AutoStartUpHour    int  `json:"AutoStartUpHour"`
	AutoStartUpMinute  int  `json:"AutoStartUpMinute"`
}

Jump to

Keyboard shortcuts

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