snmpproxy

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Get     = RequestType("get")
	GetNext = RequestType("getNext")
	Walk    = RequestType("walk")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiListener

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

func NewApiListener

func NewApiListener(
	validator *RequestValidator,
	requester Requester,
	logger *zap.SugaredLogger,
	listen string,
	socketPermissions os.FileMode,
) *ApiListener

func (*ApiListener) Close

func (l *ApiListener) Close()

func (*ApiListener) ServeHTTP

func (l *ApiListener) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*ApiListener) Start

func (l *ApiListener) Start() error

type ApiRequest

type ApiRequest struct {
	Host      string        `json:"host"`
	Community string        `json:"community"`
	Version   SnmpVersion   `json:"version"`
	Retries   uint8         `json:"retries"`
	Timeout   time.Duration `json:"timeout"`
	Requests  []Request     `json:"requests"`
}

func (*ApiRequest) UnmarshalJSON

func (r *ApiRequest) UnmarshalJSON(data []byte) error

type GosnmpRequester

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

func NewGosnmpRequester

func NewGosnmpRequester(valueFormatter *ValueFormatter) *GosnmpRequester

func (*GosnmpRequester) ExecuteRequest

func (r *GosnmpRequester) ExecuteRequest(apiRequest *ApiRequest) ([][]any, error)

type Request

type Request struct {
	RequestType    RequestType `json:"request_type"`
	Oids           []string    `json:"oids"`
	MaxRepetitions uint32      `json:"max_repetitions"`
}

func (*Request) UnmarshalJSON

func (r *Request) UnmarshalJSON(data []byte) error

type RequestType

type RequestType string

func (*RequestType) UnmarshalJSON

func (t *RequestType) UnmarshalJSON(data []byte) error

type RequestValidator

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

func NewRequestValidator

func NewRequestValidator(maxTimeoutSeconds uint, maxRetries uint8) *RequestValidator

func (*RequestValidator) Validate

func (v *RequestValidator) Validate(apiRequest *ApiRequest) error

type Requester

type Requester interface {
	ExecuteRequest(apiRequest *ApiRequest) ([][]any, error)
}

type Response

type Response struct {
	Error  string  `json:"error,omitempty"`
	Result [][]any `json:"result,omitempty"`
}

func (*Response) Bytes

func (r *Response) Bytes() []byte

type SnmpVersion

type SnmpVersion gosnmp.SnmpVersion

func (*SnmpVersion) UnmarshalJSON

func (v *SnmpVersion) UnmarshalJSON(data []byte) error

type ValueFormatter added in v1.1.0

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

func NewValueFormatter added in v1.1.0

func NewValueFormatter(mibDataProvider *mib.DataProvider) *ValueFormatter

func (*ValueFormatter) Format added in v1.1.0

func (f *ValueFormatter) Format(dataUnit gosnmp.SnmpPDU) any

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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