Skip to content

Commit

Permalink
support passing redis network and redis username to redis client (#576)
Browse files Browse the repository at this point in the history
Signed-off-by: Jat <[email protected]>
  • Loading branch information
jat001 authored Jan 12, 2024
1 parent 4f1dafa commit d1e5762
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions common/limiter/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down
4 changes: 3 additions & 1 deletion common/limiter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 4 additions & 2 deletions release/config/config.yml.example
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d1e5762

Please sign in to comment.