discovery

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package discovery publishes the local Warren Host as a DNS-SD service.

Index

Constants

View Source
const (
	ServiceType   = "_warren._tcp"
	ServiceDomain = "local."
	TXTVersion    = "1"
)

Variables

This section is empty.

Functions

func FilterForListener

func FilterForListener(candidates []net.IP, listenerAddress string) []net.IP

FilterForListener keeps only addresses that the HTTP listener can actually serve. An unspecified listener accepts every local interface; a loopback or specifically bound listener must not advertise unreachable candidates.

func LocalAddresses

func LocalAddresses() ([]net.IP, error)

LocalAddresses returns addresses suitable for a LAN advertisement. It excludes loopback, point-to-point, link-local, unspecified, multicast, and interface-down addresses.

func Start

func Start(config Config) (func() error, error)

Start starts a DNS-SD responder for the Warren Host. The returned shutdown function is idempotent from the underlying responder's perspective and must be called when the HTTP listener stops.

Types

type Advertisement struct {
	InstanceName string
	HostName     string
	Port         int
	IPs          []net.IP
	TXT          []string
}

Advertisement contains the normalized values used to register a Host. Keeping this separate from mdns.MDNSService makes metadata testable without opening a multicast socket.

func BuildAdvertisement

func BuildAdvertisement(config Config) (Advertisement, error)

BuildAdvertisement validates and normalizes a Host advertisement.

type Config

type Config struct {
	HostID      string
	HostName    string
	DNSHostName string
	Protocol    string
	Build       string
	Port        int
	TLS         bool
	PairingOpen bool
	// PairingOpenFunc optionally supplies the live state of the explicit Host
	// pairing window. When absent, PairingOpen is used as a static value.
	PairingOpenFunc func() bool
	Candidates      []net.IP
	InstanceName    string
}

Config describes the public, non-secret part of a Warren Host advertisement. Authentication credentials and private filesystem paths are deliberately absent from this type.

Jump to

Keyboard shortcuts

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