mirror of
https://github.com/pion/ice.git
synced 2026-04-22 16:17:11 +08:00
Upgrade to turn/v5
This commit is contained in:
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/pion/transport/v4/packetio"
|
||||
"github.com/pion/transport/v4/stdnet"
|
||||
"github.com/pion/transport/v4/vnet"
|
||||
"github.com/pion/turn/v4"
|
||||
"github.com/pion/turn/v5"
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@ import (
|
||||
|
||||
"github.com/pion/stun/v3"
|
||||
"github.com/pion/transport/v4/test"
|
||||
"github.com/pion/turn/v4"
|
||||
"github.com/pion/turn/v5"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func optimisticAuthHandler(string, string, net.Addr) (key []byte, ok bool) {
|
||||
return turn.GenerateAuthKey("username", "pion.ly", "password"), true
|
||||
func optimisticAuthHandler(ra *turn.RequestAttributes) (userID string, key []byte, ok bool) {
|
||||
return ra.Username, turn.GenerateAuthKey("username", "pion.ly", "password"), true
|
||||
}
|
||||
|
||||
func TestRelayOnlyConnection(t *testing.T) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
"github.com/pion/stun/v3"
|
||||
"github.com/pion/transport/v4/test"
|
||||
"github.com/pion/turn/v4"
|
||||
"github.com/pion/turn/v5"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/pion/stun/v3"
|
||||
"github.com/pion/transport/v4/test"
|
||||
"github.com/pion/transport/v4/vnet"
|
||||
"github.com/pion/turn/v4"
|
||||
"github.com/pion/turn/v5"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -172,12 +172,12 @@ func addVNetSTUN(wanNet *vnet.Net, loggerFactory logging.LoggerFactory) (*turn.S
|
||||
return nil, err
|
||||
}
|
||||
server, err := turn.NewServer(turn.ServerConfig{
|
||||
AuthHandler: func(username, realm string, _ net.Addr) (key []byte, ok bool) {
|
||||
if pw, ok := credMap[username]; ok {
|
||||
return turn.GenerateAuthKey(username, realm, pw), true
|
||||
AuthHandler: func(ra *turn.RequestAttributes) (userID string, key []byte, ok bool) {
|
||||
if pw, found := credMap[ra.Username]; found {
|
||||
return ra.Username, turn.GenerateAuthKey(ra.Username, ra.Realm, pw), true
|
||||
}
|
||||
|
||||
return nil, false
|
||||
return "", nil, false
|
||||
},
|
||||
PacketConnConfigs: []turn.PacketConnConfig{
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/stun/v3"
|
||||
"github.com/pion/transport/v4/stdnet"
|
||||
"github.com/pion/turn/v4"
|
||||
"github.com/pion/turn/v5"
|
||||
)
|
||||
|
||||
type turnClient interface {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import (
|
||||
transport "github.com/pion/transport/v4"
|
||||
"github.com/pion/transport/v4/test"
|
||||
"github.com/pion/transport/v4/vnet"
|
||||
"github.com/pion/turn/v4"
|
||||
"github.com/pion/turn/v5"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/proxy"
|
||||
|
||||
+5
-5
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/pion/stun/v3"
|
||||
"github.com/pion/transport/v4/test"
|
||||
"github.com/pion/transport/v4/vnet"
|
||||
"github.com/pion/turn/v4"
|
||||
"github.com/pion/turn/v5"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -452,12 +452,12 @@ func TestGatherRelayWithVNet(t *testing.T) {
|
||||
RelayAddressGenerator: relayGenerator,
|
||||
},
|
||||
},
|
||||
AuthHandler: func(username, realm string, srcAddr net.Addr) ([]byte, bool) {
|
||||
if username != turnUser {
|
||||
return nil, false
|
||||
AuthHandler: func(ra *turn.RequestAttributes) (userID string, key []byte, ok bool) {
|
||||
if ra.Username != turnUser {
|
||||
return "", nil, false
|
||||
}
|
||||
|
||||
return turn.GenerateAuthKey(username, realm, turnPass), true
|
||||
return ra.Username, turn.GenerateAuthKey(ra.Username, ra.Realm, turnPass), true
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -10,7 +10,7 @@ require (
|
||||
github.com/pion/randutil v0.1.0
|
||||
github.com/pion/stun/v3 v3.1.2
|
||||
github.com/pion/transport/v4 v4.0.1
|
||||
github.com/pion/turn/v4 v4.1.4
|
||||
github.com/pion/turn/v5 v5.0.3
|
||||
github.com/stretchr/testify v1.11.1
|
||||
golang.org/x/net v0.47.0
|
||||
)
|
||||
@@ -21,8 +21,8 @@ require (
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
golang.org/x/crypto v0.45.0 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
golang.org/x/time v0.10.0 // indirect
|
||||
golang.org/x/sys v0.41.0 // indirect
|
||||
golang.org/x/time v0.14.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -21,8 +21,8 @@ github.com/pion/transport/v3 v3.1.1 h1:Tr684+fnnKlhPceU+ICdrw6KKkTms+5qHMgw6bIkY
|
||||
github.com/pion/transport/v3 v3.1.1/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
|
||||
github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
|
||||
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
|
||||
github.com/pion/turn/v4 v4.1.4 h1:EU11yMXKIsK43FhcUnjLlrhE4nboHZq+TXBIi3QpcxQ=
|
||||
github.com/pion/turn/v4 v4.1.4/go.mod h1:ES1DXVFKnOhuDkqn9hn5VJlSWmZPaRJLyBXoOeO/BmQ=
|
||||
github.com/pion/turn/v5 v5.0.3 h1:I+Nw0fQgdPWF1SXDj0egWDhCkcff7gWiigdQpOK52Ak=
|
||||
github.com/pion/turn/v5 v5.0.3/go.mod h1:fs4SogUh/aRGQzonc4Lx3Jp4EU3j3t0PfNDEd9KcD/w=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
@@ -33,10 +33,10 @@ golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
|
||||
golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
|
||||
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
|
||||
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/pion/stun/v3"
|
||||
transport "github.com/pion/transport/v4"
|
||||
"github.com/pion/transport/v4/test"
|
||||
"github.com/pion/turn/v4"
|
||||
"github.com/pion/turn/v5"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/proxy"
|
||||
|
||||
Reference in New Issue
Block a user