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:
Steffen Vogel
2023-02-07 17:20:15 +01:00
parent 2af43db4c5
commit eafdc7742a
28 changed files with 85 additions and 70 deletions

View File

@@ -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))