Repository: pion/sctp
Pull request #249 (2022-11-20 08:01:21)

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.

See https://github.com/pion/transport/pull/204 for a detailed description

See also #248 


codecov[bot]: # [Codecov](https://codecov.io/gh/pion/sctp/pull/249?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) Report
Base: **80.74**% // Head: **66.53**% // Decreases project coverage by **`-14.21%`** :warning:
> Coverage data is based on head [(`9b21b45`)](https://codecov.io/gh/pion/sctp/pull/249?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) compared to base [(`c0159aa`)](https://codecov.io/gh/pion/sctp/commit/c0159aa2d49c240362038edf88baa8a9e6cfcede?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion).
> Patch has no changes to coverable lines.

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff             @@
##           master     #249       +/-   ##
===========================================
- Coverage   80.74%   66.53%   -14.22%     
===========================================
  Files          48       48               
  Lines        4046     4046               
===========================================
- Hits         3267     2692      -575     
- Misses        636     1189      +553     
- Partials      143      165       +22     
```

| Flag | Coverage Δ | |
|---|---|---|
| go | `?` | |
| wasm | `66.53% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/pion/sctp/pull/249?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | Coverage Δ | |
|---|---|---|
| [error\_cause\_user\_initiated\_abort.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-ZXJyb3JfY2F1c2VfdXNlcl9pbml0aWF0ZWRfYWJvcnQuZ28=) | `0.00% <0.00%> (-76.93%)` | :arrow_down: |
| [association\_stats.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-YXNzb2NpYXRpb25fc3RhdHMuZ28=) | `69.23% <0.00%> (-30.77%)` | :arrow_down: |
| [association.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-YXNzb2NpYXRpb24uZ28=) | `60.47% <0.00%> (-24.23%)` | :arrow_down: |
| [stream.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-c3RyZWFtLmdv) | `69.72% <0.00%> (-21.43%)` | :arrow_down: |
| [error\_cause.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-ZXJyb3JfY2F1c2UuZ28=) | `24.48% <0.00%> (-16.33%)` | :arrow_down: |
| [error\_cause\_protocol\_violation.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-ZXJyb3JfY2F1c2VfcHJvdG9jb2xfdmlvbGF0aW9uLmdv) | `61.53% <0.00%> (-15.39%)` | :arrow_down: |
| [chunk\_shutdown\_ack.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-Y2h1bmtfc2h1dGRvd25fYWNrLmdv) | `73.33% <0.00%> (-13.34%)` | :arrow_down: |
| [chunk\_shutdown\_complete.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-Y2h1bmtfc2h1dGRvd25fY29tcGxldGUuZ28=) | `73.33% <0.00%> (-13.34%)` | :arrow_down: |
| [chunk\_forward\_tsn.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-Y2h1bmtfZm9yd2FyZF90c24uZ28=) | `81.66% <0.00%> (-13.34%)` | :arrow_down: |
| [packet.go](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-cGFja2V0Lmdv) | `60.57% <0.00%> (-12.50%)` | :arrow_down: |
| ... and [8 more](https://codecov.io/gh/pion/sctp/pull/249/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/pion/sctp/pull/249?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion).


Patch:
diff --git a/go.mod b/go.mod
index 8346cb0..787d0ad 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ require (
 	github.com/kr/pretty v0.1.0 // indirect
 	github.com/pion/logging v0.2.2
 	github.com/pion/randutil v0.1.0
-	github.com/pion/transport v0.14.1
+	github.com/pion/transport/v2 v2.0.0
 	github.com/stretchr/testify v1.8.1
 	gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
 )
diff --git a/go.sum b/go.sum
index eb0d92f..ca805f7 100644
--- a/go.sum
+++ b/go.sum
@@ -10,8 +10,8 @@ github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
 github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
 github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
 github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
-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/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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=


Test patch:
diff --git a/association_test.go b/association_test.go
index 2079d22..ba058b9 100644
--- a/association_test.go
+++ b/association_test.go
@@ -20,7 +20,7 @@ import (
 	"time"
 
 	"github.com/pion/logging"
-	"github.com/pion/transport/test"
+	"github.com/pion/transport/v2/test"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 )
diff --git a/vnet_test.go b/vnet_test.go
index 058bc24..dfe11e5 100644
--- a/vnet_test.go
+++ b/vnet_test.go
@@ -10,8 +10,8 @@ import (
 	"time"
 
 	"github.com/pion/logging"
-	"github.com/pion/transport/test"
-	"github.com/pion/transport/vnet"
+	"github.com/pion/transport/v2/test"
+	"github.com/pion/transport/v2/vnet"
 	"github.com/stretchr/testify/assert"
 )
 
@@ -122,17 +122,25 @@ func buildVNetEnv(cfg *vNetEnvConfig) (*vNetEnv, error) {
 	}
 	wan.AddChunkFilter(tsnAutoLockOnFilter())
 
-	net0 := vnet.NewNet(&vnet.NetConfig{
+	net0, err := vnet.NewNet(&vnet.NetConfig{
 		StaticIPs: []string{serverIP},
 	})
+	if err != nil {
+		return nil, err
+	}
+
 	err = wan.AddNet(net0)
 	if err != nil {
 		return nil, err
 	}
 
-	net1 := vnet.NewNet(&vnet.NetConfig{
+	net1, err := vnet.NewNet(&vnet.NetConfig{
 		StaticIPs: []string{clientIP},
 	})
+	if err != nil {
+		return nil, err
+	}
+
 	err = wan.AddNet(net1)
 	if err != nil {
 		return nil, err