feat(config): update Redis configuration to use TLS in configurre name instead of SSL

pull/2540/head
charlieJ107 2025-06-22 20:39:25 +00:00
parent 72ec062cb0
commit 11c8a0fac3
5 changed files with 16 additions and 15 deletions

4
.gitignore vendored
View File

@ -32,3 +32,7 @@ conf/conf.ini
dist/ dist/
data/ data/
tmp/ tmp/
.devcontainer/.env
.devcontainer/devcontainer.json
.devcontainer/docker-compose.yml
.devcontainer/Dockerfile

View File

@ -329,11 +329,7 @@ func (d *dependency) KV() cache.Driver {
d.kv = cache.NewRedisStore( d.kv = cache.NewRedisStore(
d.Logger(), d.Logger(),
10, 10,
config.Network, config,
config.Server,
config.User,
config.Password,
config.DB,
) )
} else { } else {
d.kv = cache.NewMemoStore(util.DataPath(cache.DefaultCacheFile), d.Logger()) d.kv = cache.NewMemoStore(util.DataPath(cache.DefaultCacheFile), d.Logger())

10
pkg/cache/redis.go vendored
View File

@ -3,11 +3,12 @@ package cache
import ( import (
"bytes" "bytes"
"encoding/gob" "encoding/gob"
"github.com/cloudreve/Cloudreve/v4/pkg/conf"
"github.com/cloudreve/Cloudreve/v4/pkg/logging"
"strconv" "strconv"
"time" "time"
"github.com/cloudreve/Cloudreve/v4/pkg/conf"
"github.com/cloudreve/Cloudreve/v4/pkg/logging"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
) )
@ -45,8 +46,7 @@ func deserializer(value []byte) (any, error) {
} }
// NewRedisStore 创建新的redis存储 // NewRedisStore 创建新的redis存储
func NewRedisStore(l logging.Logger, size int, configProvider conf.ConfigProvider) *RedisStore { func NewRedisStore(l logging.Logger, size int, redisConfig *conf.Redis) *RedisStore {
redisConfig := configProvider.Redis()
return &RedisStore{ return &RedisStore{
pool: &redis.Pool{ pool: &redis.Pool{
MaxIdle: size, MaxIdle: size,
@ -67,7 +67,7 @@ func NewRedisStore(l logging.Logger, size int, configProvider conf.ConfigProvide
redis.DialDatabase(db), redis.DialDatabase(db),
redis.DialPassword(redisConfig.Password), redis.DialPassword(redisConfig.Password),
redis.DialUsername(redisConfig.User), redis.DialUsername(redisConfig.User),
redis.DialUseTLS(redisConfig.UseSSL), redis.DialUseTLS(redisConfig.UseTLS),
redis.DialTLSSkipVerify(redisConfig.TLSSkipVerify), redis.DialTLSSkipVerify(redisConfig.TLSSkipVerify),
) )
if err != nil { if err != nil {

View File

@ -2,12 +2,13 @@ package conf
import ( import (
"fmt" "fmt"
"os"
"strings"
"github.com/cloudreve/Cloudreve/v4/pkg/logging" "github.com/cloudreve/Cloudreve/v4/pkg/logging"
"github.com/cloudreve/Cloudreve/v4/pkg/util" "github.com/cloudreve/Cloudreve/v4/pkg/util"
"github.com/go-ini/ini" "github.com/go-ini/ini"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
"os"
"strings"
) )
const ( const (

View File

@ -74,7 +74,7 @@ type Redis struct {
User string User string
Password string Password string
DB string DB string
UseSSL bool UseTLS bool
TLSSkipVerify bool TLSSkipVerify bool
} }
@ -95,7 +95,7 @@ var RedisConfig = &Redis{
Server: "", Server: "",
Password: "", Password: "",
DB: "0", DB: "0",
UseSSL: false, UseTLS: false,
TLSSkipVerify: true, TLSSkipVerify: true,
} }