zeroconf

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: GPL-3.0 Imports: 17 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddUserResponse

type AddUserResponse struct {
	Status       int    `json:"status"`
	StatusString string `json:"statusString"`
	SpotifyError int    `json:"spotifyError"`
}

type AvahiRegistrar added in v0.7.0

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

AvahiRegistrar implements ServiceRegistrar using avahi-daemon via D-Bus. This allows go-librespot to share the mDNS responder with other services on the system instead of running its own.

It follows the recommended avahi client pattern of watching for state changes: service name collisions are resolved by picking an alternative name, and host name changes (e.g. caused by a host name collision on the network) cause the service to be transparently re-published once the daemon settles. See the canonical avahi example client-publish-service.c.

Compatibility: Requires avahi-daemon 0.6.x or later (uses stable D-Bus API). Tested with avahi 0.7 and 0.8.

func NewAvahiRegistrar added in v0.7.0

func NewAvahiRegistrar(log librespot.Logger) (*AvahiRegistrar, error)

NewAvahiRegistrar creates a new avahi-daemon service registrar. It connects to the system D-Bus and prepares to register services via avahi.

func (*AvahiRegistrar) Register added in v0.7.0

func (a *AvahiRegistrar) Register(name, serviceType, domain string, port int, txt []string) error

Register publishes the service via avahi-daemon.

func (*AvahiRegistrar) Shutdown added in v0.7.0

func (a *AvahiRegistrar) Shutdown()

Shutdown removes the service from avahi and releases resources.

func (*AvahiRegistrar) UpdateName added in v0.7.3

func (a *AvahiRegistrar) UpdateName(name string) error

UpdateName updates the advertised instance service name.

func (*AvahiRegistrar) Version added in v0.7.0

func (a *AvahiRegistrar) Version() string

Version returns the avahi-daemon version string.

type BuiltinRegistrar added in v0.7.0

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

BuiltinRegistrar implements ServiceRegistrar using the grandcat/zeroconf library, which provides a pure-Go mDNS responder.

func NewBuiltinRegistrar added in v0.7.0

func NewBuiltinRegistrar(ifaces []net.Interface) *BuiltinRegistrar

NewBuiltinRegistrar creates a new built-in mDNS service registrar. If ifaces is empty, the service will be advertised on all interfaces.

func (*BuiltinRegistrar) Register added in v0.7.0

func (b *BuiltinRegistrar) Register(name, serviceType, domain string, port int, txt []string) error

Register publishes the service using the built-in mDNS responder.

func (*BuiltinRegistrar) Shutdown added in v0.7.0

func (b *BuiltinRegistrar) Shutdown()

Shutdown stops the mDNS responder.

func (*BuiltinRegistrar) UpdateName added in v0.7.3

func (b *BuiltinRegistrar) UpdateName(name string) error

type GetInfoResponse

type GetInfoResponse struct {
	Status           int    `json:"status"`
	StatusString     string `json:"statusString"`
	SpotifyError     int    `json:"spotifyError"`
	Version          string `json:"version"`
	LibraryVersion   string `json:"libraryVersion"`
	AccountReq       string `json:"accountReq"`
	BrandDisplayName string `json:"brandDisplayName"`
	ModelDisplayName string `json:"modelDisplayName"`
	VoiceSupport     string `json:"voiceSupport"`
	Availability     string `json:"availability"`
	ProductID        int    `json:"productID"`
	TokenType        string `json:"tokenType"`
	GroupStatus      string `json:"groupStatus"`
	ResolverVersion  string `json:"resolverVersion"`
	Scope            string `json:"scope"`
	DeviceID         string `json:"deviceID"`
	RemoteName       string `json:"remoteName"`
	PublicKey        string `json:"publicKey"`
	DeviceType       string `json:"deviceType"`
	ActiveUser       string `json:"activeUser"`
}

type HandleNewRequestFunc

type HandleNewRequestFunc func(req NewUserRequest) bool

type NewUserRequest

type NewUserRequest struct {
	Username   string
	AuthBlob   []byte
	DeviceName string
	// contains filtered or unexported fields
}

type ServiceRegistrar added in v0.7.0

type ServiceRegistrar interface {
	// Register publishes the service via mDNS.
	// name: service instance name (e.g., "go-librespot")
	// serviceType: service type (e.g., "_spotify-connect._tcp")
	// domain: domain to register in (e.g., "local.")
	// port: TCP port the service is listening on
	// txt: TXT record key=value pairs
	Register(name, serviceType, domain string, port int, txt []string) error

	// UpdateName updates teh service instance name.
	UpdateName(name string) error

	// Shutdown stops advertising the service and releases resources.
	Shutdown()
}

ServiceRegistrar handles mDNS service registration. Implementations can use different backends like built-in mDNS or avahi-daemon.

type Zeroconf

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

func NewZeroconf

func NewZeroconf(log librespot.Logger, port int, deviceName, deviceId string, deviceType devicespb.DeviceType, interfacesToAdvertise []string, useAvahi bool) (_ *Zeroconf, err error)

func (*Zeroconf) Close

func (z *Zeroconf) Close()

Close stops the zeroconf responder and HTTP listener, but does not close the last opened session.

func (*Zeroconf) Serve

func (z *Zeroconf) Serve(handler HandleNewRequestFunc) error

func (*Zeroconf) SetCurrentUser

func (z *Zeroconf) SetCurrentUser(username string)

func (*Zeroconf) SetDeviceName added in v0.7.3

func (z *Zeroconf) SetDeviceName(name string)

Jump to

Keyboard shortcuts

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