discovery

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ArpUpdateEvent represents an ARP update event
	ArpUpdateEvent = "DISCOVERY_ARP_UPDATE"
	// SynUpdateEvent represents an SYN update event
	SynUpdateEvent = "DISCOVERY_SYN_UPDATE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DetailScanner

type DetailScanner interface {
	GetServerDetails(ctx context.Context, ip, sshPort string) (*Details, error)
}

DetailScanner interface for gathering more details about a device

type Details

type Details struct {
	Hostname string
	OS       string
}

Details represents the details returned by DetailScanner

type DiscoveryResult

type DiscoveryResult struct {
	Type     string
	ID       string
	Hostname string
	IP       string
	OS       string
	Vendor   string
	Status   ServerStatus
	Port     Port
}

nolint:revive DiscoveryResult represents our discovered device on the network

type Port

type Port struct {
	ID     uint16
	Status PortStatus
}

Port data structure representing a server port

type PortStatus

type PortStatus string

PortStatus represents possible port statuses

const (
	// PortOpen status used when a port is marked open
	PortOpen PortStatus = "open"
	// PortClosed status used when a port is marked closed
	PortClosed PortStatus = "closed"
)

type Scanner

type Scanner interface {
	Scan() error
	Stop()
	Results() chan *scanner.ScanResult
}

Scanner interface for scanning a network for devices

type ScannerService

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

ScannerService implements the Service interface for monitoring a network

func NewScannerService

func NewScannerService(
	conf config.Config,
	scanner Scanner,
	detailScanner DetailScanner,
	eventManager event.Manager,
) *ScannerService

NewScannerService returns a new instance of ScannerService

func (*ScannerService) MonitorNetwork

func (s *ScannerService) MonitorNetwork() error

MonitorNetwork polls the network to discover and track devices

func (*ScannerService) SetConfigAndScanner added in v1.2.0

func (s *ScannerService) SetConfigAndScanner(conf config.Config, netScanner Scanner)

SetConfigAndScanner sets the config and scanner to use when performing network discovery

func (*ScannerService) Stop

func (s *ScannerService) Stop()

Stop stop network discover. Once called this service will be useless. A new one must be instantiated to continue

type ServerStatus added in v1.0.0

type ServerStatus string

ServerStatus represents possible server statuses

const (
	// ServerOnline status used when a server online
	ServerOnline ServerStatus = "online"
	// ServerOffline status used when a server offline
	ServerOffline ServerStatus = "offline"
)

type Service

type Service interface {
	MonitorNetwork() error
	SetConfigAndScanner(conf config.Config, netScanner Scanner)
	Stop()
}

Service interface for monitoring a network

type UnameScanner added in v1.0.0

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

UnameScanner is an implementation of the DetailScanner interface

func NewUnameScanner added in v1.0.0

func NewUnameScanner(conf config.Config) *UnameScanner

NewUnameScanner returns a new instance of UnameScanner

func (UnameScanner) GetServerDetails added in v1.0.0

func (s UnameScanner) GetServerDetails(ctx context.Context, ip, sshPort string) (*Details, error)

GetServerDetails returns server details using ssh and "uname -a" command

Jump to

Keyboard shortcuts

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