This commit is contained in:
Max Lerebourg
2022-10-17 22:14:49 +02:00
parent 4058836678
commit 44e329cd57
+6 -11
View File
@@ -44,11 +44,10 @@ type Config struct {
ForwardedHeadersCustomName string `json:"forwardedheaderscustomheader,omitempty"` ForwardedHeadersCustomName string `json:"forwardedheaderscustomheader,omitempty"`
UpdateIntervalSeconds int64 `json:"updateIntervalSeconds,omitempty"` UpdateIntervalSeconds int64 `json:"updateIntervalSeconds,omitempty"`
DefaultDecisionSeconds int64 `json:"defaultDecisionSeconds,omitempty"` DefaultDecisionSeconds int64 `json:"defaultDecisionSeconds,omitempty"`
ForwardedHeadersTrustedIPs []string `json:"forwardedheaderstrustedips,omitempty"` ForwardedHeadersTrustedIPs []string `json:"forwardedHeadersTrustedIps,omitempty"`
RedisCacheEnabled bool `json:"rediscacheenabled,omitempty"` RedisCacheEnabled bool `json:"redisCacheEnabled,omitempty"`
RedisCacheAddr string `json:"rediscacheaddr,omitempty"` RedisCacheHost string `json:"redisCacheHost,omitempty"`
RedisCachePort int `json:"rediscacheport,omitempty"` RedisCachePassword string `json:"redisCachePassword,omitempty"`
RedisCachePassword string `json:"rediscachepassword,omitempty"`
} }
// CreateConfig creates the default plugin configuration. // CreateConfig creates the default plugin configuration.
@@ -65,8 +64,7 @@ func CreateConfig() *Config {
ForwardedHeadersTrustedIPs: []string{}, ForwardedHeadersTrustedIPs: []string{},
ForwardedHeadersCustomName: "X-Forwarded-For", ForwardedHeadersCustomName: "X-Forwarded-For",
RedisCacheEnabled: false, RedisCacheEnabled: false,
RedisCacheAddr: "localhost", RedisCacheHost: "redis:6379",
RedisCachePort: 6379,
RedisCachePassword: "", RedisCachePassword: "",
} }
} }
@@ -125,10 +123,7 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h
}, },
} }
if config.RedisCacheEnabled { if config.RedisCacheEnabled {
cache.InitRedisClient(config.RedisCacheAddr, config.RedisCachePort, config.RedisCachePassword) cache.InitRedisClient(config.RedisCacheHost, config.RedisCachePassword)
c, _ := redis.Dial("tcp", ":6379")
defer c.Close()
} }
if config.CrowdsecMode == streamMode { if config.CrowdsecMode == streamMode {
go func() { go func() {