Skip to content

Commit

Permalink
Update github.com/pion/transport
Browse files Browse the repository at this point in the history
For go1.19+: update to github.com/pion/transport/v3
For go1.18: keep github.com/pion/transport/v2

Support of go1.18 will be dropped (current plan is to support it
until the end of 2023) and then the v2 can be removed fully.
  • Loading branch information
Danielius1922 committed Sep 5, 2023
1 parent 03606f8 commit 34aabe8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ go 1.18
require (
github.com/dsnet/golib/memfile v1.0.0
github.com/hashicorp/go-multierror v1.1.1
github.com/pion/dtls/v2 v2.2.8-0.20230828143201-609e5bee6eb0
github.com/pion/dtls/v2 v2.2.8-0.20230904031456-60064c6543dd
github.com/pion/transport/v2 v2.2.3
github.com/pion/transport/v3 v3.0.1
github.com/stretchr/testify v1.8.4
go.uber.org/atomic v1.11.0
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
Expand Down
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/pion/dtls/v2 v2.2.8-0.20230828143201-609e5bee6eb0 h1:em0S0zS5l1kPv0IBuuAEN3O9PjURn3sa3Ifo/EUcF9c=
github.com/pion/dtls/v2 v2.2.8-0.20230828143201-609e5bee6eb0/go.mod h1:VzlU+2tjBIhO2YU5o4iySH0ZLvJAVHi7rVYA31/MTmU=
github.com/pion/dtls/v2 v2.2.8-0.20230904031456-60064c6543dd h1:x++LGEHewMuWqCmUym3yfErKIrFsmkYiJ2tgbGxmsV8=
github.com/pion/dtls/v2 v2.2.8-0.20230904031456-60064c6543dd/go.mod h1:gKEfO5iCAoS9mBySDZwcIRU2ksZ2a5HqzU+jTUNTzdM=
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/transport/v2 v2.2.2-0.20230802201558-f2dffd80896b/go.mod h1:OJg3ojoBJopjEeECq2yJdXH9YVrUJ1uQ++NjXLOUorc=
github.com/pion/transport/v2 v2.2.3 h1:XcOE3/x41HOSKbl1BfyY1TF1dERx7lVvlMCbXU7kfvA=
github.com/pion/transport/v2 v2.2.3/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0=
github.com/pion/transport/v3 v3.0.1 h1:gDTlPJwROfSfz6QfSi0ZmeCSkFcnWWiiR9ES0ouANiM=
github.com/pion/transport/v3 v3.0.1/go.mod h1:UY7kiITrlMv7/IKgd5eTUcaahZx5oUN3l9SzK5f5xE0=
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=
Expand All @@ -29,7 +30,6 @@ go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
Expand All @@ -41,7 +41,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -56,22 +55,19 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand Down
9 changes: 3 additions & 6 deletions net/dtlslistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
dtlsnet "github.com/pion/dtls/v2/pkg/net"
"github.com/pion/dtls/v2/pkg/protocol"
"github.com/pion/dtls/v2/pkg/protocol/recordlayer"
"github.com/pion/transport/v2/udp"
"go.uber.org/atomic"
)

Expand Down Expand Up @@ -93,9 +92,7 @@ func NewDTLSListener(network string, addr string, dtlsCfg *dtls.Config, opts ...
return ctx, cancel
}

lc := udp.ListenConfig{
AcceptFilter: tlsPacketFilter,
}
lc := ListenUDPConfig()
l.listener, err = lc.Listen(network, a)
if err != nil {
return nil, err
Expand Down Expand Up @@ -137,7 +134,7 @@ func (l *DTLSListener) run() {
return
}
err := l.accept()
if errors.Is(err, udp.ErrClosedListener) {
if IsUDPClosedError(err) {
return
}
}
Expand Down Expand Up @@ -165,7 +162,7 @@ func (l *DTLSListener) AcceptWithContext(ctx context.Context) (net.Conn, error)
// we don't want to report error handshake deadline exceeded
continue
}
if errors.Is(err, udp.ErrClosedListener) {
if IsUDPClosedError(err) {
return nil, ErrListenerIsClosed
}
if err != nil {
Expand Down
20 changes: 20 additions & 0 deletions net/udplistener.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//go:build !go1.18
// +build !go1.18

package net

import (
"errors"

"github.com/pion/transport/v3/udp"
)

func ListenUDPConfig() udp.ListenConfig {
return udp.ListenConfig{
AcceptFilter: tlsPacketFilter,
}
}

func IsUDPClosedError(err error) bool {
return errors.Is(err, udp.ErrClosedListener)
}
20 changes: 20 additions & 0 deletions net/udplistener_1_18.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//go:build go1.18
// +build go1.18

package net

import (
"errors"

"github.com/pion/transport/v2/udp"
)

func ListenUDPConfig() udp.ListenConfig {
return udp.ListenConfig{
AcceptFilter: tlsPacketFilter,
}
}

func IsUDPClosedError(err error) bool {
return errors.Is(err, udp.ErrClosedListener)
}

0 comments on commit 34aabe8

Please sign in to comment.