add multicast flow transmitter discovery via mdns _netaudio-chan service
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
41
mdns.go
41
mdns.go
@@ -31,6 +31,19 @@ func extractDanteName(s string) string {
|
||||
return name
|
||||
}
|
||||
|
||||
func extractDanteChanService(s string) (channel, device string) {
|
||||
idx := strings.Index(s, "._netaudio-chan.")
|
||||
if idx <= 0 {
|
||||
return "", ""
|
||||
}
|
||||
name := s[:idx]
|
||||
at := strings.Index(name, "@")
|
||||
if at <= 0 {
|
||||
return "", ""
|
||||
}
|
||||
return name[:at], name[at+1:]
|
||||
}
|
||||
|
||||
func isDanteService(s string) bool {
|
||||
return strings.Contains(s, "_netaudio-") || strings.Contains(s, "._dante")
|
||||
}
|
||||
@@ -108,6 +121,7 @@ func (t *Tendrils) processMDNSResponse(ifaceName string, srcIP net.IP, msg *dns.
|
||||
srvTargets := map[string]string{}
|
||||
danteNames := map[string]bool{}
|
||||
danteARCPorts := map[string]uint16{}
|
||||
danteTxChannels := map[string]string{} // device name -> channel names
|
||||
skaarhojNames := map[string]bool{}
|
||||
|
||||
for _, rr := range allRecords {
|
||||
@@ -143,6 +157,16 @@ func (t *Tendrils) processMDNSResponse(ifaceName string, srcIP net.IP, msg *dns.
|
||||
danteARCPorts[name] = r.Port
|
||||
}
|
||||
}
|
||||
if strings.Contains(r.Hdr.Name, "_netaudio-chan.") {
|
||||
channel, device := extractDanteChanService(r.Hdr.Name)
|
||||
if channel != "" && device != "" {
|
||||
if existing, ok := danteTxChannels[device]; ok {
|
||||
danteTxChannels[device] = existing + "," + channel
|
||||
} else {
|
||||
danteTxChannels[device] = channel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if isSkaarhojService(r.Hdr.Name) {
|
||||
name := extractSkaarhojName(r.Hdr.Name)
|
||||
@@ -171,6 +195,23 @@ func (t *Tendrils) processMDNSResponse(ifaceName string, srcIP net.IP, msg *dns.
|
||||
t.nodes.UpdateDante(name, ip, arcPort)
|
||||
}
|
||||
|
||||
for device, channels := range danteTxChannels {
|
||||
var ip net.IP
|
||||
if target, ok := srvTargets[device]; ok {
|
||||
ip = aRecords[target]
|
||||
}
|
||||
if ip == nil {
|
||||
ip = aRecords[device+".local"]
|
||||
}
|
||||
if ip == nil {
|
||||
ip = srcIP
|
||||
}
|
||||
if t.DebugMDNS {
|
||||
log.Printf("[mdns] %s: dante tx channels %s@%s (%s)", ifaceName, channels, device, ip)
|
||||
}
|
||||
t.nodes.UpdateDanteTxChannels(device, ip, channels)
|
||||
}
|
||||
|
||||
for name := range skaarhojNames {
|
||||
var ip net.IP
|
||||
if target, ok := srvTargets[name]; ok {
|
||||
|
||||
Reference in New Issue
Block a user