mirror of
https://github.com/pion/webrtc.git
synced 2025-10-27 01:00:35 +08:00
Use new pion/transport Net interface
This change adapts pion/ice to use a new interface for most network related operations. The interface was formerly a simple struct vnet.Net which was originally intended to facilicate testing. By replacing it with an interface we have greater flexibility and allow users to hook into the networking stack by providing their own implementation of the interface.
This commit is contained in:
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
"github.com/pion/datachannel"
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/transport/vnet"
|
||||
"github.com/pion/transport/v2/vnet"
|
||||
"github.com/pion/webrtc/v3"
|
||||
)
|
||||
|
||||
@@ -83,9 +83,11 @@ func main() {
|
||||
}()
|
||||
|
||||
// Create a network interface for offerer
|
||||
offerVNet := vnet.NewNet(&vnet.NetConfig{
|
||||
offerVNet, err := vnet.NewNet(&vnet.NetConfig{
|
||||
StaticIPs: []string{"1.2.3.4"},
|
||||
})
|
||||
panicIfError(err)
|
||||
|
||||
// Add the network interface to the router
|
||||
panicIfError(wan.AddNet(offerVNet))
|
||||
|
||||
@@ -94,9 +96,11 @@ func main() {
|
||||
offerAPI := webrtc.NewAPI(webrtc.WithSettingEngine(offerSettingEngine))
|
||||
|
||||
// Create a network interface for answerer
|
||||
answerVNet := vnet.NewNet(&vnet.NetConfig{
|
||||
answerVNet, err := vnet.NewNet(&vnet.NetConfig{
|
||||
StaticIPs: []string{"1.2.3.5"},
|
||||
})
|
||||
panicIfError(err)
|
||||
|
||||
// Add the network interface to the router
|
||||
panicIfError(wan.AddNet(answerVNet))
|
||||
|
||||
|
||||
7
go.mod
7
go.mod
@@ -7,7 +7,7 @@ require (
|
||||
github.com/onsi/gomega v1.17.0 // indirect
|
||||
github.com/pion/datachannel v1.5.5
|
||||
github.com/pion/dtls/v2 v2.2.4
|
||||
github.com/pion/ice/v2 v2.2.16
|
||||
github.com/pion/ice/v2 v2.2.17-0.20230208205849-228c31f0515c
|
||||
github.com/pion/interceptor v0.1.12
|
||||
github.com/pion/logging v0.2.2
|
||||
github.com/pion/randutil v0.1.0
|
||||
@@ -15,9 +15,10 @@ require (
|
||||
github.com/pion/rtp v1.7.13
|
||||
github.com/pion/sctp v1.8.6
|
||||
github.com/pion/sdp/v3 v3.0.6
|
||||
github.com/pion/srtp/v2 v2.0.11
|
||||
github.com/pion/transport v0.14.1
|
||||
github.com/pion/srtp/v2 v2.0.12
|
||||
github.com/pion/transport/v2 v2.0.1
|
||||
github.com/sclevine/agouti v3.0.0+incompatible
|
||||
github.com/stretchr/testify v1.8.1
|
||||
golang.org/x/crypto v0.6.0 // indirect
|
||||
golang.org/x/net v0.6.0
|
||||
)
|
||||
|
||||
34
go.sum
34
go.sum
@@ -42,11 +42,10 @@ github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE=
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/pion/datachannel v1.5.5 h1:10ef4kwdjije+M9d7Xm9im2Y3O6A6ccQb0zcqZcJew8=
|
||||
github.com/pion/datachannel v1.5.5/go.mod h1:iMz+lECmfdCMqFRhXhcA/219B0SQlbpoR2V118yimL0=
|
||||
github.com/pion/dtls/v2 v2.1.5/go.mod h1:BqCE7xPZbPSubGasRoDFJeTsyJtdD1FanJYL0JGheqY=
|
||||
github.com/pion/dtls/v2 v2.2.4 h1:YSfYwDQgrxMYXLBc/m7PFY5BVtWlNm/DN4qoU2CbcWg=
|
||||
github.com/pion/dtls/v2 v2.2.4/go.mod h1:WGKfxqhrddne4Kg3p11FUMJrynkOY4lb25zHNO49wuw=
|
||||
github.com/pion/ice/v2 v2.2.16 h1:ht10A9FxLrFouaQQy9oSzZHaN+HJqN07jQ0SmzsBgpU=
|
||||
github.com/pion/ice/v2 v2.2.16/go.mod h1:bygTkwN2e4U4v57VE77qS2wk5P8kc951WZZkf4LeA2E=
|
||||
github.com/pion/ice/v2 v2.2.17-0.20230208205849-228c31f0515c h1:CCOI4TfsbXDVx5ouyvogz8P7pf+b96i3DTMenbUAtO8=
|
||||
github.com/pion/ice/v2 v2.2.17-0.20230208205849-228c31f0515c/go.mod h1:+xO/cXVnnVUr6D2ZJcCT5g9LngucUkkTvfnTMqUxKRM=
|
||||
github.com/pion/interceptor v0.1.12 h1:CslaNriCFUItiXS5o+hh5lpL0t0ytQkFnUcbbCs2Zq8=
|
||||
github.com/pion/interceptor v0.1.12/go.mod h1:bDtgAD9dRkBZpWHGKaoKb42FhDHTG2rX8Ii9LRALLVA=
|
||||
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
|
||||
@@ -64,21 +63,17 @@ github.com/pion/sctp v1.8.6 h1:CUex11Vkt9YS++VhLf8b55O3VqKrWL6W3SDwX4jAqsI=
|
||||
github.com/pion/sctp v1.8.6/go.mod h1:SUFFfDpViyKejTAdwD1d/HQsCu+V/40cCs2nZIvC3s0=
|
||||
github.com/pion/sdp/v3 v3.0.6 h1:WuDLhtuFUUVpTfus9ILC4HRyHsW6TdugjEX/QY9OiUw=
|
||||
github.com/pion/sdp/v3 v3.0.6/go.mod h1:iiFWFpQO8Fy3S5ldclBkpXqmWy02ns78NOKoLLL0YQw=
|
||||
github.com/pion/srtp/v2 v2.0.11 h1:6cEEgT1oCLWgE+BynbfaSMAxtsqU0M096x9dNH6olY0=
|
||||
github.com/pion/srtp/v2 v2.0.11/go.mod h1:vzHprzbuVoYJ9NfaRMycnFrkHcLSaLVuBZDOtFQNZjY=
|
||||
github.com/pion/stun v0.3.5/go.mod h1:gDMim+47EeEtfWogA37n6qXZS88L5V6LqFcf+DZA2UA=
|
||||
github.com/pion/srtp/v2 v2.0.12 h1:WrmiVCubGMOAObBU1vwWjG0H3VSyQHawKeer2PVA5rY=
|
||||
github.com/pion/srtp/v2 v2.0.12/go.mod h1:C3Ep44hlOo2qEYaq4ddsmK5dL63eLehXFbHaZ9F5V9Y=
|
||||
github.com/pion/stun v0.4.0 h1:vgRrbBE2htWHy7l3Zsxckk7rkjnjOsSM7PHZnBwo8rk=
|
||||
github.com/pion/stun v0.4.0/go.mod h1:QPsh1/SbXASntw3zkkrIk3ZJVKz4saBY2G7S10P3wCw=
|
||||
github.com/pion/transport v0.12.2/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q=
|
||||
github.com/pion/transport v0.13.0/go.mod h1:yxm9uXpK9bpBBWkITk13cLo1y5/ur5VQpG22ny6EP7g=
|
||||
github.com/pion/transport v0.13.1/go.mod h1:EBxbqzyv+ZrmDb82XswEE0BjfQFtuw1Nu6sjnjWCsGg=
|
||||
github.com/pion/transport v0.14.1 h1:XSM6olwW+o8J4SCmOBb/BpwZypkHeyM0PGFCxNQBr40=
|
||||
github.com/pion/transport v0.14.1/go.mod h1:4tGmbk00NeYA3rUa9+n+dzCCoKkcy3YlYb99Jn2fNnI=
|
||||
github.com/pion/transport/v2 v2.0.0 h1:bsMYyqHCbkvHwj+eNCFBuxtlKndKfyGI2vaQmM3fIE4=
|
||||
github.com/pion/transport/v2 v2.0.0/go.mod h1:HS2MEBJTwD+1ZI2eSXSvHJx/HnzQqRy2/LXxt6eVMHc=
|
||||
github.com/pion/turn/v2 v2.0.9 h1:jcDPw0Vfd5I4iTc7s0Upfc2aMnyu2lgJ9vV0SUrNC1o=
|
||||
github.com/pion/turn/v2 v2.0.9/go.mod h1:DQlwUwx7hL8Xya6TTAabbd9DdKXTNR96Xf5g5Qqso/M=
|
||||
github.com/pion/udp v0.1.1/go.mod h1:6AFo+CMdKQm7UiA0eUPA8/eVCTx8jBIITLZHc9DWX5M=
|
||||
github.com/pion/transport/v2 v2.0.1 h1:cbSk3gzoSBEIKVGNYeghXQSp47s1H9ttoP5JyLCgxLE=
|
||||
github.com/pion/transport/v2 v2.0.1/go.mod h1:93OYg91+mrGxKW+Jrgzmqr80kgXqD7J0yybOrdr7w0Y=
|
||||
github.com/pion/turn/v2 v2.1.0 h1:5wGHSgGhJhP/RpabkUb/T9PdsAjkGLS6toYz5HNzoSI=
|
||||
github.com/pion/turn/v2 v2.1.0/go.mod h1:yrT5XbXSGX1VFSF31A3c1kCNB5bBZgk/uu5LET162qs=
|
||||
github.com/pion/udp v0.1.4 h1:OowsTmu1Od3sD6i3fQUJxJn2fEvJO6L1TidgadtbTI8=
|
||||
github.com/pion/udp v0.1.4/go.mod h1:G8LDo56HsFwC24LIcnT4YIDU5qcB6NepqqjP0keL2us=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
@@ -89,8 +84,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
@@ -101,9 +94,9 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
|
||||
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
||||
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
|
||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -111,13 +104,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||
@@ -139,9 +127,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
||||
@@ -109,7 +109,7 @@ func (g *ICEGatherer) createAgent() error {
|
||||
NAT1To1IPs: g.api.settingEngine.candidates.NAT1To1IPs,
|
||||
NAT1To1IPCandidateType: nat1To1CandiTyp,
|
||||
IncludeLoopback: g.api.settingEngine.candidates.IncludeLoopbackCandidate,
|
||||
Net: g.api.settingEngine.vnet,
|
||||
Net: g.api.settingEngine.net,
|
||||
MulticastDNSMode: mDNSMode,
|
||||
MulticastDNSHostName: g.api.settingEngine.candidates.MulticastDNSHostName,
|
||||
LocalUfrag: g.api.settingEngine.candidates.UsernameFragment,
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/ice/v2"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/pion/interceptor"
|
||||
mock_interceptor "github.com/pion/interceptor/pkg/mock"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/ice/v2"
|
||||
"github.com/pion/transport/packetio"
|
||||
"github.com/pion/transport/v2/packetio"
|
||||
)
|
||||
|
||||
// Endpoint implements net.Conn. It is used to read muxed packets.
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/pion/ice/v2"
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/transport/packetio"
|
||||
"github.com/pion/transport/v2/packetio"
|
||||
)
|
||||
|
||||
// The maximum amount of data that can be buffered before returning errors.
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/transport/packetio"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/packetio"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -49,11 +49,14 @@ func (m *muxErrorConn) Read(b []byte) (n int, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
/* Don't end the mux readLoop for packetio.ErrTimeout or io.ErrShortBuffer, assert the following
|
||||
* io.ErrShortBuffer and packetio.ErrTimeout don't end the read loop
|
||||
* io.EOF ends the loop
|
||||
/*
|
||||
Don't end the mux readLoop for packetio.ErrTimeout or io.ErrShortBuffer, assert the following
|
||||
|
||||
pion/webrtc#1720
|
||||
- io.ErrShortBuffer and packetio.ErrTimeout don't end the read loop
|
||||
|
||||
- io.EOF ends the loop
|
||||
|
||||
pion/webrtc#1720
|
||||
*/
|
||||
func TestNonFatalRead(t *testing.T) {
|
||||
// Limit runtime in case of deadlocks
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/pion/sdp/v3"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import (
|
||||
|
||||
"github.com/pion/ice/v2"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/vnet"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/pion/transport/v2/vnet"
|
||||
"github.com/pion/webrtc/v3/internal/util"
|
||||
"github.com/pion/webrtc/v3/pkg/rtcerr"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/sdp/v3"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/pion/webrtc/v3/internal/util"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/pion/webrtc/v3/pkg/rtcerr"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/sdp/v3"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/pion/webrtc/v3/pkg/rtcerr"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/sdp/v3"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ import (
|
||||
"github.com/pion/dtls/v2"
|
||||
"github.com/pion/ice/v2"
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/transport/packetio"
|
||||
"github.com/pion/transport/vnet"
|
||||
"github.com/pion/transport/v2"
|
||||
"github.com/pion/transport/v2/packetio"
|
||||
"github.com/pion/transport/v2/vnet"
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
@@ -65,7 +66,7 @@ type SettingEngine struct {
|
||||
disableCertificateFingerprintVerification bool
|
||||
disableSRTPReplayProtection bool
|
||||
disableSRTCPReplayProtection bool
|
||||
vnet *vnet.Net
|
||||
net transport.Net
|
||||
BufferFactory func(packetType packetio.BufferPacketType, ssrc uint32) io.ReadWriteCloser
|
||||
LoggerFactory logging.LoggerFactory
|
||||
iceTCPMux ice.TCPMux
|
||||
@@ -179,9 +180,13 @@ func (e *SettingEngine) SetIPFilter(filter func(net.IP) bool) {
|
||||
// Two types of candidates are supported:
|
||||
//
|
||||
// ICECandidateTypeHost:
|
||||
// The public IP address will be used for the host candidate in the SDP.
|
||||
//
|
||||
// The public IP address will be used for the host candidate in the SDP.
|
||||
//
|
||||
// ICECandidateTypeSrflx:
|
||||
// A server reflexive candidate with the given public IP address will be added
|
||||
//
|
||||
// A server reflexive candidate with the given public IP address will be added
|
||||
//
|
||||
// to the SDP.
|
||||
//
|
||||
// Please note that if you choose ICECandidateTypeHost, then the private IP address
|
||||
@@ -207,9 +212,12 @@ func (e *SettingEngine) SetIncludeLoopbackCandidate(include bool) {
|
||||
// may be useful when interacting with non-compliant clients or debugging issues.
|
||||
//
|
||||
// DTLSRoleActive:
|
||||
// Act as DTLS Client, send the ClientHello and starts the handshake
|
||||
//
|
||||
// Act as DTLS Client, send the ClientHello and starts the handshake
|
||||
//
|
||||
// DTLSRolePassive:
|
||||
// Act as DTLS Server, wait for ClientHello
|
||||
//
|
||||
// Act as DTLS Server, wait for ClientHello
|
||||
func (e *SettingEngine) SetAnsweringDTLSRole(role DTLSRole) error {
|
||||
if role != DTLSRoleClient && role != DTLSRoleServer {
|
||||
return errSettingEngineSetAnsweringDTLSRole
|
||||
@@ -224,8 +232,17 @@ func (e *SettingEngine) SetAnsweringDTLSRole(role DTLSRole) error {
|
||||
// VNet is a virtual network layer for Pion, allowing users to simulate
|
||||
// different topologies, latency, loss and jitter. This can be useful for
|
||||
// learning WebRTC concepts or testing your application in a lab environment
|
||||
// Deprecated: Please use SetNet()
|
||||
func (e *SettingEngine) SetVNet(vnet *vnet.Net) {
|
||||
e.vnet = vnet
|
||||
e.SetNet(vnet)
|
||||
}
|
||||
|
||||
// SetNet sets the Net instance that is passed to pion/ice
|
||||
//
|
||||
// Net is an network interface layer for Pion, allowing users to replace
|
||||
// Pions network stack with a custom implementation.
|
||||
func (e *SettingEngine) SetNet(net transport.Net) {
|
||||
e.net = net
|
||||
}
|
||||
|
||||
// SetICEMulticastDNSMode controls if pion/ice queries and generates mDNS ICE Candidates
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/pion/transport/v2/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
10
vnet_test.go
10
vnet_test.go
@@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/transport/vnet"
|
||||
"github.com/pion/transport/v2/vnet"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -21,9 +21,11 @@ func createVNetPair(t *testing.T) (*PeerConnection, *PeerConnection, *vnet.Route
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Create a network interface for offerer
|
||||
offerVNet := vnet.NewNet(&vnet.NetConfig{
|
||||
offerVNet, err := vnet.NewNet(&vnet.NetConfig{
|
||||
StaticIPs: []string{"1.2.3.4"},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Add the network interface to the router
|
||||
assert.NoError(t, wan.AddNet(offerVNet))
|
||||
|
||||
@@ -32,9 +34,11 @@ func createVNetPair(t *testing.T) (*PeerConnection, *PeerConnection, *vnet.Route
|
||||
offerSettingEngine.SetICETimeouts(time.Second, time.Second, time.Millisecond*200)
|
||||
|
||||
// Create a network interface for answerer
|
||||
answerVNet := vnet.NewNet(&vnet.NetConfig{
|
||||
answerVNet, err := vnet.NewNet(&vnet.NetConfig{
|
||||
StaticIPs: []string{"1.2.3.5"},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Add the network interface to the router
|
||||
assert.NoError(t, wan.AddNet(answerVNet))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user