mdns

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 9 Imported by: 0 modules, 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 Config

type Config struct {
	// ServiceName is the mDNS service name (e.g., "dirio-s3")
	ServiceName string

	// Port is the S3 data-plane HTTP port number
	Port int

	// AdminPort is the admin/console control-plane port (dual-port mode).
	// When non-zero and different from Port, additional mDNS service records
	// are registered for the admin control plane on this port.
	AdminPort int

	// HTTPSPort is the HTTPS port (optional)
	HTTPSPort int

	// TXTRecords are additional TXT records for service discovery
	TXTRecords map[string]string
}

Config holds configuration for mDNS service registration.

type Service

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

Service represents an mDNS service registration for DirIO.

The service uses a unique hostname format: <service-name>-<unique-id>.local This prevents conflicts with system mDNS responders (Bonjour/Avahi) and allows us to safely run our own mDNS responder on all platforms.

func New

func New(cfg *Config) (*Service, error)

New creates a new mDNS service but does not start it.

func (*Service) GetAdvertisedHost

func (s *Service) GetAdvertisedHost() string

GetAdvertisedHost returns the hostname being advertised via mDNS. Format: <service-name>-<unique-id>.local (e.g., "dirio-s3-abc123.local")

func (*Service) IsRunning

func (s *Service) IsRunning() bool

IsRunning returns true if the mDNS service is currently running.

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start begins advertising the mDNS service on the local network.

The service uses a unique hostname format: <service-name>-<unique-id>.local (e.g., "dirio-s3-abc123.local") which prevents conflicts with system mDNS responders.

Service discovery records (_http._tcp, _s3._tcp) point to this unique hostname, allowing clients to discover and connect to the service.

ctx controls the lifetime of the service: if the context is cancelled before Stop is called the responder loop exits, though Stop should still be called explicitly to send mDNS goodbye packets before the process exits.

func (*Service) Stop

func (s *Service) Stop() error

Stop gracefully shuts down the mDNS service. This removes all service records (sending goodbye packets) before stopping the responder.

Jump to

Keyboard shortcuts

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