mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-20 02:00:05 -08:00
webrtc: solve domains in webrtcAdditionalHosts on server-side (#4817) (#4866)
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
This commit is contained in:
parent
b627128d0f
commit
c80220eb7c
1 changed files with 52 additions and 35 deletions
|
|
@ -491,48 +491,65 @@ func (co *PeerConnection) addAdditionalCandidates(firstMedia *sdp.MediaDescripti
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, host := range co.AdditionalHosts {
|
for _, host := range co.AdditionalHosts {
|
||||||
newAttrs := append([]sdp.Attribute(nil), firstMedia.Attributes[:i]...)
|
var ips []string
|
||||||
|
if net.ParseIP(host) != nil {
|
||||||
if co.ICEUDPMux != nil {
|
ips = []string{host}
|
||||||
port := strconv.FormatInt(int64(co.ICEUDPMux.GetListenAddresses()[0].(*net.UDPAddr).Port), 10)
|
} else {
|
||||||
|
tmp, err := net.LookupIP(host)
|
||||||
tmp, err := randUint32()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
id := strconv.FormatInt(int64(tmp), 10)
|
|
||||||
|
|
||||||
newAttrs = append(newAttrs, sdp.Attribute{
|
ips = make([]string, len(tmp))
|
||||||
Key: "candidate",
|
for i, e := range tmp {
|
||||||
Value: id + " 1 udp 2130706431 " + host + " " + port + " typ host",
|
ips[i] = e.String()
|
||||||
})
|
|
||||||
newAttrs = append(newAttrs, sdp.Attribute{
|
|
||||||
Key: "candidate",
|
|
||||||
Value: id + " 2 udp 2130706431 " + host + " " + port + " typ host",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if co.ICETCPMux != nil {
|
|
||||||
port := strconv.FormatInt(int64(co.ICETCPMux.Ln.Addr().(*net.TCPAddr).Port), 10)
|
|
||||||
|
|
||||||
tmp, err := randUint32()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
id := strconv.FormatInt(int64(tmp), 10)
|
|
||||||
|
|
||||||
newAttrs = append(newAttrs, sdp.Attribute{
|
|
||||||
Key: "candidate",
|
|
||||||
Value: id + " 1 tcp 1671430143 " + host + " " + port + " typ host tcptype passive",
|
|
||||||
})
|
|
||||||
newAttrs = append(newAttrs, sdp.Attribute{
|
|
||||||
Key: "candidate",
|
|
||||||
Value: id + " 2 tcp 1671430143 " + host + " " + port + " typ host tcptype passive",
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newAttrs = append(newAttrs, firstMedia.Attributes[i:]...)
|
for _, ip := range ips {
|
||||||
firstMedia.Attributes = newAttrs
|
newAttrs := append([]sdp.Attribute(nil), firstMedia.Attributes[:i]...)
|
||||||
|
|
||||||
|
if co.ICEUDPMux != nil {
|
||||||
|
port := strconv.FormatInt(int64(co.ICEUDPMux.GetListenAddresses()[0].(*net.UDPAddr).Port), 10)
|
||||||
|
|
||||||
|
tmp, err := randUint32()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
id := strconv.FormatInt(int64(tmp), 10)
|
||||||
|
|
||||||
|
newAttrs = append(newAttrs, sdp.Attribute{
|
||||||
|
Key: "candidate",
|
||||||
|
Value: id + " 1 udp 2130706431 " + ip + " " + port + " typ host",
|
||||||
|
})
|
||||||
|
newAttrs = append(newAttrs, sdp.Attribute{
|
||||||
|
Key: "candidate",
|
||||||
|
Value: id + " 2 udp 2130706431 " + ip + " " + port + " typ host",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if co.ICETCPMux != nil {
|
||||||
|
port := strconv.FormatInt(int64(co.ICETCPMux.Ln.Addr().(*net.TCPAddr).Port), 10)
|
||||||
|
|
||||||
|
tmp, err := randUint32()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
id := strconv.FormatInt(int64(tmp), 10)
|
||||||
|
|
||||||
|
newAttrs = append(newAttrs, sdp.Attribute{
|
||||||
|
Key: "candidate",
|
||||||
|
Value: id + " 1 tcp 1671430143 " + ip + " " + port + " typ host tcptype passive",
|
||||||
|
})
|
||||||
|
newAttrs = append(newAttrs, sdp.Attribute{
|
||||||
|
Key: "candidate",
|
||||||
|
Value: id + " 2 tcp 1671430143 " + ip + " " + port + " typ host tcptype passive",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
newAttrs = append(newAttrs, firstMedia.Attributes[i:]...)
|
||||||
|
firstMedia.Attributes = newAttrs
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue