Skip to content

Commit

Permalink
Add optional redis authorization (t2bot#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
dapi committed Feb 29, 2024
1 parent 4b4eee4 commit 10f131d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/config/models_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ type SentryConfig struct {
}

type RedisConfig struct {
Enabled bool `yaml:"enabled"`
Shards []RedisShardConfig `yaml:"shards,flow"`
DbNum int `default:"0" yaml:"databaseNumber"`
Enabled bool `yaml:"enabled"`
Shards []RedisShardConfig `yaml:"shards,flow"`
DbNum int `default:"0" yaml:"databaseNumber"`
Username string `default:"" yaml:"user"`
Password string `default:"" yaml:"password"`
}

type RedisShardConfig struct {
Expand Down
4 changes: 4 additions & 0 deletions redislib/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func makeConnection() {
client := redis.NewClient(&redis.Options{
DialTimeout: 10 * time.Second,
DB: conf.DbNum,
Username: conf.Username,
Password: conf.Password,
Addr: c.Address,
})
clients = append(clients, client)
Expand All @@ -43,6 +45,8 @@ func makeConnection() {
Addrs: addresses,
DialTimeout: 10 * time.Second,
DB: conf.DbNum,
Username: conf.Username,
Password: conf.Password,
})
rs = redsync.New(pools...)
})
Expand Down

0 comments on commit 10f131d

Please sign in to comment.