From fdb71dd6aa407a31614195451b27e11608319988 Mon Sep 17 00:00:00 2001 From: colin <102356659+colinlyguo@users.noreply.github.com> Date: Fri, 29 Dec 2023 23:40:44 +0800 Subject: [PATCH] fix(bridge-history-api): change redis config (#1062) Co-authored-by: colinlyguo --- bridge-history-api/cmd/api/app/app.go | 12 +++++++++--- bridge-history-api/conf/config.json | 3 ++- bridge-history-api/internal/config/config.go | 2 ++ common/version/version.go | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/bridge-history-api/cmd/api/app/app.go b/bridge-history-api/cmd/api/app/app.go index 16a406c70..04f0b2ff2 100644 --- a/bridge-history-api/cmd/api/app/app.go +++ b/bridge-history-api/cmd/api/app/app.go @@ -1,6 +1,7 @@ package app import ( + "crypto/tls" "fmt" "os" "os/signal" @@ -52,11 +53,16 @@ func action(ctx *cli.Context) error { log.Error("failed to close db", "err", err) } }() - redisClient := redis.NewClient(&redis.Options{ + opts := &redis.Options{ Addr: cfg.Redis.Address, + Username: cfg.Redis.Username, Password: cfg.Redis.Password, - DB: cfg.Redis.DB, - }) + } + // Production Redis service has enabled transit_encryption. + if !cfg.Redis.Local { + opts.TLSConfig = &tls.Config{MinVersion: tls.VersionTLS12} + } + redisClient := redis.NewClient(opts) api.InitController(db, redisClient) router := gin.Default() diff --git a/bridge-history-api/conf/config.json b/bridge-history-api/conf/config.json index e7bcbfac4..8b20106e4 100644 --- a/bridge-history-api/conf/config.json +++ b/bridge-history-api/conf/config.json @@ -45,7 +45,8 @@ }, "redis": { "address": "localhost:6379", + "username": "default", "password": "", - "db": 0 + "local": true } } diff --git a/bridge-history-api/internal/config/config.go b/bridge-history-api/internal/config/config.go index 1c135dbd6..4235e3448 100644 --- a/bridge-history-api/internal/config/config.go +++ b/bridge-history-api/internal/config/config.go @@ -33,8 +33,10 @@ 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"` } // Config is the configuration of the bridge history backend diff --git a/common/version/version.go b/common/version/version.go index 08f65b821..0cfd443e5 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.3.45" +var tag = "v4.3.46" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok {