Skip to content

Commit

Permalink
Add IPv6 support to WebRTC #721
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Oct 30, 2023
1 parent 6a9ae93 commit b4ed738
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/webrtc/api.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package webrtc

import (
"net"
"strings"

"github.com/pion/ice/v2"
"github.com/pion/interceptor"
"github.com/pion/webrtc/v3"
"net"
"strings"
)

// ReceiveMTU = Ethernet MTU (1500) - IP Header (20) - UDP Header (8)
Expand Down Expand Up @@ -40,6 +41,7 @@ func NewAPI(address string) (*webrtc.API, error) {
// UDP6 may have problems with DNS resolving for STUN servers
s.SetNetworkTypes([]webrtc.NetworkType{
webrtc.NetworkTypeUDP4, webrtc.NetworkTypeTCP4,
webrtc.NetworkTypeUDP6, webrtc.NetworkTypeTCP6,
})

// fix https://github.com/pion/webrtc/pull/2407
Expand All @@ -50,13 +52,13 @@ func NewAPI(address string) (*webrtc.API, error) {
if address != "" {
address, network, _ := strings.Cut(address, "/")
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)
s.SetICEUDPMux(udpMux)
}
}
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)
s.SetICETCPMux(tcpMux)
}
Expand Down

0 comments on commit b4ed738

Please sign in to comment.