From a72844663f279caa422e97ae760509d8916bc708 Mon Sep 17 00:00:00 2001 From: Aleks Todorov Date: Fri, 22 Dec 2023 11:08:01 +0000 Subject: [PATCH] Allow using mDNS candidates with UDP multiplexing --- gather.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gather.go b/gather.go index f39b55e..c2bf40b 100644 --- a/gather.go +++ b/gather.go @@ -266,7 +266,9 @@ func (a *Agent) gatherCandidatesLocalUDPMux(ctx context.Context) error { //nolin return errInvalidAddress } candidateIP := udpAddr.IP - if a.extIPMapper != nil && a.extIPMapper.candidateType == CandidateTypeHost { + if a.mDNSMode != MulticastDNSModeQueryAndGather && + a.extIPMapper != nil && + a.extIPMapper.candidateType == CandidateTypeHost { mappedIP, err := a.extIPMapper.findExternalIP(candidateIP.String()) if err != nil { a.log.Warnf("1:1 NAT mapping is enabled but no external IP is found for %s", candidateIP.String()) @@ -276,9 +278,16 @@ func (a *Agent) gatherCandidatesLocalUDPMux(ctx context.Context) error { //nolin candidateIP = mappedIP } + var address string + if a.mDNSMode == MulticastDNSModeQueryAndGather { + address = a.mDNSName + } else { + address = candidateIP.String() + } + hostConfig := CandidateHostConfig{ Network: udp, - Address: candidateIP.String(), + Address: address, Port: udpAddr.Port, Component: ComponentRTP, }