tools

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToJavaBigIntegerBytes

func BytesToJavaBigIntegerBytes(valueBytes []byte) []byte

BytesToJavaBigIntegerBytes transforms valueBytes so it can be used to initialize a java.math.BigInteger via the (byte[]) constructor. source: https://github.com/j-white/underling/blob/master/underlinglib/snmp_helper.go

func GetHTTPClient

func GetHTTPClient(skipSSL bool, timeout time.Duration) *http.Client

GetHTTPClient returns an HTTP Client with a given timeout, and transport

func GetOidToWalk

func GetOidToWalk(base string, instance string) string

GetOidToWalk builds a walkable OID

func GetResultForPDU

func GetResultForPDU(pdu gosnmp.SnmpPDU, base string) api.SNMPResultDTO

GetResultForPDU get results from a given SNMP PDU

func NetMessageContains

func NetMessageContains(conn net.Conn, timeout time.Duration, banner string) (bool, error)

NetMessageContains reads message from network connection and verify if contains banner

func ParseHTTPResponseRange

func ParseHTTPResponseRange(responseRange string) (min int, max int)

ParseHTTPResponseRange parses a given response range

func Ping

func Ping(addr string, timeout time.Duration) (time.Duration, error)

TODO add logic for handling retries

Types

type MockSNMPClient

type MockSNMPClient struct {
	WalkMap map[string][]gosnmp.SnmpPDU
	GetMap  map[string]*gosnmp.SnmpPacket
}

MockSNMPClient represents a mock implementation of the SNMP Handler for testing purposes

func (*MockSNMPClient) BulkWalk

func (cli *MockSNMPClient) BulkWalk(rootOid string, walkFn gosnmp.WalkFunc) error

BulkWalk emulates a walk based on the provided list of PDUs

func (*MockSNMPClient) Connect

func (cli *MockSNMPClient) Connect() error

Connect always returns a nil error

func (*MockSNMPClient) Disconnect

func (cli *MockSNMPClient) Disconnect() error

Disconnect always returns a nil error

func (*MockSNMPClient) Get

func (cli *MockSNMPClient) Get(oid string) (result *gosnmp.SnmpPacket, err error)

Get emulates a get based on the provided map of PDU packets

func (*MockSNMPClient) Target

func (cli *MockSNMPClient) Target() string

Target returns a fixed IP for testing purposes

func (*MockSNMPClient) Version

func (cli *MockSNMPClient) Version() string

Version returns a fixed version for testing purposes

Jump to

Keyboard shortcuts

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