Skip to content

Commit 2f07e4e

Browse files
committed
Fix read fsm bug
1 parent f988b64 commit 2f07e4e

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

conn.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (c *Conn) HandshakeContext(ctx context.Context) error {
287287
c.closeLock.Unlock()
288288

289289
if c.handshakeConfig13 != nil {
290-
initialFlight := flight13_0
290+
initialFlight := flight13_1
291291
initialFSMState := handshakePreparing13
292292

293293
if err := c.handshake13(ctx, c.handshakeConfig13, initialFlight, initialFSMState); err != nil {
@@ -803,13 +803,22 @@ func (c *Conn) readAndBuffer(ctx context.Context) error { //nolint:cyclop
803803
done: make(chan struct{}),
804804
isRetransmit: isRetransmit,
805805
}
806-
select {
807-
case c.handshakeRecv <- s:
808-
// If the other party may retransmit the flight,
809-
// we should respond even if it not a new message.
810-
<-s.done
811-
case <-c.fsm.Done():
812-
case <-c.fsm13.Done():
806+
if c.fsm13 != nil {
807+
select {
808+
case c.handshakeRecv <- s:
809+
// If the other party may retransmit the flight,
810+
// we should respond even if it not a new message.
811+
<-s.done
812+
case <-c.fsm13.Done():
813+
}
814+
} else {
815+
select {
816+
case c.handshakeRecv <- s:
817+
// If the other party may retransmit the flight,
818+
// we should respond even if it not a new message.
819+
<-s.done
820+
case <-c.fsm.Done():
821+
}
813822
}
814823
}
815824

flight_13.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package dtls
66
type flightVal13 uint8
77

88
/*
9+
// [RFC9147 Section-5.7]
910
1011
Full DTLS Handshake (with Cookie Exchange):
1112

0 commit comments

Comments
 (0)