Add SetDTLSConnectContextMaker to SettingEngine

Allows a user to set the context used during the DTLS Handshake. This
can be used to extend or reduce the timeout on the DTLS Handshake.

Resolves #2477
This commit is contained in:
lisa yan
2023-05-19 10:34:41 +08:00
committed by Sean DuBois
parent c1bec495a3
commit 4d3c4b13b1
3 changed files with 23 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
package webrtc
import (
"context"
"io"
"net"
"time"
@@ -63,6 +64,7 @@ type SettingEngine struct {
insecureSkipHelloVerify bool
retransmissionInterval time.Duration
ellipticCurves []dtlsElliptic.Curve
connectContextMaker func() (context.Context, func())
}
sctp struct {
maxReceiveBufferSize uint32
@@ -368,6 +370,17 @@ func (e *SettingEngine) SetDTLSEllipticCurves(ellipticCurves ...dtlsElliptic.Cur
e.dtls.ellipticCurves = ellipticCurves
}
// SetDTLSConnectContextMaker sets the context used during the DTLS Handshake.
// It can be used to extend or reduce the timeout on the DTLS Handshake.
// If nil, the default dtls.ConnectContextMaker is used. It can be implemented as following.
//
// func ConnectContextMaker() (context.Context, func()) {
// return context.WithTimeout(context.Background(), 30*time.Second)
// }
func (e *SettingEngine) SetDTLSConnectContextMaker(connectContextMaker func() (context.Context, func())) {
e.dtls.connectContextMaker = connectContextMaker
}
// SetSCTPMaxReceiveBufferSize sets the maximum receive buffer size.
// Leave this 0 for the default maxReceiveBufferSize.
func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32) {