From b96e8778a575cead264712aeb3098b585ef1b689 Mon Sep 17 00:00:00 2001 From: colin <102356659+colinlyguo@users.noreply.github.com> Date: Fri, 5 Jan 2024 13:35:19 +0800 Subject: [PATCH] fix(bridge-history-api): add redis tls config InsecureSkipVerify (#1068) Co-authored-by: colinlyguo --- bridge-history-api/cmd/api/app/app.go | 16 ++++++++++++---- bridge-history-api/conf/config.json | 4 +++- bridge-history-api/internal/config/config.go | 12 +++++++----- common/version/version.go | 2 +- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/bridge-history-api/cmd/api/app/app.go b/bridge-history-api/cmd/api/app/app.go index 04f0b2ff2..5316ed42d 100644 --- a/bridge-history-api/cmd/api/app/app.go +++ b/bridge-history-api/cmd/api/app/app.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "os/signal" + "time" "github.com/gin-gonic/gin" "github.com/go-redis/redis/v8" @@ -54,14 +55,21 @@ func action(ctx *cli.Context) error { } }() opts := &redis.Options{ - Addr: cfg.Redis.Address, - Username: cfg.Redis.Username, - Password: cfg.Redis.Password, + Addr: cfg.Redis.Address, + Username: cfg.Redis.Username, + Password: cfg.Redis.Password, + MinIdleConns: cfg.Redis.MinIdleConns, + ReadTimeout: time.Duration(cfg.Redis.ReadTimeoutMs * int(time.Millisecond)), } // Production Redis service has enabled transit_encryption. if !cfg.Redis.Local { - opts.TLSConfig = &tls.Config{MinVersion: tls.VersionTLS12} + opts.TLSConfig = &tls.Config{ + MinVersion: tls.VersionTLS12, + InsecureSkipVerify: true, //nolint:gosec + } } + log.Info("init redis client", "addr", opts.Addr, "user name", opts.Username, "is local", cfg.Redis.Local, + "min idle connections", opts.MinIdleConns, "read timeout", opts.ReadTimeout) redisClient := redis.NewClient(opts) api.InitController(db, redisClient) diff --git a/bridge-history-api/conf/config.json b/bridge-history-api/conf/config.json index 3e94fbece..f93044d48 100644 --- a/bridge-history-api/conf/config.json +++ b/bridge-history-api/conf/config.json @@ -46,6 +46,8 @@ "address": "localhost:6379", "username": "default", "password": "", - "local": true + "local": true, + "minIdleConns": 10, + "readTimeoutMs": 500 } } diff --git a/bridge-history-api/internal/config/config.go b/bridge-history-api/internal/config/config.go index 4235e3448..4b932c29e 100644 --- a/bridge-history-api/internal/config/config.go +++ b/bridge-history-api/internal/config/config.go @@ -32,11 +32,13 @@ type LayerConfig struct { // RedisConfig redis config type RedisConfig struct { - Address string `json:"address"` - Username string `json:"username"` - Password string `json:"password"` - DB int `json:"db"` - Local bool `json:"local"` + Address string `json:"address"` + Username string `json:"username"` + Password string `json:"password"` + DB int `json:"db"` + Local bool `json:"local"` + MinIdleConns int `json:"minIdleConns"` + ReadTimeoutMs int `json:"readTimeoutMs"` } // Config is the configuration of the bridge history backend diff --git a/common/version/version.go b/common/version/version.go index f851a21da..1c45246ad 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.3.49" +var tag = "v4.3.50" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok {