Apply handshake timeout to ShadowTLS v3 standard TLS handshake

This commit is contained in:
世界
2026-11-25 21:25:12 +08:00
parent 27c872d81f
commit c7f675a68b
3 changed files with 10 additions and 4 deletions
+7 -1
View File
@@ -76,7 +76,13 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
if err != nil {
return nil, err
}
tlsHandshakeFunc = shadowtls.DefaultTLSHandshakeFunc(options.Password, stdTLSConfig)
defaultHandshakeFunc := shadowtls.DefaultTLSHandshakeFunc(options.Password, stdTLSConfig)
handshakeTimeout := tlsConfig.HandshakeTimeout()
tlsHandshakeFunc = func(ctx context.Context, conn net.Conn, sessionIDGenerator shadowtls.TLSSessionIDGeneratorFunc) error {
ctx, cancel := context.WithTimeout(ctx, handshakeTimeout)
defer cancel()
return defaultHandshakeFunc(ctx, conn, sessionIDGenerator)
}
}
}
outboundDialer, err := dialer.New(ctx, options.DialerOptions, options.ServerIsDomain())