Filter mdns candidate if not mdns not enabled (#1393)
* Filter mdns candidate if not mdns not enabled * log target
This commit is contained in:
@@ -37,6 +37,7 @@ type WebRTCConfig struct {
|
|||||||
Publisher DirectionConfig
|
Publisher DirectionConfig
|
||||||
Subscriber DirectionConfig
|
Subscriber DirectionConfig
|
||||||
NAT1To1IPs []string
|
NAT1To1IPs []string
|
||||||
|
UseMDNS bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReceiverConfig struct {
|
type ReceiverConfig struct {
|
||||||
@@ -265,6 +266,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
|
|||||||
Publisher: publisherConfig,
|
Publisher: publisherConfig,
|
||||||
Subscriber: subscriberConfig,
|
Subscriber: subscriberConfig,
|
||||||
NAT1To1IPs: nat1to1IPs,
|
NAT1To1IPs: nat1to1IPs,
|
||||||
|
UseMDNS: rtcConf.UseMDNS,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pion/ice/v2"
|
||||||
"github.com/pion/rtcp"
|
"github.com/pion/rtcp"
|
||||||
"github.com/pion/sdp/v3"
|
"github.com/pion/sdp/v3"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
@@ -424,6 +425,19 @@ func (t *TransportManager) HandleAnswer(answer webrtc.SessionDescription) {
|
|||||||
|
|
||||||
// AddICECandidate adds candidates for remote peer
|
// AddICECandidate adds candidates for remote peer
|
||||||
func (t *TransportManager) AddICECandidate(candidate webrtc.ICECandidateInit, target livekit.SignalTarget) {
|
func (t *TransportManager) AddICECandidate(candidate webrtc.ICECandidateInit, target livekit.SignalTarget) {
|
||||||
|
if !t.params.Config.UseMDNS {
|
||||||
|
candidateValue := strings.TrimPrefix(candidate.Candidate, "candidate:")
|
||||||
|
if candidateValue != "" {
|
||||||
|
candidate, err := ice.UnmarshalCandidate(candidateValue)
|
||||||
|
if err != nil {
|
||||||
|
t.params.Logger.Errorw("failed to parse ice candidate", err)
|
||||||
|
} else if strings.HasSuffix(candidate.Address(), ".local") {
|
||||||
|
t.params.Logger.Debugw("ignoring mDNS candidate", "candidate", candidateValue, "target", target)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch target {
|
switch target {
|
||||||
case livekit.SignalTarget_PUBLISHER:
|
case livekit.SignalTarget_PUBLISHER:
|
||||||
t.publisher.AddICECandidate(candidate)
|
t.publisher.AddICECandidate(candidate)
|
||||||
|
|||||||
Reference in New Issue
Block a user