server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package server provides the Mason application used for network discovery and management

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasCapabilities

func HasCapabilities() bool

func SetCapabilities

func SetCapabilities() error

Types

type Mason

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

func New

func New(
	cfg *config.Config,
	b bus.Bus,
	store StoreAll,
) *Mason

func NewTool

func NewTool() *Mason

NewTool returns a Mason instance meant for network tool usage (ping, traceroute, etc..) and not persisting data or operating as a server

func (*Mason) AddNetwork

func (m *Mason) AddNetwork(network network.Network) error

func (*Mason) AddNetworkByName

func (m *Mason) AddNetworkByName(name string, prefix string, scannow bool) error

AddNetwork is a helper function to introduce a new network into the system

func (Mason) ArpPing

func (m Mason) ArpPing(
	ctx context.Context,
	target string,
	timeout time.Duration,
) (net.HardwareAddr, error)

func (Mason) CheckDNS

func (m Mason) CheckDNS(
	ctx context.Context,
	target string,
) (map[string]map[string][]netip.Addr, error)

func (*Mason) CountDevices

func (m *Mason) CountDevices() int

func (*Mason) CountNetworks

func (m *Mason) CountNetworks() int

func (Mason) FetchSNMPInfo

func (m Mason) FetchSNMPInfo(
	ctx context.Context,
	target string,
) (info nettools.SnmpInfo, err error)

func (Mason) FetchSNMPInfoAddr

func (m Mason) FetchSNMPInfoAddr(
	ctx context.Context,
	target netip.Addr,
) (info nettools.SnmpInfo, err error)

func (Mason) FetchTLSInfo

func (m Mason) FetchTLSInfo(ctx context.Context, target string) (nettools.TLS, error)

func (Mason) GetConfig

func (m Mason) GetConfig() config.Config

func (*Mason) GetDeviceByAddr

func (m *Mason) GetDeviceByAddr(addr netip.Addr) (device.Device, error)

func (Mason) GetExternalAddr

func (m Mason) GetExternalAddr(ctx context.Context) (netip.Addr, error)

func (*Mason) GetInternalsSnapshot

func (m *Mason) GetInternalsSnapshot() MasonInternalsView

func (Mason) GetNetworkStats

func (m Mason) GetNetworkStats() []network.NetworkStats

func (Mason) GetUserAgent

func (m Mason) GetUserAgent() string

func (Mason) IcmpPing

func (m Mason) IcmpPing(
	ctx context.Context,
	target string,
	count int,
	timeout time.Duration,
) (stats nettools.Icmp4EchoResponseStatistics, err error)

func (Mason) IcmpPingAddr

func (m Mason) IcmpPingAddr(
	ctx context.Context,
	addr netip.Addr,
	count int,
	timeout time.Duration,
) (nettools.Icmp4EchoResponseStatistics, error)

func (*Mason) ListDevices

func (m *Mason) ListDevices() []device.Device

func (*Mason) ListNetworks

func (m *Mason) ListNetworks() []network.Network

func (Mason) OuiLookup

func (m Mason) OuiLookup(mac net.HardwareAddr) (string, error)

func (Mason) PingFailures

func (m Mason) PingFailures() []device.Device

func (Mason) Portscan

func (m Mason) Portscan(
	ctx context.Context,
	target string,
	cfg *config.PortScannerConfig,
) ([]int, error)

func (*Mason) ReadTimeseriesPoints

func (m *Mason) ReadTimeseriesPoints(
	ctx context.Context,
	device device.Device,
	duration time.Duration,
	hydrator pinger.TimeseriesPoint,
) ([]pinger.TimeseriesPoint, error)

func (*Mason) Run

func (m *Mason) Run(ctx context.Context)

func (Mason) ServerDevices

func (m Mason) ServerDevices() []device.Device

func (Mason) StringToAddr

func (m Mason) StringToAddr(str string) (netip.Addr, error)

func (Mason) Traceroute

func (m Mason) Traceroute(
	ctx context.Context,
	target string,
) (stat []nettools.Icmp4EchoResponseStatistics, err error)

func (Mason) TracerouteAddr

func (m Mason) TracerouteAddr(
	ctx context.Context,
	target netip.Addr,
) (stats []nettools.Icmp4EchoResponseStatistics, err error)

type MasonInternalsView

type MasonInternalsView struct {
	NumberOfGoProcs int

	NetworkStoreCount int
	DeviceStoreCount  int

	NetworkScanMaxWorkers int
	DiscoveryMaxWorkers   int
	EnrichmentMaxWorkers  int
	PortScanMaxWorkers    int
	PingerMaxWorkers      int

	AddressScanActive  int
	DeviceEnrichActive int
	PerfPingActive     int
	NetworkScanActive  int

	CurrentNetworkScan string
	Events             []bus.HistoricalEvent
	Errors             []bus.HistoricalError

	Memstats  runtime.MemStats
	Buildinfo debug.BuildInfo
}

type MasonReader

type MasonReader interface {
	ListNetworks() []network.Network
	CountNetworks() int
	ListDevices() []device.Device
	CountDevices() int
	GetDeviceByAddr(netip.Addr) (device.Device, error)
	ReadTimeseriesPoints(
		context.Context,
		device.Device,
		time.Duration,
		pinger.TimeseriesPoint,
	) ([]pinger.TimeseriesPoint, error)
	GetConfig() config.Config
	GetInternalsSnapshot() MasonInternalsView
	GetUserAgent() string
	OuiLookup(mac net.HardwareAddr) (string, error)
	GetNetworkStats() []network.NetworkStats
	PingFailures() []device.Device
	ServerDevices() []device.Device
}

type MasonReaderWriter

type MasonReaderWriter interface {
	MasonReader
	MasonWriter
	MasonNetworker
}

type MasonWriter

type MasonWriter interface {
	AddNetwork(network.Network) error
	AddNetworkByName(string, string, bool) error
}

type StoreAll

type StoreAll interface {
	StoreNetwork
	StoreDevice
	StoreTimeseries
}

StoreAll is a complete implementation of all objects which need to be managed

type StoreDevice

type StoreDevice interface {
	AddDevice(device.Device) error
	RemoveDeviceByAddr(netip.Addr) error
	UpdateDevice(device.Device) error
	GetDeviceByAddr(netip.Addr) (device.Device, error)
	GetFilteredDevices(device.DeviceFilter) []device.Device
	ListDevices() []device.Device
	CountDevices() int
}

StoreDevice allows for the saving and fetching of device definitions.

type StoreNetwork

type StoreNetwork interface {
	AddNetwork(n network.Network) error
	RemoveNetworkByName(name string) error
	UpdateNetwork(network.Network) error
	UpsertNetwork(network.Network) error
	GetNetworkByName(name string) (network.Network, error)
	GetFilteredNetworks(network.NetworkFilter) []network.Network
	ListNetworks() []network.Network
	CountNetworks() int
}

StoreNetwork allows for the saving and fetching of network definitions.

type StoreTimeseries

type StoreTimeseries interface {
	WriteTimeseriesPoint(
		context.Context,
		time.Time,
		device.Device,
		...pinger.TimeseriesPoint,
	) error
	ReadTimeseriesPoints(
		context.Context,
		device.Device,
		time.Duration,
		pinger.TimeseriesPoint,
	) ([]pinger.TimeseriesPoint, error)
}

StoreTimeseries allows for the saving and fetching of timeseries data.

Jump to

Keyboard shortcuts

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