Fix STUN candidate in IPv6 format

This commit is contained in:
Alexey Khit
2023-01-08 15:45:11 +03:00
parent 9e9f07f3f7
commit a9d1e64f88

View File

@@ -1,6 +1,7 @@
package webrtc package webrtc
import ( import (
"errors"
"fmt" "fmt"
"github.com/AlexxIT/go2rtc/pkg/streamer" "github.com/AlexxIT/go2rtc/pkg/streamer"
"github.com/pion/ice/v2" "github.com/pion/ice/v2"
@@ -13,10 +14,11 @@ import (
) )
func NewCandidate(address string) (string, error) { func NewCandidate(address string) (string, error) {
host, port, err := net.SplitHostPort(address) i := strings.LastIndexByte(address, ':')
if err != nil { if i < 0 {
return "", err return "", errors.New("wrong candidate: " + address)
} }
host, port := address[:i], address[i+1:]
i, err := strconv.Atoi(port) i, err := strconv.Atoi(port)
if err != nil { if err != nil {