model

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDeviceExists       = errors.New("device exists")
	ErrDeviceDoesNotExist = errors.New("device does not exists")

	EmptyDevice = Device{}
)
View Source
var (
	ErrNetworkExists       = errors.New("network exists")
	ErrNetworkDoesNotExist = errors.New("network does not exists")
)
View Source
var RandomizedMacAddressTag = Tag{Val: "RandomizedMACAddress"}

Functions

func CompareNetwork

func CompareNetwork(a Network, b Network) int

func ComparePrefix

func ComparePrefix(a Prefix, b Prefix) int

func DateTimeFmt

func DateTimeFmt(t time.Time) string

func IsUsefulInterface

func IsUsefulInterface(iface net.Interface) bool

func NewNetworkIterator

func NewNetworkIterator(n Network) *networkIterator

func NewNetworkIteratorAsChannel

func NewNetworkIteratorAsChannel(n Network) *networkIteratorAsChannel

func SortDevicesByAddr

func SortDevicesByAddr(devs []Device)

func SortNetworksByAddr

func SortNetworksByAddr(nets []Network)

Types

type Addr

type Addr struct {
	A netip.Addr
}

func AddrToModelAddr

func AddrToModelAddr(a netip.Addr) Addr

func MustParseAddr

func MustParseAddr(s string) Addr

func ParseAddr

func ParseAddr(s string) (ip Addr, err error)

func (Addr) Addr

func (na Addr) Addr() netip.Addr

func (Addr) Compare

func (na Addr) Compare(ip2 Addr) int

func (*Addr) Scan

func (na *Addr) Scan(src interface{}) error

func (Addr) String

func (na Addr) String() string

func (Addr) Value

func (na Addr) Value() (driver.Value, error)

type Asn

type Asn struct {
	IPRange IPRange
	Asn     string
	Country string
	Name    string
}

type Device

type Device struct {
	Name         string
	Addr         Addr
	MAC          MAC
	DiscoveredAt time.Time
	DiscoveredBy DiscoverySource

	Meta            Meta
	Server          Server
	PerformancePing Pinger
	SNMP            SNMP
	// contains filtered or unexported fields
}

func (*Device) ClearUpdated

func (d *Device) ClearUpdated()

func (Device) DiscoveredAtString

func (d Device) DiscoveredAtString() string

func (Device) FirstSeenString

func (d Device) FirstSeenString() string

func (Device) IsNameAddr

func (d Device) IsNameAddr() bool

func (Device) IsServer

func (d Device) IsServer() bool

func (Device) IsUpdated

func (d Device) IsUpdated() bool

func (Device) LastPingMaximumString

func (d Device) LastPingMaximumString() string

func (Device) LastPingMeanString

func (d Device) LastPingMeanString() string

func (Device) LastSeenDurString

func (d Device) LastSeenDurString(f func(time.Time) time.Duration) string

func (Device) LastSeenString

func (d Device) LastSeenString() string

func (Device) Merge

func (d Device) Merge(in Device) Device

func (*Device) SetUpdated

func (d *Device) SetUpdated()

func (Device) String

func (d Device) String() string

func (*Device) UpdateFromPingStats

func (d *Device) UpdateFromPingStats(stats nettools.Icmp4EchoResponseStatistics, ts time.Time)

type DeviceFilter

type DeviceFilter func(Device) bool

DeviceFilter defines a function used to select a set of required devices.

type DiscoveredNetwork

type DiscoveredNetwork Network

type DiscoverySource

type DiscoverySource string

func (DiscoverySource) IsEmpty

func (ds DiscoverySource) IsEmpty() bool

func (*DiscoverySource) Scan

func (ds *DiscoverySource) Scan(src interface{}) error

func (DiscoverySource) String

func (ds DiscoverySource) String() string

func (DiscoverySource) Value

func (ds DiscoverySource) Value() (driver.Value, error)

type EventDeviceAdded

type EventDeviceAdded Device

func (EventDeviceAdded) String

func (nd EventDeviceAdded) String() string

type EventDeviceDiscovered

type EventDeviceDiscovered Device
var EmptyDiscoveredDevice EventDeviceDiscovered

func (EventDeviceDiscovered) String

func (dd EventDeviceDiscovered) String() string

type EventDeviceUpdated

type EventDeviceUpdated Device

func (EventDeviceUpdated) String

func (ude EventDeviceUpdated) String() string

type FlowSummaryForAddrByCountry

type FlowSummaryForAddrByCountry struct {
	Country   string
	Name      string
	RecvBytes int
	XmitBytes int
}

type FlowSummaryForAddrByIP

type FlowSummaryForAddrByIP struct {
	Country   string
	Name      string
	Asn       string
	Addr      Addr
	RecvBytes int
	XmitBytes int
}

type FlowSummaryForAddrByName

type FlowSummaryForAddrByName struct {
	Name      string
	RecvBytes int
	XmitBytes int
}

type IPRange

type IPRange struct {
	A netipx.IPRange
}

func IPRangeToModelIPRange

func IPRangeToModelIPRange(a netipx.IPRange) IPRange

func MustParseIPRange

func MustParseIPRange(s string) IPRange

func ParseIPRange

func ParseIPRange(s string) (ip IPRange, err error)

func (IPRange) Compare

func (na IPRange) Compare(ip2 IPRange) int

func (IPRange) IPRange

func (na IPRange) IPRange() netipx.IPRange

func (*IPRange) Scan

