Add uTLS support for shadowtls v3

This commit is contained in:
世界
2023-02-20 14:08:13 +08:00
parent 5bcfb71737
commit f26785c0ba
8 changed files with 66 additions and 40 deletions

View File

@@ -53,11 +53,18 @@ func NewShadowTLS(ctx context.Context, router adapter.Router, logger log.Context
return common.Error(tls.ClientHandshake(ctx, conn, tlsConfig))
}
case 3:
stdTLSConfig, err := tlsConfig.Config()
if err != nil {
return nil, err
if idConfig, loaded := tlsConfig.(tls.ConfigWithSessionIDGenerator); loaded {
tlsHandshakeFunc = func(ctx context.Context, conn net.Conn, sessionIDGenerator shadowtls.TLSSessionIDGeneratorFunc) error {
idConfig.SetSessionIDGenerator(sessionIDGenerator)
return common.Error(tls.ClientHandshake(ctx, conn, tlsConfig))
}
} else {
stdTLSConfig, err := tlsConfig.Config()
if err != nil {
return nil, err
}
tlsHandshakeFunc = shadowtls.DefaultTLSHandshakeFunc(options.Password, stdTLSConfig)
}
tlsHandshakeFunc = shadowtls.DefaultTLSHandshakeFunc(options.Password, stdTLSConfig)
}
client, err := shadowtls.NewClient(shadowtls.ClientConfig{
Version: options.Version,