| 1 |
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly> |
| 2 |
// SPDX-License-Identifier: MIT |
| 3 |
|
| 4 |
package dtlsscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/ |
| 5 |
|
| 6 |
import ( |
| 7 |
"bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/" |
| 8 |
"contextscip-go gomod github.com/golang/go/src go1.24.0 context/" |
| 9 |
"crypto/tlsscip-go gomod github.com/golang/go/src go1.24.0 `crypto/tls`/" |
| 10 |
"errorsscip-go gomod github.com/golang/go/src go1.24.0 errors/" |
| 11 |
"syncscip-go gomod github.com/golang/go/src go1.24.0 sync/" |
| 12 |
"testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 13 |
"timescip-go gomod github.com/golang/go/src go1.24.0 time/" |
| 14 |
|
| 15 |
"github.com/pion/dtls/v3/pkg/crypto/selfsignscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/crypto/selfsign`/" |
| 16 |
"github.com/pion/dtls/v3/pkg/crypto/signaturehashscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/crypto/signaturehash`/" |
| 17 |
"github.com/pion/dtls/v3/pkg/protocol/alertscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/alert`/" |
| 18 |
"github.com/pion/dtls/v3/pkg/protocol/handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/" |
| 19 |
"github.com/pion/dtls/v3/pkg/protocol/recordlayerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/" |
| 20 |
"github.com/pion/loggingscip-go gomod github.com/pion/logging v0.2.4 `github.com/pion/logging`/" |
| •21 |
"github.com/pion/transport/v3/testscip-go gomod github.com/golang/go/src go1.24.0 `github.com/pion/transport/v3/test`/" |
| 22 |
"github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 23 |
) |
| 24 |
|
| 25 |
const nonZeroRetransmitIntervalscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/nonZeroRetransmitInterval. = 100 * timescip-go gomod github.com/golang/go/src go1.24.0 time/.Millisecondscip-go gomod github.com/golang/go/src go1.24.0 time/Millisecond. |
| 26 |
|
| 27 |
// Test that writes to the key log are in the correct format and only applies |
| 28 |
// when a key log writer is given. |
| 29 |
func TestWriteKeyLogscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestWriteKeyLog().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 30 |
var buf bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer# |
| 31 |
cfg := handshakeConfigscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#{ |
| 32 |
keyLogWriterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#keyLogWriter.: &buf, |
| 33 |
} |
| 34 |
cfg.writeKeyLogscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#writeKeyLog().("LABEL", []byte{0xAA, 0xBB, 0xCC}, []byte{0xDD, 0xEE, 0xFF}) |
| 35 |
|
| 36 |
// Secrets follow the format <Label> <space> <ClientRandom> <space> <Secret> |
| 37 |
// https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format |
| 38 |
want := "LABEL aabbcc ddeeff\n" |
| 39 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, want, buf.Stringscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer#String().()) |
| 40 |
|
| 41 |
// no key log writer = no writes |
| 42 |
cfg = handshakeConfigscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#{} |
| 43 |
cfg.writeKeyLogscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#writeKeyLog().("LABEL", []byte{0xAA, 0xBB, 0xCC}, []byte{0xDD, 0xEE, 0xFF}) |
| 44 |
} |
| 45 |
|
| 46 |
func TestHandshakerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestHandshaker().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { //nolint:gocyclo,cyclop,maintidx |
| 47 |
// Check for leaking routines |
| 48 |
report := testscip-go gomod github.com/golang/go/src go1.24.0 `github.com/pion/transport/v3/test`/.CheckRoutines(t) |
| 49 |
defer report() |
| 50 |
|
| 51 |
loggerFactory := loggingscip-go gomod github.com/pion/logging v0.2.4 `github.com/pion/logging`/.NewDefaultLoggerFactoryscip-go gomod github.com/pion/logging v0.2.4 `github.com/pion/logging`/NewDefaultLoggerFactory().() |
| 52 |
logger := loggerFactory.NewLoggerscip-go gomod github.com/pion/logging v0.2.4 `github.com/pion/logging`/DefaultLoggerFactory#NewLogger().("dtls") |
| 53 |
|
| 54 |
cipherSuites, err := parseCipherSuitesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/parseCipherSuites().(nil, nil, true, false) |
| 55 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 56 |
clientCert, err := selfsignscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/crypto/selfsign`/.GenerateSelfSignedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/crypto/selfsign`/GenerateSelfSigned().() |
| 57 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 58 |
|
| 59 |
genFilters := map[string]func() (TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#)){ |
| 60 |
"PassThrough": func() (TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#)) { |
| 61 |
return TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#{}, TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#{}, nil |
| 62 |
}, |
| 63 |
|
| 64 |
"HelloVerifyRequestLost": func() (TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#)) { |
| 65 |
var ( |
| 66 |
cntHelloVerifyRequest = 0 |
| 67 |
cntClientHelloNoCookie = 0 |
| 68 |
) |
| 69 |
const helloVerifyDrop = 5 |
| 70 |
|
| 71 |
clientEndpoint := TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#{ |
| 72 |
Filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Filter.: func(p *packetscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#) bool { |
| 73 |
h, ok := p.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Contentscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Content..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.Handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#) |
| 74 |
if !ok { |
| 75 |
return true |
| 76 |
} |
| 77 |
if hmch, ok := h.Messagescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Message..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.MessageClientHelloscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/MessageClientHello#); ok { |
| 78 |
if len(hmch.Cookiescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/MessageClientHello#Cookie.) == 0 { |
| 79 |
cntClientHelloNoCookie++ |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
return true |
| 84 |
}, |
| 85 |
} |
| 86 |
|
| 87 |
serverEndpoint := TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#{ |
| 88 |
Filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Filter.: func(p *packetscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#) bool { |
| 89 |
h, ok := p.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Contentscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Content..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.Handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#) |
| 90 |
if !ok { |
| 91 |
return true |
| 92 |
} |
| 93 |
if _, ok := h.Messagescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Message..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.MessageHelloVerifyRequestscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/MessageHelloVerifyRequest#); ok { |
| 94 |
cntHelloVerifyRequest++ |
| 95 |
|
| 96 |
return cntHelloVerifyRequest > helloVerifyDrop |
| 97 |
} |
| 98 |
|
| 99 |
return true |
| 100 |
}, |
| 101 |
} |
| 102 |
|
| 103 |
report := func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 104 |
t.Helperscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Helper().() |
| 105 |
|
| 106 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, cntHelloVerifyRequest, helloVerifyDrop+1, "Number of HelloVerifyRequest retransmit is wrong") |
| 107 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, cntHelloVerifyRequest, cntClientHelloNoCookie, |
| 108 |
"Number of ClientHello without cookie should match the number of HelloVerifyRequest sent.") |
| 109 |
} |
| 110 |
|
| 111 |
return clientEndpoint, serverEndpoint, report |
| 112 |
}, |
| 113 |
|
| 114 |
"NoLatencyTest": func() (TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#)) { |
| 115 |
var ( |
| 116 |
cntClientFinished = 0 |
| 117 |
cntServerFinished = 0 |
| 118 |
) |
| 119 |
|
| 120 |
clientEndpoint := TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#{ |
| 121 |
Filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Filter.: func(p *packetscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#) bool { |
| 122 |
h, ok := p.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Contentscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Content..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.Handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#) |
| 123 |
if !ok { |
| 124 |
return true |
| 125 |
} |
| 126 |
if _, ok := h.Messagescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Message..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.MessageFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/MessageFinished#); ok { |
| 127 |
cntClientFinished++ |
| 128 |
} |
| 129 |
|
| 130 |
return true |
| 131 |
}, |
| 132 |
} |
| 133 |
|
| 134 |
serverEndpoint := TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#{ |
| 135 |
Filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Filter.: func(p *packetscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#) bool { |
| 136 |
h, ok := p.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Contentscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Content..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.Handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#) |
| 137 |
if !ok { |
| 138 |
return true |
| 139 |
} |
| 140 |
if _, ok := h.Messagescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Message..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.MessageFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/MessageFinished#); ok { |
| 141 |
cntServerFinished++ |
| 142 |
} |
| 143 |
|
| 144 |
return true |
| 145 |
}, |
| 146 |
} |
| 147 |
|
| 148 |
report := func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 149 |
t.Helperscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Helper().() |
| 150 |
|
| 151 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, 1, cntClientFinished) |
| 152 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, 1, cntServerFinished) |
| 153 |
} |
| 154 |
|
| 155 |
return clientEndpoint, serverEndpoint, report |
| 156 |
}, |
| 157 |
|
| 158 |
"SlowServerTest": func() (TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#)) { |
| 159 |
var ( |
| 160 |
cntClientFinished = 0 |
| 161 |
isClientFinished = false |
| 162 |
cntClientFinishedLastRetransmit = 0 |
| 163 |
cntServerFinished = 0 |
| 164 |
isServerFinished = false |
| 165 |
cntServerFinishedLastRetransmit = 0 |
| 166 |
) |
| 167 |
|
| 168 |
clientEndpoint := TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#{ |
| 169 |
Filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Filter.: func(p *packetscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#) bool { |
| 170 |
h, ok := p.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Contentscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Content..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.Handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#) |
| 171 |
if !ok { |
| 172 |
return true |
| 173 |
} |
| 174 |
if _, ok := h.Messagescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Message..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.MessageFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/MessageFinished#); ok { |
| 175 |
if isClientFinished { |
| 176 |
cntClientFinishedLastRetransmit++ |
| 177 |
} else { |
| 178 |
cntClientFinished++ |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
return true |
| 183 |
}, |
| 184 |
Delayscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Delay.: 0, |
| 185 |
OnFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#OnFinished.: func() { |
| 186 |
isClientFinished = true |
| 187 |
}, |
| 188 |
FinishWaitscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#FinishWait.: 2000 * timescip-go gomod github.com/golang/go/src go1.24.0 time/.Millisecondscip-go gomod github.com/golang/go/src go1.24.0 time/Millisecond., |
| 189 |
} |
| 190 |
|
| 191 |
serverEndpoint := TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#{ |
| 192 |
Filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Filter.: func(p *packetscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#) bool { |
| 193 |
h, ok := p.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Contentscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Content..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.Handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#) |
| 194 |
if !ok { |
| 195 |
return true |
| 196 |
} |
| 197 |
if _, ok := h.Messagescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Message..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.MessageFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/MessageFinished#); ok { |
| 198 |
if isServerFinished { |
| 199 |
cntServerFinishedLastRetransmit++ |
| 200 |
} else { |
| 201 |
cntServerFinished++ |
| 202 |
} |
| 203 |
} |
| 204 |
|
| 205 |
return true |
| 206 |
}, |
| 207 |
Delayscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Delay.: 1000 * timescip-go gomod github.com/golang/go/src go1.24.0 time/.Millisecondscip-go gomod github.com/golang/go/src go1.24.0 time/Millisecond., |
| 208 |
OnFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#OnFinished.: func() { |
| 209 |
isServerFinished = true |
| 210 |
}, |
| 211 |
FinishWaitscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#FinishWait.: 2000 * timescip-go gomod github.com/golang/go/src go1.24.0 time/.Millisecondscip-go gomod github.com/golang/go/src go1.24.0 time/Millisecond., |
| 212 |
} |
| 213 |
|
| 214 |
report := func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 215 |
t.Helperscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Helper().() |
| 216 |
|
| 217 |
// with one second server delay and 100 ms retransmit (+ exponential backoff), |
| 218 |
// there should be close to 4 `Finished` from client |
| 219 |
// using a range of 3 - 5 for checking. |
| 220 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.LessOrEqualscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/LessOrEqual().(t, 3, cntClientFinished, "Number of client finished should be greater than 3") |
| 221 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.GreaterOrEqualscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/GreaterOrEqual().(t, 5, cntClientFinished, "Number of client finished should be less than 5") |
| 222 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, isClientFinished) |
| 223 |
// there should be no `Finished` last retransmit from client |
| 224 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, 0, cntClientFinishedLastRetransmit, "Number of client finished last retransmit greater than zero") |
| 225 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.LessOrEqualscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/LessOrEqual().(t, 1, cntServerFinished, "Number of server finished less than 1") |
| 226 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, isServerFinished) |
| 227 |
// there should be `Finished` last retransmit from server. |
| 228 |
// Because of slow server, client would have sent several `Finished`. |
| 229 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.LessOrEqualscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/LessOrEqual().(t, 1, cntServerFinished, "Number of server finished last retransmit is less than 1") |
| 230 |
} |
| 231 |
|
| 232 |
return clientEndpoint, serverEndpoint, report |
| 233 |
}, |
| 234 |
} |
| 235 |
|
| 236 |
for name, filters := range genFilters { |
| 237 |
clientEndpoint, serverEndpoint, report := filters() |
| 238 |
t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 239 |
ctx, cancel := contextscip-go gomod github.com/golang/go/src go1.24.0 context/.WithTimeoutscip-go gomod github.com/golang/go/src go1.24.0 context/WithTimeout().(contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Backgroundscip-go gomod github.com/golang/go/src go1.24.0 context/Background().(), 20*timescip-go gomod github.com/golang/go/src go1.24.0 time/.Secondscip-go gomod github.com/golang/go/src go1.24.0 time/Second.) |
| 240 |
defer cancel() |
| 241 |
|
| 242 |
if report != nil { |
| 243 |
defer report(t) |
| 244 |
} |
| 245 |
|
| 246 |
ca, cb := flightTestPipescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestPipe().(ctx, clientEndpoint, serverEndpoint) |
| 247 |
ca.statescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#state..isClientscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/State#isClient. = true |
| 248 |
|
| 249 |
var wg syncscip-go gomod github.com/golang/go/src go1.24.0 sync/.WaitGroupscip-go gomod github.com/golang/go/src go1.24.0 sync/WaitGroup# |
| 250 |
wg.Addscip-go gomod github.com/golang/go/src go1.24.0 sync/WaitGroup#Add().(2) |
| 251 |
|
| 252 |
ctxCliFinished, cancelCli := contextscip-go gomod github.com/golang/go/src go1.24.0 context/.WithCancelscip-go gomod github.com/golang/go/src go1.24.0 context/WithCancel().(ctx) |
| 253 |
ctxSrvFinished, cancelSrv := contextscip-go gomod github.com/golang/go/src go1.24.0 context/.WithCancelscip-go gomod github.com/golang/go/src go1.24.0 context/WithCancel().(ctx) |
| 254 |
go func() { |
| 255 |
defer wg.Donescip-go gomod github.com/golang/go/src go1.24.0 sync/WaitGroup#Done().() |
| 256 |
cfg := &handshakeConfigscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#{ |
| 257 |
localCipherSuitesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#localCipherSuites.: cipherSuites, |
| 258 |
localCertificatesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#localCertificates.: []tlsscip-go gomod github.com/golang/go/src go1.24.0 `crypto/tls`/.Certificatescip-go gomod github.com/golang/go/src go1.24.0 `crypto/tls`/Certificate#{clientCert}, |
| 259 |
ellipticCurvesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#ellipticCurves.: defaultCurvesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/defaultCurves., |
| 260 |
localSignatureSchemesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#localSignatureSchemes.: signaturehashscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/crypto/signaturehash`/.Algorithmsscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/crypto/signaturehash`/Algorithms().(), |
| 261 |
insecureSkipVerifyscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#insecureSkipVerify.: true, |
| 262 |
logscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#log.: logger, |
| 263 |
onFlightStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#onFlightState.: func(_ flightValscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightVal#, s handshakeStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeState#) { |
| 264 |
if s == handshakeFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeFinished. { |
| 265 |
if clientEndpoint.OnFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#OnFinished. != nil { |
| 266 |
clientEndpoint.OnFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#OnFinished.() |
| 267 |
} |
| 268 |
timescip-go gomod github.com/golang/go/src go1.24.0 time/.AfterFuncscip-go gomod github.com/golang/go/src go1.24.0 time/AfterFunc().(clientEndpoint.FinishWaitscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#FinishWait., func() { |
| 269 |
cancelCli() |
| 270 |
}) |
| 271 |
} |
| 272 |
}, |
| 273 |
initialRetransmitIntervalscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#initialRetransmitInterval.: nonZeroRetransmitIntervalscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/nonZeroRetransmitInterval., |
| 274 |
} |
| 275 |
|
| 276 |
fsm := newHandshakeFSMscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/newHandshakeFSM().(&ca.statescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#state., ca.handshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#handshakeCache., cfg, flight1scip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flight1.) |
| 277 |
err := fsm.Runscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeFSM#Run().(ctx, ca, handshakePreparingscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakePreparing.) |
| 278 |
switch { |
| 279 |
case errorsscip-go gomod github.com/golang/go/src go1.24.0 errors/.Isscip-go gomod github.com/golang/go/src go1.24.0 errors/Is().(err, contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Canceledscip-go gomod github.com/golang/go/src go1.24.0 context/Canceled.): |
| 280 |
case errorsscip-go gomod github.com/golang/go/src go1.24.0 errors/.Isscip-go gomod github.com/golang/go/src go1.24.0 errors/Is().(err, contextscip-go gomod github.com/golang/go/src go1.24.0 context/.DeadlineExceededscip-go gomod github.com/golang/go/src go1.24.0 context/DeadlineExceeded.): |
| 281 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Failscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Fail().(t, "timeout") |
| 282 |
default: |
| 283 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Failfscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Failf().(t, "Handshake failed", "Error: %v", err) |
| 284 |
} |
| 285 |
}() |
| 286 |
|
| 287 |
go func() { |
| 288 |
defer wg.Donescip-go gomod github.com/golang/go/src go1.24.0 sync/WaitGroup#Done().() |
| 289 |
cfg := &handshakeConfigscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#{ |
| 290 |
localCipherSuitesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#localCipherSuites.: cipherSuites, |
| 291 |
localCertificatesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#localCertificates.: []tlsscip-go gomod github.com/golang/go/src go1.24.0 `crypto/tls`/.Certificatescip-go gomod github.com/golang/go/src go1.24.0 `crypto/tls`/Certificate#{clientCert}, |
| 292 |
ellipticCurvesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#ellipticCurves.: defaultCurvesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/defaultCurves., |
| 293 |
localSignatureSchemesscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#localSignatureSchemes.: signaturehashscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/crypto/signaturehash`/.Algorithmsscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/crypto/signaturehash`/Algorithms().(), |
| 294 |
insecureSkipVerifyscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#insecureSkipVerify.: true, |
| 295 |
logscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#log.: logger, |
| 296 |
onFlightStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#onFlightState.: func(_ flightValscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightVal#, s handshakeStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeState#) { |
| 297 |
if s == handshakeFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeFinished. { |
| 298 |
if serverEndpoint.OnFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#OnFinished. != nil { |
| 299 |
serverEndpoint.OnFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#OnFinished.() |
| 300 |
} |
| 301 |
timescip-go gomod github.com/golang/go/src go1.24.0 time/.AfterFuncscip-go gomod github.com/golang/go/src go1.24.0 time/AfterFunc().(serverEndpoint.FinishWaitscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#FinishWait., func() { |
| 302 |
cancelSrv() |
| 303 |
}) |
| 304 |
} |
| 305 |
}, |
| 306 |
initialRetransmitIntervalscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeConfig#initialRetransmitInterval.: nonZeroRetransmitIntervalscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/nonZeroRetransmitInterval., |
| 307 |
} |
| 308 |
|
| 309 |
fsm := newHandshakeFSMscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/newHandshakeFSM().(&cb.statescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#state., cb.handshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#handshakeCache., cfg, flight0scip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flight0.) |
| 310 |
err := fsm.Runscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeFSM#Run().(ctx, cb, handshakePreparingscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakePreparing.) |
| 311 |
switch { |
| 312 |
case errorsscip-go gomod github.com/golang/go/src go1.24.0 errors/.Isscip-go gomod github.com/golang/go/src go1.24.0 errors/Is().(err, contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Canceledscip-go gomod github.com/golang/go/src go1.24.0 context/Canceled.): |
| 313 |
case errorsscip-go gomod github.com/golang/go/src go1.24.0 errors/.Isscip-go gomod github.com/golang/go/src go1.24.0 errors/Is().(err, contextscip-go gomod github.com/golang/go/src go1.24.0 context/.DeadlineExceededscip-go gomod github.com/golang/go/src go1.24.0 context/DeadlineExceeded.): |
| 314 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Failscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Fail().(t, "timeout") |
| 315 |
default: |
| 316 |
assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Failfscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Failf().(t, "Handshake failed", "Error: %v", err) |
| 317 |
} |
| 318 |
}() |
| 319 |
|
| 320 |
<-ctxCliFinished.Donescip-go gomod github.com/golang/go/src go1.24.0 context/Context#Done().() |
| 321 |
<-ctxSrvFinished.Donescip-go gomod github.com/golang/go/src go1.24.0 context/Context#Done().() |
| 322 |
|
| 323 |
cancel() |
| 324 |
wg.Waitscip-go gomod github.com/golang/go/src go1.24.0 sync/WaitGroup#Wait().() |
| 325 |
}) |
| 326 |
} |
| 327 |
} |
| 328 |
|
| 329 |
type packetFilterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packetFilter# func(p *packetscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#) bool |
| 330 |
|
| 331 |
type TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint# struct { |
| 332 |
Filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Filter. packetFilterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packetFilter# |
| 333 |
Delayscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Delay. timescip-go gomod github.com/golang/go/src go1.24.0 time/.Durationscip-go gomod github.com/golang/go/src go1.24.0 time/Duration# |
| 334 |
OnFinishedscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#OnFinished. func() |
| 335 |
FinishWaitscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#FinishWait. timescip-go gomod github.com/golang/go/src go1.24.0 time/.Durationscip-go gomod github.com/golang/go/src go1.24.0 time/Duration# |
| 336 |
} |
| 337 |
|
| 338 |
func flightTestPipescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestPipe().( |
| 339 |
ctx contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Contextscip-go gomod github.com/golang/go/src go1.24.0 context/Context#, |
| 340 |
clientEndpoint TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, |
| 341 |
serverEndpoint TestEndpointscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#, |
| 342 |
) (*flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#, *flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#) { |
| 343 |
ca := newHandshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/newHandshakeCache().() |
| 344 |
cb := newHandshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/newHandshakeCache().() |
| 345 |
chA := make(chan recvHandshakeStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/recvHandshakeState#) |
| 346 |
chB := make(chan recvHandshakeStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/recvHandshakeState#) |
| 347 |
|
| 348 |
return &flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#{ |
| 349 |
handshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#handshakeCache.: ca, |
| 350 |
otherEndCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#otherEndCache.: cb, |
| 351 |
recvscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#recv.: chA, |
| 352 |
otherEndRecvscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#otherEndRecv.: chB, |
| 353 |
donescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#done.: ctx.Donescip-go gomod github.com/golang/go/src go1.24.0 context/Context#Done().(), |
| 354 |
filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#filter.: clientEndpoint.Filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Filter., |
| 355 |
delayscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#delay.: clientEndpoint.Delayscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Delay., |
| 356 |
}, &flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#{ |
| 357 |
handshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#handshakeCache.: cb, |
| 358 |
otherEndCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#otherEndCache.: ca, |
| 359 |
recvscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#recv.: chB, |
| 360 |
otherEndRecvscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#otherEndRecv.: chA, |
| 361 |
donescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#done.: ctx.Donescip-go gomod github.com/golang/go/src go1.24.0 context/Context#Done().(), |
| 362 |
filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#filter.: serverEndpoint.Filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Filter., |
| 363 |
delayscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#delay.: serverEndpoint.Delayscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/TestEndpoint#Delay., |
| 364 |
} |
| 365 |
} |
| 366 |
|
| 367 |
type flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn# struct { |
| 368 |
statescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#state. Statescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/State# |
| 369 |
handshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#handshakeCache. *handshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeCache# |
| 370 |
recvscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#recv. chan recvHandshakeStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/recvHandshakeState# |
| 371 |
donescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#done. <-chan struct{} |
| 372 |
epochscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#epoch. uint16 |
| 373 |
|
| 374 |
filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#filter. packetFilterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packetFilter# |
| 375 |
|
| 376 |
delayscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#delay. timescip-go gomod github.com/golang/go/src go1.24.0 time/.Durationscip-go gomod github.com/golang/go/src go1.24.0 time/Duration# |
| 377 |
|
| 378 |
otherEndCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#otherEndCache. *handshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeCache# |
| 379 |
otherEndRecvscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#otherEndRecv. chan recvHandshakeStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/recvHandshakeState# |
| 380 |
} |
| 381 |
|
| 382 |
func (c *flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#) recvHandshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#recvHandshake().() <-chan recvHandshakeStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/recvHandshakeState# { |
| 383 |
return c.recvscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#recv. |
| 384 |
} |
| 385 |
|
| 386 |
func (c *flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#) setLocalEpochscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#setLocalEpoch().(epoch uint16) { |
| 387 |
c.epochscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#epoch. = epoch |
| 388 |
} |
| 389 |
|
| 390 |
func (c *flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#) notifyscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#notify().(contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Contextscip-go gomod github.com/golang/go/src go1.24.0 context/Context#, alertscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/alert`/.Levelscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/alert`/Level#, alertscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/alert`/.Descriptionscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/alert`/Description#) error { |
| 391 |
return nil |
| 392 |
} |
| 393 |
|
| 394 |
func (c *flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#) writePacketsscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#writePackets().(_ contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Contextscip-go gomod github.com/golang/go/src go1.24.0 context/Context#, pkts []*packetscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#) error { |
| 395 |
timescip-go gomod github.com/golang/go/src go1.24.0 time/.Sleepscip-go gomod github.com/golang/go/src go1.24.0 time/Sleep().(c.delayscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#delay.) |
| 396 |
for _, pkt := range pkts { |
| 397 |
if c.filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#filter. != nil && !c.filterscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#filter.(pkt) { |
| 398 |
continue |
| 399 |
} |
| 400 |
if handshake, ok := pkt.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Contentscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Content..(*handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/.Handshakescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#); ok { |
| 401 |
handshakeRaw, err := pkt.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Marshalscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Marshal().() |
| 402 |
if err != nil { |
| 403 |
return err |
| 404 |
} |
| 405 |
|
| 406 |
c.handshakeCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#handshakeCache..pushscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeCache#push().( |
| 407 |
handshakeRaw[recordlayerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/.FixedHeaderSizescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/FixedHeaderSize.:], |
| 408 |
pkt.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Headerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Header..Epochscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/Header#Epoch., |
| 409 |
handshake.Headerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Header..MessageSequencescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Header#MessageSequence., |
| 410 |
handshake.Headerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Header..Typescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Header#Type., |
| 411 |
c.statescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#state..isClientscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/State#isClient., |
| 412 |
) |
| 413 |
|
| 414 |
content, err := handshake.Messagescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Message..Marshalscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Message#Marshal.() |
| 415 |
if err != nil { |
| 416 |
return err |
| 417 |
} |
| 418 |
handshake.Headerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Header..Lengthscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Header#Length. = uint32(len(content)) //nolint:gosec // G115 |
| 419 |
handshake.Headerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Header..FragmentLengthscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Header#FragmentLength. = uint32(len(content)) //nolint:gosec // G115 |
| 420 |
hdr, err := handshake.Headerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Header..Marshalscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Header#Marshal().() |
| 421 |
if err != nil { |
| 422 |
return err |
| 423 |
} |
| 424 |
c.otherEndCachescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#otherEndCache..pushscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/handshakeCache#push().( |
| 425 |
append(hdr, content...), |
| 426 |
pkt.recordscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/packet#record..Headerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/RecordLayer#Header..Epochscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/recordlayer`/Header#Epoch., |
| 427 |
handshake.Headerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Header..MessageSequencescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Header#MessageSequence., |
| 428 |
handshake.Headerscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Handshake#Header..Typescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3/pkg/protocol/handshake`/Header#Type., |
| 429 |
c.statescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#state..isClientscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/State#isClient., |
| 430 |
) |
| 431 |
} |
| 432 |
} |
| 433 |
go func() { |
| 434 |
select { |
| 435 |
case c.otherEndRecvscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#otherEndRecv. <- recvHandshakeStatescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/recvHandshakeState#{donescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/recvHandshakeState#done.: make(chan struct{})}: |
| 436 |
case <-c.donescip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#done.: |
| 437 |
} |
| 438 |
}() |
| 439 |
|
| 440 |
// Avoid deadlock on JS/WASM environment due to context switch problem. |
| 441 |
timescip-go gomod github.com/golang/go/src go1.24.0 time/.Sleepscip-go gomod github.com/golang/go/src go1.24.0 time/Sleep().(10 * timescip-go gomod github.com/golang/go/src go1.24.0 time/.Millisecondscip-go gomod github.com/golang/go/src go1.24.0 time/Millisecond.) |
| 442 |
|
| 443 |
return nil |
| 444 |
} |
| 445 |
|
| 446 |
func (c *flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#) handleQueuedPacketsscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#handleQueuedPackets().(contextscip-go gomod github.com/golang/go/src go1.24.0 context/.Contextscip-go gomod github.com/golang/go/src go1.24.0 context/Context#) error { |
| 447 |
return nil |
| 448 |
} |
| 449 |
|
| 450 |
func (c *flightTestConnscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#) sessionKeyscip-go gomod github.com/pion/dtls/v3 . `github.com/pion/dtls/v3`/flightTestConn#sessionKey().() []byte { |
| 451 |
return nil |
| 452 |
} |