server

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

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

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(cfg *Config) bool

func SetCapabilities

func SetCapabilities() error

func SetFlags added in v0.2.0

func SetFlags(fs *pflag.FlagSet, cfg *Config)

Types

type AsnStorer added in v0.2.0

type AsnStorer interface {
	UpsertAsn(context.Context, model.Asn) error
	GetAsn(context.Context, string) (model.Asn, error)
}

type Config added in v0.2.0

type Config struct {
	ConfigDirectory string
	Store           *Store
	Wui             *WuiConfig
	Tui             *TuiConfig
	Bus             *bus.Config
	Discovery       *discovery.Config
	Pinger          *pinger.Config
	Enrichment      *enrichment.Config
	NetFlows        *netflows.Config
	Asn             *asn.Config
	Oui             *oui.Config
}

func GetConfig added in v0.2.0

func GetConfig() *Config

func (Config) Save added in v0.2.0

func (c Config) Save() error

type DeviceStorer added in v0.2.0

type DeviceStorer interface {
	AddDevice(context.Context, model.Device) error
	RemoveDeviceByAddr(context.Context, model.Addr) error
	UpdateDevice(context.Context, model.Device) (bool, error)
	GetDeviceByAddr(context.Context, model.Addr) (model.Device, error)
	GetFilteredDevices(context.Context, model.DeviceFilter) []model.Device
	ListDevices(context.Context) []model.Device
	CountDevices(context.Context) int
}

DeviceStorer allows for the saving and fetching of device definitions.

type Mason

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

func New

func New(opts ...Option) *Mason

func (*Mason) AddNetwork

func (m *Mason) AddNetwork(ctx context.Context, network model.Network) error

func (*Mason) AddNetworkByName

func (m *Mason) AddNetworkByName(
	ctx context.Context,
	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,
) (model.MAC, 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(ctx context.Context) int

func (*Mason) CountNetworks

func (m *Mason) CountNetworks(ctx context.Context) 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 model.Addr,
) (info nettools.SnmpInfo, err error)

func (*Mason) FetchTLSInfo

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

func (*Mason) FlowSummaryByCountry added in v0.2.0

func (m *Mason) FlowSummaryByCountry(
	ctx context.Context,
	addr model.Addr,
) ([]model.FlowSummaryForAddrByCountry, error)

func (*Mason) FlowSummaryByIP added in v0.2.0

func (m *Mason) FlowSummaryByIP(
	ctx context.Context,
	addr model.Addr,
) ([]model.FlowSummaryForAddrByIP, error)

func (*Mason) FlowSummaryByName added in v0.2.0

func (m *Mason) FlowSummaryByName(
	ctx context.Context,
	addr model.Addr,
) ([]model.FlowSummaryForAddrByName, error)

func (*Mason) GetAsn added in v0.2.0

func (m *Mason) GetAsn(ctx context.Context, asn string) (model.Asn, error)

func (*Mason) GetConfig

func (m *Mason) GetConfig() *Config

func (*Mason) GetDeviceByAddr

func (m *Mason) GetDeviceByAddr(ctx context.Context, addr model.Addr) (model.Device, error)

func (*Mason) GetExternalAddr

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

func (*Mason) GetInternalsSnapshot

func (m *Mason) GetInternalsSnapshot(ctx context.Context) MasonInternalsView

func (*Mason) GetNetworkStats

func (m *Mason) GetNetworkStats(ctx context.Context) []model.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,
	priviledged bool,
) (stats nettools.Icmp4EchoResponseStatistics, err error)

func (*Mason) IcmpPingAddr

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

func (*Mason) ListDevices

func (m *Mason) ListDevices(ctx context.Context) []model.Device

func (*Mason) ListNetworks

func (m *Mason) ListNetworks(ctx context.Context) []model.Network

func (*Mason) LookupIP added in v0.2.0

func (m *Mason) LookupIP(addr model.Addr) string

func (*Mason) OuiLookup

