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