Documentation
¶
Overview ¶
Package mdns advertises and browses DNS-SD services over multicast DNS (RFC 6762, RFC 6763), over IPv4, as Linked Instances find each other on the LAN (ADR 0027).
Port 5353 is also the default port of the dns Service, which Host mode's DNS forwarding sends to, and an mDNS daemon (avahi-daemon, mDNSResponder, Windows' DNS Client) usually holds it on the wildcard address. Neither side takes it from the other:
- A Responder binds the mDNS group address itself (the wildcard on Windows, which cannot bind a multicast address), with SO_REUSEADDR and SO_REUSEPORT, so it shares multicast queries with the daemon and never receives unicast datagrams meant for the dns Service's specific address. Its host name is its own (gcpemu-…), never the machine's, which the daemon answers for.
- Browse is a one-shot querier (RFC 6762 §5.1): it queries from an ephemeral port, and responders answer it by unicast to that port, so browsing binds nothing on 5353.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Port = 5353 Group = net.IPv4(224, 0, 0, 251) )
Port is the mDNS port, and Group the IPv4 group address.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
// Instance is its label, and Host the name its SRV record targets.
Instance string
Host string
Port int
Addrs []net.IP
// TXT maps its TXT record's keys, lowercased, to their values.
TXT map[string]string
}
Entry is a browsed service instance.
type Options ¶
type Options struct {
// Port zero means Port.
Port int
// Wait is how long Browse collects answers; zero means a second, or
// until its context is done if that is sooner.
Wait time.Duration
Log *slog.Logger
}
Options configure Advertise and Browse.
type Responder ¶
type Responder struct {
// contains filtered or unexported fields
}
Responder answers mDNS queries for a Service until Close.
type Service ¶
type Service struct {
// Instance is the instance's label, e.g. "default@office".
Instance string
// Type is the service type, e.g. "_gcpemu._tcp".
Type string
// Host is the label of the host name the service's addresses are
// published under, in .local; it must not be the machine's own.
Host string
Port int
// Addrs are the addresses to advertise. An unspecified one stands for
// every address of every multicast-capable interface.
Addrs []net.IP
// TXT holds the TXT record's strings, "key=value".
TXT []string
}
Service is a DNS-SD service instance to advertise.