From ebaf6a0712193a172883b3d8ba5c0239b793374d Mon Sep 17 00:00:00 2001 From: Kevin Park Date: Wed, 3 Jan 2024 11:49:25 +0900 Subject: [PATCH 1/2] Change CLI TLS configuration to http2 --- admin/client.go | 3 ++- client/client.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/admin/client.go b/admin/client.go index 2a4c6b0d2..ac7710c55 100644 --- a/admin/client.go +++ b/admin/client.go @@ -26,6 +26,7 @@ import ( "connectrpc.com/connect" "go.uber.org/zap" + "golang.org/x/net/http2" "github.com/yorkie-team/yorkie/api/converter" "github.com/yorkie-team/yorkie/api/types" @@ -83,7 +84,7 @@ func New(opts ...Option) (*Client, error) { conn := &http.Client{} if !options.IsInsecure { tlsConfig := &tls.Config{MinVersion: tls.VersionTLS12} - conn.Transport = &http.Transport{TLSClientConfig: tlsConfig} + conn.Transport = &http2.Transport{TLSClientConfig: tlsConfig} } logger := options.Logger diff --git a/client/client.go b/client/client.go index f754d1486..7d5e93318 100644 --- a/client/client.go +++ b/client/client.go @@ -32,6 +32,7 @@ import ( "connectrpc.com/connect" "github.com/rs/xid" "go.uber.org/zap" + "golang.org/x/net/http2" "github.com/yorkie-team/yorkie/api/converter" "github.com/yorkie-team/yorkie/api/types" @@ -133,7 +134,7 @@ func New(opts ...Option) (*Client, error) { return nil, fmt.Errorf("create client tls from file: %w", err) } - conn.Transport = &http.Transport{TLSClientConfig: tlsConfig} + conn.Transport = &http2.Transport{TLSClientConfig: tlsConfig} } var clientOptions []connect.ClientOption From 5736314a6f999e1016c5169d0d53a6c637528171 Mon Sep 17 00:00:00 2001 From: Kevin Park Date: Wed, 3 Jan 2024 12:19:14 +0900 Subject: [PATCH 2/2] Update default HTTP scheme configuration --- admin/client.go | 8 ++++++-- client/client.go | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/admin/client.go b/admin/client.go index ac7710c55..192bd7715 100644 --- a/admin/client.go +++ b/admin/client.go @@ -119,8 +119,12 @@ func Dial(rpcAddr string, opts ...Option) (*Client, error) { // Dial dials to the admin service. func (c *Client) Dial(rpcAddr string) error { - if !strings.HasPrefix(rpcAddr, "http") { - rpcAddr = "http://" + rpcAddr + if !strings.Contains(rpcAddr, "://") { + if c.conn.Transport == nil { + rpcAddr = "http://" + rpcAddr + } else { + rpcAddr = "https://" + rpcAddr + } } c.client = v1connect.NewAdminServiceClient(c.conn, rpcAddr, connect.WithInterceptors(c.authInterceptor)) diff --git a/client/client.go b/client/client.go index 7d5e93318..0ec16183c 100644 --- a/client/client.go +++ b/client/client.go @@ -181,8 +181,12 @@ func Dial(rpcAddr string, opts ...Option) (*Client, error) { // Dial dials the given rpcAddr. func (c *Client) Dial(rpcAddr string) error { - if !strings.HasPrefix(rpcAddr, "http") { - rpcAddr = "http://" + rpcAddr + if !strings.Contains(rpcAddr, "://") { + if c.conn.Transport == nil { + rpcAddr = "http://" + rpcAddr + } else { + rpcAddr = "https://" + rpcAddr + } } c.client = v1connect.NewYorkieServiceClient(c.conn, rpcAddr, c.clientOptions...)