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 ¶
const ServiceType = "_bubbles._tcp"
ServiceType is the DNS-SD service type browsed by the SDK and the tray.
const TXTVersion = "1"
TXTVersion is the value of the "v" TXT key.
Variables ¶
This section is empty.
Functions ¶
func Fingerprint16 ¶
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).
Types ¶
type Advertiser ¶
type Advertiser struct {
// contains filtered or unexported fields
}
Advertiser owns one mDNS responder.
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.