func (na *IPRange) Scan(src interface{}) error

func (IPRange) String

func (na IPRange) String() string

func (IPRange) Value

func (na IPRange) Value() (driver.Value, error)

type IpAsn

type IpAsn struct {
	Asn
	IP      Addr
	Created time.Time
}

type IpFlow

type IpFlow struct {
	SrcAddr  Addr
	SrcPort  uint16
	SrcASN   string
	DstAddr  Addr
	DstPort  uint16
	DstASN   string
	Start    time.Time
	End      time.Time
	Bytes    int
	Packets  int
	Protocol Protocol // https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
	Flags    TcpFlags
}

func (IpFlow) String

func (ipf IpFlow) String() string

type MAC

type MAC struct {
	M net.HardwareAddr
}

func HardwareAddrToMAC

func HardwareAddrToMAC(a net.HardwareAddr) MAC

func MustParseMAC

func MustParseMAC(s string) MAC

func ParseMAC

func ParseMAC(s string) (m MAC, err error)

func (MAC) Addr

func (m MAC) Addr() net.HardwareAddr

func (MAC) Compare

func (m MAC) Compare(x MAC) int

func (MAC) IsEmpty

func (m MAC) IsEmpty() bool

func (*MAC) Scan

func (m *MAC) Scan(src interface{}) error

func (MAC) String

func (m MAC) String() string

func (MAC) Value

func (m MAC) Value() (driver.Value, error)

type Meta

type Meta struct {
	DnsName      string
	Manufacturer string
	Tags         Tags
}

type Network

type Network struct {
	Name     string
	Prefix   Prefix
	LastScan time.Time
	Tags     Tags
}

func New

func New(name string, ns string) (Network, error)

func NewNetworkFromPrefix

func NewNetworkFromPrefix(ns netip.Prefix) Network

func (Network) Contains

func (n Network) Contains(d Device) bool

func (Network) String

func (n Network) String() string

type NetworkAddedEvent

type NetworkAddedEvent Network

NetworkAddEvent

type NetworkFilter

type NetworkFilter func(Network) bool

NetworkFilter defines a function used to select a set of required devices.

type NetworkStats

type NetworkStats struct {
	Network
	IPUsed  uint64
	IPTotal float64
	AvgPing time.Duration
	MaxPing time.Duration
}

type Pinger

type Pinger struct {
	FirstSeen  time.Time
	LastSeen   time.Time
	Mean       time.Duration
	Maximum    time.Duration
	LastFailed bool
}

type PortList

type PortList struct {
	Ports []int
}

func IntSliceToPortList

func IntSliceToPortList(s []int) PortList

func MustParsePortList

func MustParsePortList(s string) PortList

func ParsePortList

func ParsePortList(s string) (pl PortList, err error)

func (PortList) Clone

func (pl PortList) Clone() PortList

func (PortList) IsEmpty

func (pl PortList) IsEmpty() bool

func (PortList) Len

func (pl PortList) Len() int

func (*PortList) Scan

func (pl *PortList) Scan(src interface{}) (err error)

func (PortList) String

func (pl PortList) String() string

func (PortList) Value

func (pl PortList) Value() (driver.Value, error)

type Prefix

type Prefix struct {
	P netip.Prefix
}

func MustParsePrefix

func MustParsePrefix(s string) Prefix

func PrefixToModelPrefix

func PrefixToModelPrefix(p netip.Prefix) Prefix

func (Prefix) Addr

func (np Prefix) Addr() netip.Addr

func (Prefix) Bits

func (np Prefix) Bits() int

func (Prefix) Contains

func (np Prefix) Contains(addr Addr) bool

func (Prefix) ContainsAddr

func (np Prefix) ContainsAddr(addr netip.Addr) bool

func (Prefix) Is6

func (np Prefix) Is6() bool

func (*Prefix) Scan

func (np *Prefix) Scan(src interface{}) error

func (Prefix) String

func (np Prefix) String() string

func (Prefix) Value

func (np Prefix) Value() (driver.Value, error)

type Protocol

type Protocol byte

func (Protocol) String

func (p Protocol) String() string

type SNMP

type SNMP struct {
	Name               string
	Description        string
	Community          string
	Port               int
	LastSNMPCheck      time.Time
	HasArpTable        bool
	LastArpTableScan   time.Time
	HasInterfaces      bool
	LastInterfacesScan time.Time
}

type ScanAllNetworksRequest

type ScanAllNetworksRequest struct{}

type ScanNetworkRequest

type ScanNetworkRequest Network

type Server

type Server struct {
	Ports    PortList
	LastScan time.Time
}

type Tag

type Tag struct {
	Val string
}

func Add

func Add(tag Tag, tags []Tag) []Tag

func Remove

func Remove(tag Tag, tags []Tag) []Tag

func (Tag) Equal

func (t Tag) Equal(intag Tag) bool

func (*Tag) Scan

func (t *Tag) Scan(src interface{}) error

func (Tag) Value

func (t Tag) Value() (driver.Value, error)

type Tags

type Tags []Tag

func (*Tags) Scan

func (ts *Tags) Scan(src interface{}) error

func (Tags) String added in v0.3.0

func (ts Tags) String() string

func (Tags) Value

func (ts Tags) Value() (driver.Value, error)

type TcpFlags

type TcpFlags byte

func (TcpFlags) String

func (tf TcpFlags) String() string

Jump to

Keyboard shortcuts

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