Remove TLS requirement for gRPC client

This commit is contained in:
Hellojack 2023-04-04 21:09:08 +08:00 committed by 世界
parent 3a92bf993d
commit ec2d0b6b3c
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
5 changed files with 42 additions and 38 deletions

View file

@ -36,7 +36,9 @@ type Client struct {
func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, options option.V2RayGRPCOptions, tlsConfig tls.Config) (adapter.V2RayClientTransport, error) {
var dialOptions []grpc.DialOption
if tlsConfig != nil {
tlsConfig.SetNextProtos([]string{http2.NextProtoTLS})
if len(tlsConfig.NextProtos()) == 0 {
tlsConfig.SetNextProtos([]string{http2.NextProtoTLS})
}
dialOptions = append(dialOptions, grpc.WithTransportCredentials(NewTLSTransportCredentials(tlsConfig)))
} else {
dialOptions = append(dialOptions, grpc.WithTransportCredentials(insecure.NewCredentials()))