Skip to content

Commit

Permalink
hysteria2, grpc: fix the use of GetTLSConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dyhkwong committed Oct 2, 2024
1 parent 6c091e6 commit e4e0f0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion transport/internet/grpc/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne

transportCredentials := insecure.NewCredentials()
if config != nil {
transportCredentials = credentials.NewTLS(config.GetTLSConfig())
transportCredentials = credentials.NewTLS(config.GetTLSConfig(tls.WithDestination(dest)))
}
dialOption := grpc.WithTransportCredentials(transportCredentials)

Expand Down
6 changes: 3 additions & 3 deletions transport/internet/hysteria2/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ var RunningClient map[dialerConf](hyClient.Client)
var ClientMutex sync.Mutex
var MBps uint64 = 1000000 / 8 // MByte

func GetClientTLSConfig(streamSettings *internet.MemoryStreamConfig) (*hyClient.TLSConfig, error) {
func GetClientTLSConfig(dest net.Destination, streamSettings *internet.MemoryStreamConfig) (*hyClient.TLSConfig, error) {
config := tls.ConfigFromStreamSettings(streamSettings)
if config == nil {
return nil, newError(Hy2MustNeedTLS)
}
tlsConfig := config.GetTLSConfig()
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest))

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

func NewHyClient(dest net.Destination, streamSettings *internet.MemoryStreamConfig) (hyClient.Client, error) {
tlsConfig, err := GetClientTLSConfig(streamSettings)
tlsConfig, err := GetClientTLSConfig(dest, streamSettings)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e4e0f0a

Please sign in to comment.