Skip to content

Commit 408e76f

Browse files
authored
hysteria2, grpc: fix the use of GetTLSConfig (v2fly#3176)
1 parent 6c091e6 commit 408e76f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

transport/internet/grpc/dial.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne
5252

5353
transportCredentials := insecure.NewCredentials()
5454
if config != nil {
55-
transportCredentials = credentials.NewTLS(config.GetTLSConfig())
55+
transportCredentials = credentials.NewTLS(config.GetTLSConfig(tls.WithDestination(dest)))
5656
}
5757
dialOption := grpc.WithTransportCredentials(transportCredentials)
5858

transport/internet/hysteria2/dialer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ var RunningClient map[dialerConf](hyClient.Client)
2424
var ClientMutex sync.Mutex
2525
var MBps uint64 = 1000000 / 8 // MByte
2626

27-
func GetClientTLSConfig(streamSettings *internet.MemoryStreamConfig) (*hyClient.TLSConfig, error) {
27+
func GetClientTLSConfig(dest net.Destination, streamSettings *internet.MemoryStreamConfig) (*hyClient.TLSConfig, error) {
2828
config := tls.ConfigFromStreamSettings(streamSettings)
2929
if config == nil {
3030
return nil, newError(Hy2MustNeedTLS)
3131
}
32-
tlsConfig := config.GetTLSConfig()
32+
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest))
3333

3434
return &hyClient.TLSConfig{
3535
RootCAs: tlsConfig.RootCAs,
@@ -67,7 +67,7 @@ func (f *connFactory) New(addr net.Addr) (net.PacketConn, error) {
6767
}
6868

6969
func NewHyClient(dest net.Destination, streamSettings *internet.MemoryStreamConfig) (hyClient.Client, error) {
70-
tlsConfig, err := GetClientTLSConfig(streamSettings)
70+
tlsConfig, err := GetClientTLSConfig(dest, streamSettings)
7171
if err != nil {
7272
return nil, err
7373
}

0 commit comments

Comments
 (0)