netutil

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package netutil answers the two questions the rest of the app keeps asking: "is this address on my own network?" and "who am I?".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrFromIP

func AddrFromIP(ip net.IP) (netip.Addr, bool)

AddrFromIP converts a net.IP, normalising IPv4-mapped IPv6 to plain IPv4.

Packet capture and the pcap interface list both hand back net.IP, and a 4-in-6 address left mapped would be treated as a different endpoint from the same address seen over IPv4.

func IsInternal

func IsInternal(addr netip.Addr) bool

IsInternal reports whether an address is local to this network rather than a destination out on the internet.

func IsRoutable

func IsRoutable(addr netip.Addr) bool

IsRoutable reports whether an address is a plausible external destination.

func PublicIP

func PublicIP(ctx context.Context) (netip.Addr, bool)

PublicIP discovers this network's own external address, which is the only way to place the map's origin, nothing observable from inside the network says where it is.

The DNS route is tried first and deliberately: a TXT query to a resolver that answers with the querier's address discloses nothing that sending the query did not already disclose. The HTTPS fallback exists for networks that block or intercept external resolvers.

This is the only outbound request LAN Sheriff makes about *you* rather than about a dataset, and it can be switched off entirely (--no-locate), in which case arcs are drawn from a neutral origin.

Types

type Self

type Self struct {
	DeviceID string
	Hostname string
	IP       string
	MAC      string
	Subnets  []netip.Prefix
}

Self describes this host.

func Local

func Local() Self

Local returns this host's identity, computed once per process.

func (Self) Device

func (s Self) Device() types.Device

func (Self) Sighting

func (s Self) Sighting() types.Sighting

Device renders this host as a Device record. Sighting describes this machine in the form the store's identity model takes.

PreferredID carries the ID derived from the local hardware address, because the capture sources tag flows with it before the database is open: the record discovery converges on has to be the same one those flows point at.

Jump to

Keyboard shortcuts

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