Skip to content

Commit ce7cc03

Browse files
committed
fix dtls Handshake
1 parent d97700e commit ce7cc03

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: vpn/dtls.go

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package vpn
22

33
import (
4+
"context"
45
"encoding/hex"
56
"github.com/pion/dtls/v3"
67
"net"
@@ -67,6 +68,13 @@ func dtlsChannel(cSess *session.ConnSession) {
6768
close(cSess.DtlsSetupChan) // 没有成功建立 DTLS 隧道
6869
return
6970
}
71+
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
72+
defer cancel()
73+
if err = conn.HandshakeContext(ctx); err != nil {
74+
base.Error(err)
75+
close(cSess.DtlsSetupChan) // 没有成功建立 DTLS 隧道
76+
return
77+
}
7078

7179
cSess.DtlsConnected.Store(true)
7280
dSess = cSess.DSess

0 commit comments

Comments
 (0)