Skip to content

Commit

Permalink
Merge pull request #46 from vortex14/proxy-service
Browse files Browse the repository at this point in the history
auth for redis implemented
  • Loading branch information
vortex14 authored Nov 11, 2022
2 parents 52579b3 + 7a94c1e commit da83698
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion extensions/servers/gin/domains/proxy/models.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package proxy

import "github.com/vortex14/gotyphoon/interfaces"

type Settings struct {
BlockedTime int
CheckTime int
CheckBlockedTime int
RedisHost string
ConcurrentCheck int
Port int
PrefixNamespace string
CheckHosts []string

interfaces.RedisDetails
}

type Stats struct {
Expand Down
4 changes: 3 additions & 1 deletion extensions/servers/gin/domains/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ func (c *Collection) Init() *Collection {
Config: &interfaces.ServiceRedis{
Name: "Redis proxy data",
Details: interfaces.RedisDetails{
Host: c.Settings.RedisHost, Port: 6379,
Host: c.Settings.RedisDetails.Host,
Port: c.Settings.RedisDetails.Port,
Password: c.Settings.Password,
},
},
}
Expand Down
9 changes: 6 additions & 3 deletions extensions/servers/gin/domains/proxy/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ var (
BlockedTime: BlockedTime,
CheckTime: CheckTime,
CheckBlockedTime: CheckBlockedTime,
RedisHost: "localhost",
ConcurrentCheck: 3,
Port: 11222,
RedisDetails: interfaces.RedisDetails{
Host: "localhost",
Port: 6379,
},
ConcurrentCheck: 3,
Port: 11222,
}
)

Expand Down
6 changes: 3 additions & 3 deletions integrations/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func (s *Service) initClient() {
redisString := fmt.Sprintf("%s:%d", s.Config.GetHost(), s.Config.GetPort())
color.Yellow("init Redis Service %s", redisString)
rdb := redis.NewClient(&redis.Options{
Addr: redisString, // use default Addr
Password: "", // no password set
DB: 0, // use default DB
Addr: redisString, // use default Addr
Password: s.Config.Details.Password, // no password set
DB: 0, // use default DB
})
s.client = rdb
conn := s.connect()
Expand Down
6 changes: 3 additions & 3 deletions interfaces/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ type MapFileObjects map[string]*FileObject
type BuilderOptions builders.BuildOptions

type RedisDetails struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
Password interface{} `yaml:"password"`
Host string `yaml:"host"`
Port int `yaml:"port"`
Password string `yaml:"password"`
}

type ServiceRedis struct {
Expand Down

0 comments on commit da83698

Please sign in to comment.