mdns

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mdns wraps github.com/grandcat/zeroconf to advertise and discover Omaclip instances on the local network.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDiscoverableIPs   = fmt.Errorf("mdns: no discoverable IPs, skipping registering to the network")
	ErrInterfaceNotFound   = fmt.Errorf("mdns: requested network interface not found")
	ErrServiceRegistration = fmt.Errorf("mdns: failed to register service")
)

Functions

This section is empty.

Types

type Discoverer

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

Discoverer registers this instance via mDNS and continuously browses for peers.

func New

func New(
	log *slog.Logger,
	browsePeriod time.Duration,
	hostname string,
	ps *passphrase.Store,
	ifaceName string,
) (*Discoverer, error)

New creates a Discoverer. Call Register then Start to begin advertising and browsing. If ifaceName is non-empty, mDNS will bind to that network interface only.

func (*Discoverer) Peers

func (d *Discoverer) Peers() []Peer

Peers returns a snapshot of currently known peers.

func (*Discoverer) Register

func (d *Discoverer) Register(port int) error

Register advertises this Omaclip instance at the given port via mDNS.

func (*Discoverer) Shutdown

func (d *Discoverer) Shutdown()

Shutdown tears down the mDNS server.

func (*Discoverer) Start

func (d *Discoverer) Start(ctx context.Context)

Start begins the periodic browse loop until ctx is cancelled.

type Peer

type Peer struct {
	Name string `json:"name"`
	Addr string `json:"addr"`
	Port int    `json:"port"`
}

Peer describes a discovered remote Omaclip instance.

Jump to

Keyboard shortcuts

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