fix(bridge-history-api): add redis tls config InsecureSkipVerify (#1068)

Co-authored-by: colinlyguo <colinlyguo@users.noreply.github.com>
This commit is contained in:
colin
2024-01-05 13:35:19 +08:00
committed by GitHub
parent ab82b79638
commit b96e8778a5
4 changed files with 23 additions and 11 deletions

View File

@@ -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)

View File

@@ -46,6 +46,8 @@
"address": "localhost:6379",
"username": "default",
"password": "",
"local": true
"local": true,
"minIdleConns": 10,
"readTimeoutMs": 500
}
}

View File

@@ -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

View File

@@ -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 {