Repository: pion/webrtc
Pull request #2408 (2023-02-07 16:21:48)

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.

stv0g: Currently pending on: https://github.com/pion/ice/pull/471
enobufs: @stv0g I did a quick review and it looks good to me. Hopefully, we see all builds succeed once we have the updated pion/ice integrated. 🤞 

Patch:
diff --git a/examples/vnet/show-network-usage/main.go b/examples/vnet/show-network-usage/main.go
index b3430d5c..4a132ab8 100644
--- a/examples/vnet/show-network-usage/main.go
+++ b/examples/vnet/show-network-usage/main.go
@@ -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))
 
diff --git a/go.mod b/go.mod
index c76d5f76..1020046a 100644
--- a/go.mod
+++ b/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
 )
diff --git a/go.sum b/go.sum
index eb52d287..4daf4263 100644
--- a/go.sum
+++ b/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=
diff --git a/icegatherer.go b/icegatherer.go
index a38f08b7..1f743897 100644
--- a/icegatherer.go
+++ b/icegatherer.go
@@ -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,
diff --git a/internal/mux/endpoint.go b/internal/mux/endpoint.go
index afccc077..939a2294 100644
--- a/internal/mux/endpoint.go
+++ b/internal/mux/endpoint.go
@@ -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.
diff --git a/internal/mux/mux.go b/internal/mux/mux.go
index 901bf180..5412e8c3 100644
--- a/internal/mux/mux.go
+++ b/internal/mux/mux.go
@@ -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.
diff --git a/settingengine.go b/settingengine.go
index 0c1e0c3a..7eee7b01 100644
--- a/settingengine.go
+++ b/settingengine.go
@@ -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


Test patch:
diff --git a/datachannel_go_test.go b/datachannel_go_test.go
index a93ca288..5c9036f1 100644
--- a/datachannel_go_test.go
+++ b/datachannel_go_test.go
@@ -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"
 )
 
diff --git a/datachannel_test.go b/datachannel_test.go
index 7dfaf4ca..98d60ae6 100644
--- a/datachannel_test.go
+++ b/datachannel_test.go
@@ -7,7 +7,7 @@ import (
 	"testing"
 	"time"
 
-	"github.com/pion/transport/test"
+	"github.com/pion/transport/v2/test"
 	"github.com/stretchr/testify/assert"
 )
 
diff --git a/dtlstransport_test.go b/dtlstransport_test.go
index 4d6d3934..20ac73a2 100644
--- a/dtlstransport_test.go
+++ b/dtlstransport_test.go
@@ -8,7 +8,7 @@ import (
 	"testing"
 	"time"
 
-	"github.com/pion/transport/test"
+	"github.com/pion/transport/v2/test"
 	"github.com/stretchr/testify/assert"
 )
 
diff --git a/icegatherer_test.go b/icegatherer_test.go
index cdd1a9c3..55b4ca8b 100644
--- a/icegatherer_test.go
+++ b/icegatherer_test.go
@@ -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"
 )
 
diff --git a/icetransport_test.go b/icetransport_test.go
index 221441d0..87ab0ded 100644
--- a/icetransport_test.go
+++ b/icetransport_test.go
@@ -9,7 +9,7 @@ import (
 	"testing"
 	"time"
 
-	"github.com/pion/transport/test"
+	"github.com/pion/transport/v2/test"
 	"github.com/stretchr/testify/assert"
 )
 
diff --git a/interceptor_test.go b/interceptor_test.go
index bce700e2..2f55e7a8 100644
--- a/interceptor_test.go
+++ b/interceptor_test.go
@@ -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"
 )
diff --git a/internal/mux/mux_test.go b/internal/mux/mux_test.go
index 7c19ea1f..27cd9678 100644
--- a/internal/mux/mux_test.go
+++ b/internal/mux/mux_test.go
@@ -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
diff --git a/mediaengine_test.go b/mediaengine_test.go
index 3d91b482..a92cd7da 100644
--- a/mediaengine_test.go
+++ b/mediaengine_test.go
@@ -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"
 )
 
diff --git a/ortc_datachannel_test.go b/ortc_datachannel_test.go
index cc64d2cb..eb58bfac 100644
--- a/ortc_datachannel_test.go
+++ b/ortc_datachannel_test.go
@@ -8,7 +8,7 @@ import (
 	"testing"
 	"time"
 
-	"github.com/pion/transport/test"
+	"github.com/pion/transport/v2/test"
 	"github.com/stretchr/testify/assert"
 )
 
diff --git a/ortc_media_test.go b/ortc_media_test.go
index 5d247337..0061e038 100644
--- a/ortc_media_test.go
+++ b/ortc_media_test.go
@@ -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"
 )
diff --git a/peerconnection_close_test.go b/peerconnection_close_test.go
index 4a8d2916..1f789292 100644
--- a/peerconnection_close_test.go
+++ b/peerconnection_close_test.go
@@ -7,7 +7,7 @@ import (
 	"testing"
 	"time"
 
-	"github.com/pion/transport/test"
+	"github.com/pion/transport/v2/test"
 	"github.com/stretchr/testify/assert"
 )
 
diff --git a/peerconnection_go_test.go b/peerconnection_go_test.go
index d5a0b27b..010f1eae 100644
--- a/peerconnection_go_test.go
+++ b/peerconnection_go_test.go
@@ -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"
diff --git a/peerconnection_media_test.go b/peerconnection_media_test.go
index 6390abfa..71963e73 100644
--- a/peerconnection_media_test.go
+++ b/peerconnection_media_test.go
@@ -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"
diff --git a/peerconnection_renegotiation_test.go b/peerconnection_renegotiation_test.go
index 7d08bbe4..de4b1f16 100644
--- a/peerconnection_renegotiation_test.go
+++ b/peerconnection_renegotiation_test.go
@@ -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"
diff --git a/peerconnection_test.go b/peerconnection_test.go
index c5d08261..5a5dcd01 100644
--- a/peerconnection_test.go
+++ b/peerconnection_test.go
@@ -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"
 )
diff --git a/rtpreceiver_test.go b/rtpreceiver_test.go
index 858ddf1a..ac19516f 100644
--- a/rtpreceiver_test.go
+++ b/rtpreceiver_test.go
@@ -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"
 )
diff --git a/rtpsender_test.go b/rtpsender_test.go
index 28831bb6..cfd770de 100644
--- a/rtpsender_test.go
+++ b/rtpsender_test.go
@@ -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"
 )
diff --git a/sdpsemantics_test.go b/sdpsemantics_test.go
index ca28c69b..14c51dd5 100644
--- a/sdpsemantics_test.go
+++ b/sdpsemantics_test.go
@@ -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"
 )
 
diff --git a/settingengine_test.go b/settingengine_test.go
index dd661d5e..27858e8e 100644
--- a/settingengine_test.go
+++ b/settingengine_test.go
@@ -8,7 +8,7 @@ import (
 	"testing"
 	"time"
 
-	"github.com/pion/transport/test"
+	"github.com/pion/transport/v2/test"
 	"github.com/stretchr/testify/assert"
 )
 
diff --git a/track_local_static_test.go b/track_local_static_test.go
index d6feebba..29a322a2 100644
--- a/track_local_static_test.go
+++ b/track_local_static_test.go
@@ -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"
 )
 
diff --git a/vnet_test.go b/vnet_test.go
index 11bdb4bd..8d763d65 100644
--- a/vnet_test.go
+++ b/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))