discovery

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package discovery provides LAN discovery of OpenDeezer instances so a client can offer a "play on another device" picker (OpenDeezer Connect). Each instance with the control API enabled runs a small UDP responder advertising its display name + control port; a client multicasts a probe and collects replies.

Transport: IPv4 UDP multicast (group 239.255.42.99, port 7655) with a limited broadcast as a fallback for networks that filter multicast. The responder binds with SO_REUSEADDR/SO_REUSEPORT so several instances on ONE machine can all listen + answer.

Security: the responder answers only the exact probe magic, only to private/loopback/link-local sources (no internet reflection), with a tiny fixed payload (no amplification), and never carries the same-account credential (the Deezer user id) — only the display name + client + version.

Index

Constants

View Source
const (
	// Port is the UDP port the responder listens on.
	Port = 7655
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Name    string `json:"name"`    // account display name (not the user id)
	Addr    string `json:"addr"`    // control API host:port
	Client  string `json:"client"`  // client/platform id (tui, macos, …)
	Version string `json:"version"` // OpenDeezer version
}

Device is a discovered OpenDeezer instance.

func Discover

func Discover(timeout time.Duration, selfPort int) ([]Device, error)

Discover multicasts a probe (with a broadcast fallback) and collects replies for the given timeout. selfPort is this instance's own control port (0 if none): replies from a local address with that port are our own responder and are filtered out, so we never list ourselves. Other instances on the same host use a different control port and are kept.

type Info

type Info struct {
	Name    string
	Client  string
	Version string
}

Info is the advertised identity (read per request, so re-login is reflected).

type Responder

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

Responder advertises this instance until Close.

func Advertise(info func() Info, controlPort int) (*Responder, error)

Advertise starts the discovery responder on UDP :Port (reuse-port so multiple instances on one host coexist) and joins the multicast group on every capable interface. info supplies the current identity; controlPort is the control API TCP port controllers should connect to.

func (*Responder) Close

func (r *Responder) Close()

Close stops the responder.

Jump to

Keyboard shortcuts

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