From d1e5762937a287f9c590f34686a0ce3b660f0087 Mon Sep 17 00:00:00 2001 From: Jat Date: Fri, 12 Jan 2024 22:22:28 +0800 Subject: [PATCH] support passing redis network and redis username to redis client (#576) Signed-off-by: Jat --- common/limiter/limiter.go | 2 ++ common/limiter/model.go | 4 +++- release/config/config.yml.example | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/limiter/limiter.go b/common/limiter/limiter.go index 42bb97b..97ce234 100644 --- a/common/limiter/limiter.go +++ b/common/limiter/limiter.go @@ -66,7 +66,9 @@ func (l *Limiter) AddInboundLimiter(tag string, nodeSpeedLimit uint64, userList // init redis store rs := redisStore.NewRedis(redis.NewClient( &redis.Options{ + Network: globalLimit.RedisNetwork, Addr: globalLimit.RedisAddr, + Username: globalLimit.RedisUsername, Password: globalLimit.RedisPassword, DB: globalLimit.RedisDB, }), diff --git a/common/limiter/model.go b/common/limiter/model.go index 569d1fc..a8cc3ad 100644 --- a/common/limiter/model.go +++ b/common/limiter/model.go @@ -2,7 +2,9 @@ package limiter type GlobalDeviceLimitConfig struct { Enable bool `mapstructure:"Enable"` - RedisAddr string `mapstructure:"RedisAddr"` // host:port + RedisNetwork string `mapstructure:"RedisNetwork"` // tcp or unix + RedisAddr string `mapstructure:"RedisAddr"` // host:port, or /path/to/unix.sock + RedisUsername string `mapstructure:"RedisUsername"` RedisPassword string `mapstructure:"RedisPassword"` RedisDB int `mapstructure:"RedisDB"` Timeout int `mapstructure:"Timeout"` diff --git a/release/config/config.yml.example b/release/config/config.yml.example index 4f6e540..5a02333 100644 --- a/release/config/config.yml.example +++ b/release/config/config.yml.example @@ -1,5 +1,5 @@ Log: - Level: warning # Log level: none, error, warning, info, debug + Level: warning # Log level: none, error, warning, info, debug AccessPath: # /etc/XrayR/access.Log ErrorPath: # /etc/XrayR/error.log DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.github.io/config/dns.html for help @@ -40,7 +40,9 @@ Nodes: LimitDuration: 0 # How many minutes will the limiting last (unit: minute) GlobalDeviceLimitConfig: Enable: false # Enable the global device limit of a user - RedisAddr: 127.0.0.1:6379 # The redis server address + RedisNetwork: tcp # Redis protocol, tcp or unix + RedisAddr: 127.0.0.1:6379 # Redis server address, or unix socket path + RedisUsername: # Redis username RedisPassword: YOUR PASSWORD # Redis password RedisDB: 0 # Redis DB Timeout: 5 # Timeout for redis request