discovery

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package discovery advertises the server over mDNS (DNS-SD): a _bubbles._tcp service instance on the HTTPS port plus A/AAAA records for <mdns-name>.local on the ranked LAN interfaces.

Index

Constants

View Source
const ServiceType = "_bubbles._tcp"

ServiceType is the DNS-SD service type browsed by the SDK and the tray.

View Source
const TXTVersion = "1"

TXTVersion is the value of the "v" TXT key.

Variables

This section is empty.

Functions

func Fingerprint16

func Fingerprint16(der []byte) string

Fingerprint16 returns the first 16 lowercase hex digits of the SHA-256 of the CA certificate DER, or "" when der is empty (bring-your-own TLS).

func LANIfaces

func LANIfaces() []string

LANIfaces returns the names of interfaces carrying ranked private LAN addresses.

func TXT

func TXT(fp string, onboardPort int) map[string]string

TXT builds the TXT record map: v=1, fp=<16 hex>, onboard=<http port>, path=/.

Types

type Advertiser

type Advertiser struct {
	// contains filtered or unexported fields
}

Advertiser owns one mDNS responder.

func New

func New(opts Options) *Advertiser

New returns an idle Advertiser.

func (*Advertiser) Close

func (a *Advertiser) Close()

Close stops responding and waits for the responder to exit.

func (*Advertiser) Names

func (a *Advertiser) Names() (host, instance string)

Names returns the host and instance names actually in use after probing.

func (*Advertiser) Refresh

func (a *Advertiser) Refresh()

Refresh re-announces the TXT record with the current CA fingerprint. Call it when the CA changes (restore, factory reset).

func (*Advertiser) Start

func (a *Advertiser) Start(ctx context.Context) error

Start probes for unique names, then announces the service until ctx is cancelled or Close is called. It blocks for the probe only; responding continues in the background. A name conflict renames the instance or host (dnssd appends -2) and calls OnRename.

type Options

type Options struct {
	// Instance is the service instance name (the instance name setting).
	Instance string
	// Host is the single-label mDNS host name; <Host>.local is published.
	Host string
	// HTTPSPort and HTTPPort are the bound listener ports.
	HTTPSPort, HTTPPort int
	// CADER returns the current CA certificate DER; nil or empty omits fp.
	CADER func() []byte
	// Ifaces returns the interface names to publish on; nil means the ranked
	// LAN interfaces. An empty result lets dnssd use every multicast interface.
	Ifaces func() []string
	// OnRename is called when probing had to rename the host or instance
	// (name conflict). The composition root triggers a TLS SAN refresh.
	OnRename func()
	// Logger receives diagnostics; nil discards.
	Logger *slog.Logger
}

Options configures an Advertiser.

Jump to

Keyboard shortcuts

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