session

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication

type Authentication interface {
	Auth(hs *HttpSession) (ok bool, token string, err error)
}

type Authenticator

type Authenticator struct{}

func (*Authenticator) Auth

func (au *Authenticator) Auth(hs *HttpSession) (ok bool, token string, err error)

type CliSession

type CliSession struct {
	Session
	Info *DeviceBaseInfo

	OpType terminalmode.ModeType
	// contains filtered or unexported fields
}

func NewCliSession

func NewCliSession(info *DeviceBaseInfo) *CliSession

func (*CliSession) BatchConfig

func (cli *CliSession) BatchConfig(cmds interface{}, stopOnError bool) error

func (*CliSession) BatchRun

func (cli *CliSession) BatchRun(cmds interface{}, stopOnError bool) error

func (*CliSession) Run

func (cli *CliSession) Run(cmd *command.CliCmd) (*command.CacheData, error)

func (*CliSession) WithModeType

func (cli *CliSession) WithModeType(opType terminalmode.ModeType)

type Debug

type Debug struct {
	DNS struct {
		Start   string       `json:"start"`
		End     string       `json:"end"`
		Host    string       `json:"host"`
		Address []net.IPAddr `json:"address"`
		Error   error        `json:"error"`
	} `json:"dns"`
	Dial struct {
		Start string `json:"start"`
		End   string `json:"end"`
	} `json:"dial"`
	Connection struct {
		Time string `json:"time"`
	} `json:"connection"`
	WroteAllRequestHeaders struct {
		Time string `json:"time"`
	} `json:"wrote_all_request_header"`
	WroteAllRequest struct {
		Time string `json:"time"`
	} `json:"wrote_all_request"`
	FirstReceivedResponseByte struct {
		Time string `json:"time"`
	} `json:"first_received_response_byte"`
}

type DeviceBaseInfo

type DeviceBaseInfo struct {
	terminal.BaseInfo `json:"base_info" mapstructure:"base_info" yaml:"base_info"`
	// Host       string `json:"host" mapstructure:"host" yaml:"host"`
	// Username   string `json:"username" mapstructure:"username" yaml:"username"`
	// Password   string `json:"password" mapstructure:"password" yaml:"password"`
	// AuthPass   string `json:"auth_pass" mapstructure:"auth_pass" yaml:"auth_pass"`
	// Port       int    `json:"port" mapstructure:"port" yaml:"port"`
	// Authorize  bool   `json:"authorize" mapstructure:"authorize" yaml:"authorize"`
	// SshOptions string `json:"ssh_options" mapstructure:"ssh_options" yaml:"ssh_options"`
	Community string `json:"community" mapstructure:"community" yaml:"community"`
	Mode      string `json:"mode" mapstructure:"mode" yaml:"mode"`
	Sn        string `json:"sn" mapstructure:"sn" yaml:"sn"`
	Token     string `json:"token" mapstructure:"token" yaml:"token"`
}

func NewDeviceBaseInfo

func NewDeviceBaseInfo(host, user, pass, devType, community string, port int) *DeviceBaseInfo

func (*DeviceBaseInfo) WithAuthPass

func (dbi *DeviceBaseInfo) WithAuthPass(auth_pass string) *DeviceBaseInfo

func (*DeviceBaseInfo) WithMode

func (dbi *DeviceBaseInfo) WithMode(mode string) *DeviceBaseInfo

func (*DeviceBaseInfo) WithSn

func (dbi *DeviceBaseInfo) WithSn(sn string) *DeviceBaseInfo

func (*DeviceBaseInfo) WithSshOptions

func (dbi *DeviceBaseInfo) WithSshOptions(ssh_options string) *DeviceBaseInfo

func (*DeviceBaseInfo) WithTelnet

func (dbi *DeviceBaseInfo) WithTelnet(telnet bool) *DeviceBaseInfo

func (*DeviceBaseInfo) WithToken

func (dbi *DeviceBaseInfo) WithToken(token string) *DeviceBaseInfo

type HeadBuilder

type HeadBuilder interface {
	BuildHeader(hs *HttpSession) (header *http.Header)
}

type HttpHeader

type HttpHeader struct{}

func (*HttpHeader) BuildHeader

func (th *HttpHeader) BuildHeader(hs *HttpSession) (header *http.Header)

type HttpSession

type HttpSession struct {
	Session
	Info      *DeviceBaseInfo
	AuthUrl   string
	TokenId   string
	TokenTime time.Time
	// contains filtered or unexported fields
}

func NewHttpSession

func NewHttpSession(info *DeviceBaseInfo, auth_url string) *HttpSession

func (*HttpSession) BatchConfig

func (hs *HttpSession) BatchConfig(cmds interface{}, stopOnError bool) error

func (*HttpSession) BatchRun

func (hs *HttpSession) BatchRun(cmds interface{}, stopOnError bool) error

func (*HttpSession) Client

func (hs *HttpSession) Client() *http.Client

func (*HttpSession) EnableBasicAuth

func (hs *HttpSession) EnableBasicAuth() *HttpSession

func (*HttpSession) EnableBasicAuthAll

func (hs *HttpSession) EnableBasicAuthAll() *HttpSession

func (*HttpSession) Request

func (hs *HttpSession) Request(cmd *command.HttpCmd) (*command.CacheData, error)

func (*HttpSession) RequestWithoutCache

func (hs *HttpSession) RequestWithoutCache(cmd *command.HttpCmd) ([]byte, error)

func (*HttpSession) WithAuthData

func (hs *HttpSession) WithAuthData(data []byte) *HttpSession

func (*HttpSession) WithTokenField

func (hs *HttpSession) WithTokenField(tokenField string) *HttpSession

type NetconfSession

type NetconfSession struct {
	Session
	Info *DeviceBaseInfo
	// contains filtered or unexported fields
}

func NewNetconfSession

func NewNetconfSession(info *DeviceBaseInfo) *NetconfSession

func (*NetconfSession) Run

type Session

type Session struct{}

func (*Session) Get

func (s *Session) Get(ip string, cmd command.Command) (cd *command.CacheData, err error)

func (*Session) Set

func (s *Session) Set(ip string, cmd command.Command, cd *command.CacheData) (err error)

type SnmpSession

type SnmpSession struct {
	Session
	Info *DeviceBaseInfo
	// contains filtered or unexported fields
}

func NewSnmpSession

func NewSnmpSession(info *DeviceBaseInfo) *SnmpSession

func (*SnmpSession) Run

func (ss *SnmpSession) Run(cmd *command.SnmpCmd) (*command.CacheData, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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