bootstrap

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package bootstrap maintains a live set of IPv6 source addresses resolved from a list of DNS names and/or IPv6 literals. It is intended to drive the per-control-group bootstrap source lists used for SSM joins on the beacon, manifest, and subtree-announce groups.

Resolution semantics:

  • Startup is fail-closed. Resolver.Start returns an error if no entry resolves to at least one AAAA record.
  • Subsequent refreshes are best-effort. Failures keep the last good set and increment Resolver.ResolveErrors; the active source set never spontaneously empties.
  • A diff against the previous set is delivered via the OnChange callback, suitable for issuing MCAST_JOIN_SOURCE_GROUP / MCAST_LEAVE_SOURCE_GROUP calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLookup

func DefaultLookup(ctx context.Context, name string) ([]netip.Addr, error)

DefaultLookup uses net.DefaultResolver to resolve a name to IPv6 addresses, returning only AAAA results.

Types

type LookupFunc

type LookupFunc func(ctx context.Context, name string) ([]netip.Addr, error)

LookupFunc resolves a DNS name to IPv6 addresses. The default is net.DefaultResolver.LookupNetIP filtered to IPv6. Override for tests.

type Resolver

type Resolver struct {
	// Entries is the list of DNS names and/or IPv6 literals. Required.
	Entries []string

	// Refresh is the periodic re-resolve interval. Defaults to 30s.
	Refresh time.Duration

	// Lookup resolves a DNS name to IPv6 addresses. Defaults to
	// [DefaultLookup]. Override for tests or for using a custom
	// resolver. Literal IPv6 entries bypass Lookup and are added
	// directly.
	Lookup LookupFunc

	// OnChange is invoked after every refresh that yields a different
	// set. It is called synchronously from the refresh goroutine while
	// the internal mutex is NOT held, so callbacks may issue join/leave
	// syscalls without deadlock risk. Optional.
	OnChange func(added, removed []netip.Addr)
	// contains filtered or unexported fields
}

Resolver holds the configuration and live state for one bootstrap list (e.g. one of beacon / manifest / subtreeAnnounce).

func (*Resolver) Current

func (r *Resolver) Current() []netip.Addr

Current returns a copy of the currently-resolved address set.

func (*Resolver) ResolveErrors

func (r *Resolver) ResolveErrors() uint64

ResolveErrors returns the cumulative count of failed refresh attempts. A non-zero value indicates DNS issues that did not (yet) empty the active set.

func (*Resolver) Start

func (r *Resolver) Start(ctx context.Context) error

Start performs the initial resolution synchronously and starts the periodic refresh goroutine. The goroutine exits when ctx is cancelled. Returns an error if no entry resolves to >= 1 AAAA record.

Jump to

Keyboard shortcuts

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