dnssdbrowser

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package dnssdbrowser provides a DNS-SD browser.

Index

Constants

This section is empty.

Variables

View Source
var MULTICAST_ADDR = netip.AddrPortFrom(netip.AddrFrom4([...]byte{224, 0, 0, 251}), 5353)

Functions

This section is empty.

Types

type Browser

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

Browser represents a DNS-SD browser.

func NewBrowser

func NewBrowser() *Browser

NewBrowser creates a new DNS-SD browser.

func (*Browser) FullSubscribe

func (b *Browser) FullSubscribe(serviceName string) *FullSubscription

FullSubscribe subscribes to a complete view of the service. The stream will always start with the current state of the service.

func (*Browser) Listen

func (b *Browser) Listen(socket *net.UDPConn)

Listen listens for DNS-SD packets on the given socket. The socket will be closed when the function returns.

func (*Browser) Services

func (b *Browser) Services(name string) []Service

Services returns the currently known services for the given service name.

func (*Browser) SetLogger

func (b *Browser) SetLogger(log *zap.Logger) *Browser

SetLogger sets the logger.

func (*Browser) Subscribe

func (b *Browser) Subscribe(serviceName string) *Subscription

Subscribe subscribes to a service.

type Change

type Change struct {
	Type    ChangeType
	Service Service
}

Change represents a change to a service.

type ChangeType

type ChangeType int

ChangeType represents the type of change to a service.

const (
	Added ChangeType = iota
	Removed
	Updated
)

type FullSubscription

type FullSubscription struct {
	Stream <-chan []Service
	// contains filtered or unexported fields
}

FullSubscription represents a subscription to a service.

func (*FullSubscription) Close

func (s *FullSubscription) Close()

Close closes the subscription.

type Service

type Service struct {
	// Instance name e.g. MacBouk Pro._http._tcp.local.
	// Note that it is a fully qualified domain name (FQDN), so it includes a trailing period.
	InstanceName string

	// Service name e.g. _http._tcp.local.
	// Note that it is a fully qualified domain name (FQDN), so it includes a trailing period.
	ServiceName string

	// Hostname e.g. MacBouk-Pro.local.
	// Note that it is a fully qualified domain name (FQDN), so it includes a trailing period.
	Hostname string

	// Port
	Port uint16

	// Resolved addresses for hostname
	Addresses []netip.Addr

	// TXT record
	Metadata map[string]*string
}

Service represents a service instance.

func (*Service) UserFriendlyName

func (s *Service) UserFriendlyName() string

UserFriendlyName returns a user friendly name for the service.

type Subscription

type Subscription struct {
	Stream <-chan Change
	// contains filtered or unexported fields
}

Subscription represents a subscription to a service.

func (*Subscription) Close

func (s *Subscription) Close()

Close closes the subscription.

Jump to

Keyboard shortcuts

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