Add mDNS Host Candidate support

Relates to pion/webrtc#699
This commit is contained in:
Sean DuBois
2019-06-21 00:09:16 -07:00
committed by adwpc
parent acbf5671b7
commit 0116bdd649
8 changed files with 283 additions and 44 deletions

32
mdns.go Normal file
View File

@@ -0,0 +1,32 @@
package ice
import (
"crypto/rand"
"fmt"
)
// MulticastDNSMode represents the different Multicast modes ICE can run in
type MulticastDNSMode byte
// MulticastDNSMode enum
const (
// MulticastDNSModeDisabled means remote mDNS candidates will be discarded, and local host candidates will use IPs
MulticastDNSModeDisabled MulticastDNSMode = iota + 1
// MulticastDNSModeQueryOnly means remote mDNS candidates will be accepted, and local host candidates will use IPs
MulticastDNSModeQueryOnly
// MulticastDNSModeQueryAndGather means remote mDNS candidates will be accepted, and local host candidates will use mDNS
MulticastDNSModeQueryAndGather
)
func generateMulticastDNSName() (string, error) {
b := make([]byte, 16)
_, err := rand.Read(b) //nolint
if err != nil {
return "", err
}
return fmt.Sprintf("%X-%X-%X-%X-%X.local", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]), nil
}