1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-20 22:45:24 +00:00

Feat: make gRPC dialer accept socket config (#1697)

This commit is contained in:
dyhkwong 2022-04-06 12:26:04 +08:00 committed by GitHub
parent 5b9f7821ea
commit 5ce71e0652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,7 +54,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne
dialOption = grpc.WithTransportCredentials(credentials.NewTLS(config.GetTLSConfig()))
}
conn, canceller, err := getGrpcClient(ctx, dest, dialOption)
conn, canceller, err := getGrpcClient(ctx, dest, dialOption, streamSettings)
if err != nil {
return nil, newError("Cannot dial grpc").Base(err)
}
@ -67,7 +67,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne
return encoding.NewGunConn(gunService, nil), nil
}
func getGrpcClient(ctx context.Context, dest net.Destination, dialOption grpc.DialOption) (*grpc.ClientConn, dialerCanceller, error) {
func getGrpcClient(ctx context.Context, dest net.Destination, dialOption grpc.DialOption, streamSettings *internet.MemoryStreamConfig) (*grpc.ClientConn, dialerCanceller, error) {
globalDialerAccess.Lock()
defer globalDialerAccess.Unlock()
@ -112,7 +112,7 @@ func getGrpcClient(ctx context.Context, dest net.Destination, dialOption grpc.Di
}
address := net.ParseAddress(rawHost)
detachedContext := core.ToBackgroundDetachedContext(ctx)
return internet.DialSystem(detachedContext, net.TCPDestination(address, port), nil)
return internet.DialSystem(detachedContext, net.TCPDestination(address, port), streamSettings.SocketSettings)
}),
)
globalDialerMap[dest] = conn