Add SetDTLSConnectionState

Allow a DTLS Connection to be resumed from DTLS ConnectionState
This commit is contained in:
Sean DuBois
2023-03-16 23:56:19 -04:00
parent 1b74d280ea
commit ae0858ebca
2 changed files with 8 additions and 1 deletions

View File

@@ -330,7 +330,9 @@ 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 {
if t.api.settingEngine.dtls.connectionState != nil {
dtlsConn, err = dtls.Resume(t.api.settingEngine.dtls.connectionState, dtlsEndpoint, dtlsConfig)
} else if role == DTLSRoleClient {
dtlsConn, err = dtls.Client(dtlsEndpoint, dtlsConfig)
} else {
dtlsConn, err = dtls.Server(dtlsEndpoint, dtlsConfig)

View File

@@ -60,6 +60,7 @@ type SettingEngine struct {
insecureSkipHelloVerify bool
retransmissionInterval time.Duration
ellipticCurves []dtlsElliptic.Curve
connectionState *dtls.State
}
sctp struct {
maxReceiveBufferSize uint32
@@ -370,3 +371,7 @@ func (e *SettingEngine) SetDTLSEllipticCurves(ellipticCurves ...dtlsElliptic.Cur
func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32) {
e.sctp.maxReceiveBufferSize = maxReceiveBufferSize
}
func (e *SettingEngine) SetDTLSConnectionState(connectionState *dtls.State) {
e.dtls.connectionState = connectionState
}