Properly exclude mDNS when not trickling also. (#2956)
This commit is contained in:
+10
-13
@@ -706,19 +706,6 @@ func (t *PCTransport) SetPreferTCP(preferTCP bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *PCTransport) AddICECandidate(candidate webrtc.ICECandidateInit) {
|
func (t *PCTransport) AddICECandidate(candidate webrtc.ICECandidateInit) {
|
||||||
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)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
t.postEvent(event{
|
t.postEvent(event{
|
||||||
signal: signalRemoteICECandidate,
|
signal: signalRemoteICECandidate,
|
||||||
data: &candidate,
|
data: &candidate,
|
||||||
@@ -1395,6 +1382,11 @@ func (t *PCTransport) handleRemoteICECandidate(e event) error {
|
|||||||
filtered = true
|
filtered = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !t.params.Config.UseMDNS && types.IsCandidateMDNS(*c) {
|
||||||
|
t.params.Logger.Debugw("ignoring mDNS candidate", "candidate", c.Candidate)
|
||||||
|
filtered = true
|
||||||
|
}
|
||||||
|
|
||||||
t.connectionDetails.AddRemoteCandidate(*c, filtered, true)
|
t.connectionDetails.AddRemoteCandidate(*c, filtered, true)
|
||||||
if filtered {
|
if filtered {
|
||||||
return nil
|
return nil
|
||||||
@@ -1440,6 +1432,11 @@ func (t *PCTransport) filterCandidates(sd webrtc.SessionDescription, preferTCP,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
excluded := preferTCP && !c.NetworkType().IsTCP()
|
excluded := preferTCP && !c.NetworkType().IsTCP()
|
||||||
|
if !excluded {
|
||||||
|
if !t.params.Config.UseMDNS && types.IsICECandidateMDNS(c) {
|
||||||
|
excluded = true
|
||||||
|
}
|
||||||
|
}
|
||||||
if !excluded {
|
if !excluded {
|
||||||
filteredAttrs = append(filteredAttrs, a)
|
filteredAttrs = append(filteredAttrs, a)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,6 +224,8 @@ func (d *ICEConnectionDetails) SetSelectedPair(pair *webrtc.ICECandidatePair) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
|
||||||
func isCandidateEqualTo(c1, c2 *webrtc.ICECandidate) bool {
|
func isCandidateEqualTo(c1, c2 *webrtc.ICECandidate) bool {
|
||||||
if c1 == nil && c2 == nil {
|
if c1 == nil && c2 == nil {
|
||||||
return true
|
return true
|
||||||
@@ -332,3 +334,16 @@ func unmarshalCandidate(i ice.Candidate) (*webrtc.ICECandidate, error) {
|
|||||||
|
|
||||||
return &c, nil
|
return &c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsCandidateMDNS(candidate webrtc.ICECandidateInit) bool {
|
||||||
|
c, err := unmarshalICECandidate(candidate)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return IsICECandidateMDNS(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsICECandidateMDNS(candidate ice.Candidate) bool {
|
||||||
|
return strings.HasSuffix(candidate.Address(), ".local")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user