mon

package
v1.1.22 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveHostname

func ResolveHostname(ip string) (string, error)

Types

type Client

type Client struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	IP        string
	HWAddr    string
	Name      string
	// contains filtered or unexported fields
}

Client represent a device on the network, a client is tracked by it's IP address.

func NewClient

func NewClient(ip string, avgSamples int) *Client

func (*Client) Stat

func (c *Client) Stat() clientstats.Stat

func (*Client) UpdateArp

func (c *Client) UpdateArp(a arp.Entry)

func (*Client) UpdateIPTables

func (c *Client) UpdateIPTables(s iptables.Stat, timestamp time.Time)

func (*Client) UpdateName

func (c *Client) UpdateName(name string)

type Clients

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

Clients hold the recorded data of all known clients data.

Access to the data is protected by a single mutex because it is expected that it is more than enough for this use case.

func NewClients

func NewClients(avgSamples int, hostAliases map[string]string) *Clients

func (*Clients) Stats

func (c *Clients) Stats() clientstats.Stats

func (*Clients) UpdateArp

func (c *Clients) UpdateArp(as arp.Entries) error

func (*Clients) UpdateIPTables

func (c *Clients) UpdateIPTables(stats IPTStats) error

func (*Clients) UpdateNames

func (c *Clients) UpdateNames(names map[string]string) error

type Flow added in v1.1.0

type Flow struct {
	Orig  Subflow
	Reply Subflow
	TTL   uint64
}

type FlowSlice

type FlowSlice []Flow

FlowSlice provides filtering and ordering methods.

func Flows

func Flows() (FlowSlice, error)

Flows returns the current connections that might be interesting to display to the user.

func (FlowSlice) FilterByIP

func (fs FlowSlice) FilterByIP(ip net.IP) FlowSlice

func (FlowSlice) OrderByOriginalBytes added in v1.1.3

func (fs FlowSlice) OrderByOriginalBytes()

func (FlowSlice) OrderByOriginalDPort

func (fs FlowSlice) OrderByOriginalDPort()

func (FlowSlice) OrderByOriginalDestination

func (fs FlowSlice) OrderByOriginalDestination()

func (FlowSlice) OrderByOriginalSPort

func (fs FlowSlice) OrderByOriginalSPort()

func (FlowSlice) OrderByOriginalSource

func (fs FlowSlice) OrderByOriginalSource()

func (FlowSlice) OrderByReplyBytes added in v1.1.3

func (fs FlowSlice) OrderByReplyBytes()

func (FlowSlice) OrderByReplyDPort

func (fs FlowSlice) OrderByReplyDPort()

func (FlowSlice) OrderByReplyDestination

func (fs FlowSlice) OrderByReplyDestination()

func (FlowSlice) OrderByReplySPort

func (fs FlowSlice) OrderByReplySPort()

func (FlowSlice) OrderByReplySource

func (fs FlowSlice) OrderByReplySource()

func (FlowSlice) OrderByTTL

func (fs FlowSlice) OrderByTTL()

type IPTStats

type IPTStats struct {
	CreatedAt time.Time
	Stats     []iptables.Stat
}

IPTStats .

type IPTables

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

IPTables takes care of managing iptables rules for tracking per client bandwidth usage.

func NewIPTables

func NewIPTables(chain string, netif string) (*IPTables, error)

func (*IPTables) ClearChain

func (i *IPTables) ClearChain() error

ClearChain clears and

func (*IPTables) Delete

func (i *IPTables) Delete() error

Delete removes all rules related to natbwmon

func (*IPTables) Stats

func (i *IPTables) Stats() (IPTStats, error)

func (*IPTables) Update

func (i *IPTables) Update(arps arp.Entries) error

Update updates natbw rules according to the system arp list

type Monitor added in v1.1.8

type Monitor struct {
	Clients  *Clients
	IPTables *IPTables
}

Monitor .

type Subflow added in v1.1.0

type Subflow struct {
	Source      net.IP
	Destination net.IP
	SPort       int
	DPort       int
	Bytes       uint64
	Packets     uint64
}

Jump to

Keyboard shortcuts

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