File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,7 @@ func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error {
334334 dtlsConfig .FlightInterval = t .api .settingEngine .dtls .retransmissionInterval
335335 dtlsConfig .InsecureSkipVerifyHello = t .api .settingEngine .dtls .insecureSkipHelloVerify
336336 dtlsConfig .EllipticCurves = t .api .settingEngine .dtls .ellipticCurves
337+ dtlsConfig .ConnectContextMaker = t .api .settingEngine .dtls .connectContextMaker
337338
338339 // Connect as DTLS Client/Server, function is blocking and we
339340 // must not hold the DTLSTransport lock
Original file line number Diff line number Diff line change 77package webrtc
88
99import (
10+ "context"
1011 "io"
1112 "net"
1213 "time"
@@ -63,6 +64,7 @@ type SettingEngine struct {
6364 insecureSkipHelloVerify bool
6465 retransmissionInterval time.Duration
6566 ellipticCurves []dtlsElliptic.Curve
67+ connectContextMaker func () (context.Context , func ())
6668 }
6769 sctp struct {
6870 maxReceiveBufferSize uint32
@@ -368,6 +370,17 @@ func (e *SettingEngine) SetDTLSEllipticCurves(ellipticCurves ...dtlsElliptic.Cur
368370 e .dtls .ellipticCurves = ellipticCurves
369371}
370372
373+ // SetDTLSConnectContextMaker sets the context used during the DTLS Handshake.
374+ // It can be used to extend or reduce the timeout on the DTLS Handshake.
375+ // If nil, the default dtls.ConnectContextMaker is used. It can be implemented as following.
376+ //
377+ // func ConnectContextMaker() (context.Context, func()) {
378+ // return context.WithTimeout(context.Background(), 30*time.Second)
379+ // }
380+ func (e * SettingEngine ) SetDTLSConnectContextMaker (connectContextMaker func () (context.Context , func ())) {
381+ e .dtls .connectContextMaker = connectContextMaker
382+ }
383+
371384// SetSCTPMaxReceiveBufferSize sets the maximum receive buffer size.
372385// Leave this 0 for the default maxReceiveBufferSize.
373386func (e * SettingEngine ) SetSCTPMaxReceiveBufferSize (maxReceiveBufferSize uint32 ) {
Original file line number Diff line number Diff line change 77package webrtc
88
99import (
10+ "context"
1011 "net"
1112 "testing"
1213 "time"
@@ -252,6 +253,14 @@ func TestSetDTLSEllipticCurves(t *testing.T) {
252253 }
253254}
254255
256+ func TestSetDTLSHandShakeTimeout (* testing.T ) {
257+ s := SettingEngine {}
258+
259+ s .SetDTLSConnectContextMaker (func () (context.Context , func ()) {
260+ return context .WithTimeout (context .Background (), 60 * time .Second )
261+ })
262+ }
263+
255264func TestSetSCTPMaxReceiverBufferSize (t * testing.T ) {
256265 s := SettingEngine {}
257266 assert .Equal (t , uint32 (0 ), s .sctp .maxReceiveBufferSize )
You can’t perform that action at this time.
0 commit comments