dnssd

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 12 Imported by: 1 module, 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 dnssd browses DNS-SD services through Avahi's D-Bus API on the system bus, with no mDNS library: a browser per service type reports the services that come and go, each resolved to its host, port and TXT record.

Index

Constants

View Source
const (
	BusName      = "org.freedesktop.Avahi"
	ServerIface  = BusName + ".Server"
	BrowserIface = BusName + ".ServiceBrowser"
)

Avahi's names.

Variables

View Source
var ErrNoAvahi = errors.New("dnssd: no Avahi on the system bus")

ErrNoAvahi is a system bus without Avahi on it.

Functions

This section is empty.

Types

type Browser

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

Browser is a browse running: Stop frees its Avahi browsers.

func (*Browser) Stop

func (b *Browser) Stop() error

Stop frees the browsers and waits for the last service handed over; a browser Avahi would not free is the error.

type Client

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

Client is an Avahi client on a system bus connection the caller owns.

func New

func New(conn *dbus.Conn) *Client

New is a client on conn.

func (*Client) Browse

func (c *Client) Browse(ctx context.Context, types []string, found func(Service), removed func(key string)) (*Browser, error)

Browse browses types, calling found with each service resolved and removed with the key of each that went, from one goroutine, until Stop. Without Avahi on the bus it is ErrNoAvahi.

type Service

type Service struct {
	Name, Type, Domain string
	Host               string
	Address            netip.Addr
	Port               uint16
	TXT                map[string]string
}

Service is one resolved service: its instance name, type and domain, its host name, the address it is reached at (with its interface as the zone where link-local) and port, and its TXT record by key.

func (Service) Key

func (s Service) Key() string

Key identifies a service instance across its announcements.

Directories

Path Synopsis
Package dnssdtest is a fake Avahi on a private bus: the services a test announces are reported to every browser of their type, once per address, on the interface and protocol the address names, and resolve to what the test set; the browsers made and freed are counted.
Package dnssdtest is a fake Avahi on a private bus: the services a test announces are reported to every browser of their type, once per address, on the interface and protocol the address names, and resolve to what the test set; the browsers made and freed are counted.

Jump to

Keyboard shortcuts

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