mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-05 16:26:50 +08:00
Add IPv6 support to WebRTC #721
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
package webrtc
|
package webrtc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/pion/ice/v2"
|
"github.com/pion/ice/v2"
|
||||||
"github.com/pion/interceptor"
|
"github.com/pion/interceptor"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
"net"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReceiveMTU = Ethernet MTU (1500) - IP Header (20) - UDP Header (8)
|
// ReceiveMTU = Ethernet MTU (1500) - IP Header (20) - UDP Header (8)
|
||||||
@@ -40,6 +41,7 @@ func NewAPI(address string) (*webrtc.API, error) {
|
|||||||
// UDP6 may have problems with DNS resolving for STUN servers
|
// UDP6 may have problems with DNS resolving for STUN servers
|
||||||
s.SetNetworkTypes([]webrtc.NetworkType{
|
s.SetNetworkTypes([]webrtc.NetworkType{
|
||||||
webrtc.NetworkTypeUDP4, webrtc.NetworkTypeTCP4,
|
webrtc.NetworkTypeUDP4, webrtc.NetworkTypeTCP4,
|
||||||
|
webrtc.NetworkTypeUDP6, webrtc.NetworkTypeTCP6,
|
||||||
})
|
})
|
||||||
|
|
||||||
// fix https://github.com/pion/webrtc/pull/2407
|
// fix https://github.com/pion/webrtc/pull/2407
|
||||||
@@ -50,13 +52,13 @@ func NewAPI(address string) (*webrtc.API, error) {
|
|||||||
if address != "" {
|
if address != "" {
|
||||||
address, network, _ := strings.Cut(address, "/")
|
address, network, _ := strings.Cut(address, "/")
|
||||||
if network == "" || network == "udp" {
|
if network == "" || network == "udp" {
|
||||||
if ln, err := net.ListenPacket("udp4", address); err == nil {
|
if ln, err := net.ListenPacket("udp", address); err == nil {
|
||||||
udpMux := webrtc.NewICEUDPMux(nil, ln)
|
udpMux := webrtc.NewICEUDPMux(nil, ln)
|
||||||
s.SetICEUDPMux(udpMux)
|
s.SetICEUDPMux(udpMux)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if network == "" || network == "tcp" {
|
if network == "" || network == "tcp" {
|
||||||
if ln, err := net.Listen("tcp4", address); err == nil {
|
if ln, err := net.Listen("tcp", address); err == nil {
|
||||||
tcpMux := webrtc.NewICETCPMux(nil, ln, 8)
|
tcpMux := webrtc.NewICETCPMux(nil, ln, 8)
|
||||||
s.SetICETCPMux(tcpMux)
|
s.SetICETCPMux(tcpMux)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user