Skip to content

Commit

Permalink
Update module github.com/pion/dtls/v2 to v3
Browse files Browse the repository at this point in the history
Generated by renovateBot
  • Loading branch information
Sean-Der committed Jul 25, 2024
1 parent 6a4a57a commit f388de6
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strings"
"time"

"github.com/pion/dtls/v2/pkg/crypto/fingerprint"
"github.com/pion/dtls/v3/pkg/crypto/fingerprint"
"github.com/pion/webrtc/v4/pkg/rtcerr"
)

Expand Down
2 changes: 1 addition & 1 deletion constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package webrtc

import "github.com/pion/dtls/v2"
import "github.com/pion/dtls/v3"

const (
// Equal to UDP MTU
Expand Down
20 changes: 14 additions & 6 deletions dtlstransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"sync/atomic"
"time"

"github.com/pion/dtls/v2"
"github.com/pion/dtls/v2/pkg/crypto/fingerprint"
"github.com/pion/dtls/v3"
"github.com/pion/dtls/v3/pkg/crypto/fingerprint"
"github.com/pion/interceptor"
"github.com/pion/logging"
"github.com/pion/rtcp"
Expand Down Expand Up @@ -284,7 +284,7 @@ func (t *DTLSTransport) role() DTLSRole {
}

// Start DTLS transport negotiation with the parameters of the remote DTLS transport
func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error {
func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error { //nolint: gocognit
// Take lock and prepare connection, we must not hold the lock
// when connecting
prepareTransport := func() (DTLSRole, *dtls.Config, error) {
Expand Down Expand Up @@ -346,7 +346,6 @@ func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error {
dtlsConfig.FlightInterval = t.api.settingEngine.dtls.retransmissionInterval
dtlsConfig.InsecureSkipVerifyHello = t.api.settingEngine.dtls.insecureSkipHelloVerify
dtlsConfig.EllipticCurves = t.api.settingEngine.dtls.ellipticCurves
dtlsConfig.ConnectContextMaker = t.api.settingEngine.dtls.connectContextMaker
dtlsConfig.ExtendedMasterSecret = t.api.settingEngine.dtls.extendedMasterSecret
dtlsConfig.ClientCAs = t.api.settingEngine.dtls.clientCAs
dtlsConfig.RootCAs = t.api.settingEngine.dtls.rootCAs
Expand All @@ -355,9 +354,18 @@ func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error {
// Connect as DTLS Client/Server, function is blocking and we
// must not hold the DTLSTransport lock
if role == DTLSRoleClient {
dtlsConn, err = dtls.Client(dtlsEndpoint, dtlsConfig)
dtlsConn, err = dtls.Client(dtlsEndpoint, dtlsEndpoint.RemoteAddr(), dtlsConfig)
} else {
dtlsConn, err = dtls.Server(dtlsEndpoint, dtlsConfig)
dtlsConn, err = dtls.Server(dtlsEndpoint, dtlsEndpoint.RemoteAddr(), dtlsConfig)
}

if err == nil {
if t.api.settingEngine.dtls.connectContextMaker != nil {
handshakeCtx, _ := t.api.settingEngine.dtls.connectContextMaker()
err = dtlsConn.HandshakeContext(handshakeCtx)
} else {
err = dtlsConn.Handshake()
}
}

// Re-take the lock, nothing beyond here is blocking
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/pion/datachannel v1.5.8
github.com/pion/dtls/v2 v2.2.12
github.com/pion/dtls/v3 v3.0.0
github.com/pion/ice/v3 v3.0.13
github.com/pion/interceptor v0.1.29
github.com/pion/logging v0.2.2
Expand All @@ -26,6 +26,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.17.0 // indirect
github.com/pion/dtls/v2 v2.2.12 // indirect
github.com/pion/mdns/v2 v2.0.7 // indirect
github.com/pion/transport/v2 v2.2.8 // indirect
github.com/pion/turn/v3 v3.0.3 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ github.com/pion/datachannel v1.5.8/go.mod h1:PgmdpoaNBLX9HNzNClmdki4DYW5JtI7Yibu
github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s=
github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk=
github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE=
github.com/pion/dtls/v3 v3.0.0 h1:m2hzwPkzqoBjVKXm5ymNuX01OAjht82TdFL6LoTzgi4=
github.com/pion/dtls/v3 v3.0.0/go.mod h1:tiX7NaneB0wNoRaUpaMVP7igAlkMCTQkbpiY+OfeIi0=
github.com/pion/ice/v3 v3.0.13 h1:tPi5fh2xbWhS0DBcs7LTEG0SOUTHLVDjTlFwBy3hXfw=
github.com/pion/ice/v3 v3.0.13/go.mod h1:q2M/RnfpgGhC4HcluxPpD1wImaqFqU0Z1PE2eeOPrIs=
github.com/pion/interceptor v0.1.29 h1:39fsnlP1U8gw2JzOFWdfCU82vHvhW9o0rZnZF56wF+M=
Expand Down
12 changes: 12 additions & 0 deletions internal/mux/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ func (e *Endpoint) Read(p []byte) (int, error) {
return e.buffer.Read(p)
}

// ReadFrom reads a packet of len(p) bytes from the underlying conn
// that are matched by the associated MuxFunc
func (e *Endpoint) ReadFrom(p []byte) (int, net.Addr, error) {
i, err := e.Read(p)
return i, nil, err
}

// Write writes len(p) bytes to the underlying conn
func (e *Endpoint) Write(p []byte) (int, error) {
n, err := e.mux.nextConn.Write(p)
Expand All @@ -56,6 +63,11 @@ func (e *Endpoint) Write(p []byte) (int, error) {
return n, err
}

// WriteTo writes len(p) bytes to the underlying conn
func (e *Endpoint) WriteTo(p []byte, _ net.Addr) (int, error) {
return e.Write(p)
}

// LocalAddr is a stub
func (e *Endpoint) LocalAddr() net.Addr {
return e.mux.nextConn.LocalAddr()
Expand Down
4 changes: 2 additions & 2 deletions settingengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"net"
"time"

"github.com/pion/dtls/v2"
dtlsElliptic "github.com/pion/dtls/v2/pkg/crypto/elliptic"
"github.com/pion/dtls/v3"
dtlsElliptic "github.com/pion/dtls/v3/pkg/crypto/elliptic"
"github.com/pion/ice/v3"
"github.com/pion/logging"
"github.com/pion/stun/v2"
Expand Down
2 changes: 1 addition & 1 deletion settingengine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
"time"

"github.com/pion/dtls/v2/pkg/crypto/elliptic"
"github.com/pion/dtls/v3/pkg/crypto/elliptic"
"github.com/pion/ice/v3"
"github.com/pion/stun/v2"
"github.com/pion/transport/v3/test"
Expand Down

0 comments on commit f388de6

Please sign in to comment.