func (m *Mason) OuiLookup(mac net.HardwareAddr) string

func (*Mason) PingFailures

func (m *Mason) PingFailures(ctx context.Context) []model.Device

func (*Mason) Portscan

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

func (*Mason) ReadPerformancePings added in v0.2.0

func (m *Mason) ReadPerformancePings(
	ctx context.Context,
	device model.Device,
	duration time.Duration,
) ([]pinger.Point, error)

func (*Mason) Run

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

func (*Mason) ServerDevices

func (m *Mason) ServerDevices(ctx context.Context) []model.Device

func (*Mason) StringToAddr

func (m *Mason) StringToAddr(str string) (model.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 model.Addr,
) (stats []nettools.Icmp4EchoResponseStatistics, err error)

type MasonInternalsView

type MasonInternalsView struct {
	NumberOfGoProcs int

	NetworkStoreCount int
	DeviceStoreCount  int

	DiscoveryMaxWorkers    int
	EnrichmentMaxWorkers   int
	EnrichmentBackPressure int
	PortScanMaxWorkers     int
	PingerMaxWorkers       int

	AddressScanActive  int
	DeviceEnrichActive int
	PerfPingActive     int
	NetworkScanActive  int

	BusBackPressure int

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

	Memstats  runtime.MemStats
	Buildinfo debug.BuildInfo
}

type NetflowStorer added in v0.2.0

type NetflowStorer interface {
	AsnStorer
	AddNetflows(context.Context, []model.IpFlow) error
	GetNetflows(context.Context, model.Addr) ([]model.IpFlow, error)
	FlowSummaryByIP(context.Context, model.Addr) ([]model.FlowSummaryForAddrByIP, error)
	FlowSummaryByName(context.Context, model.Addr) ([]model.FlowSummaryForAddrByName, error)
	FlowSummaryByCountry(
		context.Context,
		model.Addr,
	) ([]model.FlowSummaryForAddrByCountry, error)
}

type NetworkStorer added in v0.2.0

type NetworkStorer interface {
	AddNetwork(context.Context, model.Network) error
	RemoveNetworkByName(context.Context, string) error
	UpdateNetwork(context.Context, model.Network) error
	UpsertNetwork(context.Context, model.Network) error
	GetNetworkByName(context.Context, string) (model.Network, error)
	GetFilteredNetworks(context.Context, model.NetworkFilter) []model.Network
	ListNetworks(context.Context) []model.Network
	CountNetworks(context.Context) int
}

NetworkStorer allows for the saving and fetching of network definitions.

type Option added in v0.2.0

type Option func(*Options)

func WithBus added in v0.2.0

func WithBus(x bus.Bus) Option

func WithConfig added in v0.2.0

func WithConfig(x *Config) Option

func WithNetflowStorer added in v0.2.0

func WithNetflowStorer(x NetflowStorer) Option

func WithStore added in v0.2.0

func WithStore(x Storer) Option

type Options added in v0.2.0

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

type PerformancePingStorer added in v0.2.0

type PerformancePingStorer interface {
	WritePerformancePing(
		context.Context,
		time.Time,
		model.Device,
		nettools.Icmp4EchoResponseStatistics,
	) error
	ReadPerformancePings(
		context.Context,
		model.Device,
		time.Duration,
	) ([]pinger.Point, error)
}

PerformancePingStorer allows for the saving and fetching of timeseries data.

type Store added in v0.2.0

type Store struct {
	Combo  *combostore.Config
	Sqlite *sqlitestore.Config
}

type Storer added in v0.2.0

type Storer interface {
	NetworkStorer
	DeviceStorer
	PerformancePingStorer
	Close() error
}

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

type TuiConfig added in v0.2.0

type TuiConfig struct {
	Enabled       bool
	ListenAddress string
	KeyDirectory  string
}

type WuiConfig added in v0.2.0

type WuiConfig struct {
	Enabled       bool
	ListenAddress string
}

Jump to

Keyboard shortcuts

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