From aa879916324b71a8387543de9c71e6988a833f46 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 8 May 2023 17:08:19 +0200 Subject: [PATCH] avahi: add hostname suffix to mDNS service name The mDNS service name must be unique to each host announcing it. --- pkg/publisher/avahi/avahi.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/publisher/avahi/avahi.go b/pkg/publisher/avahi/avahi.go index c53e73d..40787c0 100644 --- a/pkg/publisher/avahi/avahi.go +++ b/pkg/publisher/avahi/avahi.go @@ -5,6 +5,7 @@ package avahipublisher import ( "fmt" + "strings" dbus "github.com/godbus/dbus/v5" "github.com/holoplot/go-avahi" @@ -38,7 +39,9 @@ func (a *AvahiPublisher) Publish(serviceName, serviceType, txt string, port int) txtBytes = [][]byte{[]byte(txt)} } - if err := eg.AddService(avahi.InterfaceUnspec, avahi.ProtoUnspec, 0, serviceName, + localName := strings.Join([]string{serviceName, "on", a.hostnameFqdn}, " ") + + if err := eg.AddService(avahi.InterfaceUnspec, avahi.ProtoUnspec, 0, localName, serviceType, "local", a.hostnameFqdn, uint16(port), txtBytes); err != nil { return nil, fmt.Errorf("AddService() failed: %w", err) }