Skip to content

Commit

Permalink
avahi: add hostname suffix to mDNS service name
Browse files Browse the repository at this point in the history
The mDNS service name must be unique to each host announcing it.
  • Loading branch information
zonque committed May 8, 2023
1 parent 22fff8a commit aa87991
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/publisher/avahi/avahi.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package avahipublisher

import (
"fmt"
"strings"

dbus "github.com/godbus/dbus/v5"
"github.com/holoplot/go-avahi"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit aa87991

Please sign in to comment.