hostinfo

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package hostinfo can be used to correlate IPs, MACs and hostnames using caches DNS lookups and ARP information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	DNSTimeout time.Duration

	sync.Mutex
	// contains filtered or unexported fields
}

Cache caches information such as IPv4 addresses, MAC vendors and hostnames.

func NewCache

func NewCache() *Cache

NewCache returns a new HostInfoCache and parses the embedded MAC vendors file.

func (*Cache) AddHostnamesForIP

func (c *Cache) AddHostnamesForIP(ip net.IP, hostnames []string)

AddHostnamesForIP registers a set of hostnames for a given IP that were obtained externally. Hostnames are only added if they are not already present.

func (*Cache) HostInfos

func (c *Cache) HostInfos(ip net.IP) []string

HostInfos returns the string representations of all available infos for the host.

func (*Cache) Hostnames

func (c *Cache) Hostnames(ip net.IP) []string

Hostnames returns all known hostnames associated with the given IP.

func (*Cache) SaveMACFromIP

func (c *Cache) SaveMACFromIP(ip net.IP, fallback net.HardwareAddr)

SaveMACFromIP saves the MAC address extracted from the IP together with the IP in the cache. If the IP did not contain an EUI-64 encoded MAC address a MAC address with the first three bytes of the provided fallback address is saved in order to be able to identify the vendor.

Jump to

Keyboard shortcuts

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