dnsmasq

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WatchLeases

func WatchLeases(ctx context.Context, filePath string, output chan<- []*Lease) error

WatchLeases sends all read DHCP leases over `output` channel every time lease file at `filePath` gets updated. Function is blocking until context is done.

func WatchLogs

func WatchLogs(ctx context.Context, filePath string, output chan<- *Query, fn LogFn) error

WatchLogs reads dnsmasq logs from a named pipe (FIFO) and sends all completed DNS queries over output channel. Optionally pass func(string, bool) to access each incoming log line. Function is blocking until context is done.

Types

type Lease

type Lease struct {
	Expires  time.Time
	MacAddr  net.HardwareAddr
	IPAddr   netip.Addr
	Hostname string
}

Lease is the representation of DHCP lease from DNSMasq.

func ReadLeases

func ReadLeases(reader io.Reader) ([]*Lease, error)

ReadLeases reads DHCP leases from file using provided `io.Reader`.

type LogFn

type LogFn func(line string, dns bool)

LogFn defines a function executed on each log line read from dnsmasq with ability to distinguish if the line was related to DNS query.

type Query

type Query struct {
	Domain   string
	MadeBy   string
	Queried  []string
	Result   []string
	Started  time.Time
	Finished time.Time
}

Query represents DNS query served by dnsmasq.

Jump to

Keyboard shortcuts

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