mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-07-21 11:38:59 +02:00
🍱 fix before version
This commit is contained in:
@@ -57,7 +57,7 @@ At each start of synchronisation, the middleware will wait a random number of se
|
|||||||
- Enabled
|
- Enabled
|
||||||
- bool
|
- bool
|
||||||
- enable the plugin
|
- enable the plugin
|
||||||
- default: true
|
- default: false
|
||||||
- LogLevel
|
- LogLevel
|
||||||
- string
|
- string
|
||||||
- default: `INFO`, expected value are: `INFO`, `DEBUG`
|
- default: `INFO`, expected value are: `INFO`, `DEBUG`
|
||||||
|
|||||||
+2
-4
@@ -46,7 +46,6 @@ type Config struct {
|
|||||||
ForwardedHeadersTrustedIPs []string `json:"forwardedHeadersTrustedIps,omitempty"`
|
ForwardedHeadersTrustedIPs []string `json:"forwardedHeadersTrustedIps,omitempty"`
|
||||||
RedisCacheEnabled bool `json:"redisCacheEnabled,omitempty"`
|
RedisCacheEnabled bool `json:"redisCacheEnabled,omitempty"`
|
||||||
RedisCacheHost string `json:"redisCacheHost,omitempty"`
|
RedisCacheHost string `json:"redisCacheHost,omitempty"`
|
||||||
RedisCachePassword string `json:"redisCachePassword,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateConfig creates the default plugin configuration.
|
// CreateConfig creates the default plugin configuration.
|
||||||
@@ -54,7 +53,7 @@ func CreateConfig() *Config {
|
|||||||
return &Config{
|
return &Config{
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
LogLevel: "INFO",
|
LogLevel: "INFO",
|
||||||
CrowdsecMode: streamMode,
|
CrowdsecMode: liveMode,
|
||||||
CrowdsecLapiScheme: "http",
|
CrowdsecLapiScheme: "http",
|
||||||
CrowdsecLapiHost: "crowdsec:8080",
|
CrowdsecLapiHost: "crowdsec:8080",
|
||||||
CrowdsecLapiKey: "",
|
CrowdsecLapiKey: "",
|
||||||
@@ -64,7 +63,6 @@ func CreateConfig() *Config {
|
|||||||
ForwardedHeadersCustomName: "X-Forwarded-For",
|
ForwardedHeadersCustomName: "X-Forwarded-For",
|
||||||
RedisCacheEnabled: false,
|
RedisCacheEnabled: false,
|
||||||
RedisCacheHost: "redis:6379",
|
RedisCacheHost: "redis:6379",
|
||||||
RedisCachePassword: "",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +120,7 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
if config.RedisCacheEnabled {
|
if config.RedisCacheEnabled {
|
||||||
cache.InitRedisClient(config.RedisCacheHost, config.RedisCachePassword)
|
cache.InitRedisClient(config.RedisCacheHost)
|
||||||
}
|
}
|
||||||
if config.CrowdsecMode == streamMode && ticker == nil {
|
if config.CrowdsecMode == streamMode && ticker == nil {
|
||||||
ticker = startTicker(config, func() {
|
ticker = startTicker(config, func() {
|
||||||
|
|||||||
+2
-2
@@ -29,7 +29,7 @@ services:
|
|||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
# Definition of the router
|
# Definition of the router
|
||||||
- "traefik.http.routers.router1.rule=Host(`localhost`) && Path(`/foo`)"
|
- "traefik.http.routers.router1.rule=Path(`/foo`)"
|
||||||
- "traefik.http.routers.router1.entrypoints=web"
|
- "traefik.http.routers.router1.entrypoints=web"
|
||||||
- "traefik.http.routers.router1.middlewares=crowdsec2@docker"
|
- "traefik.http.routers.router1.middlewares=crowdsec2@docker"
|
||||||
# Definition of the service
|
# Definition of the service
|
||||||
@@ -47,7 +47,7 @@ services:
|
|||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
# Definition of the router
|
# Definition of the router
|
||||||
- "traefik.http.routers.router2.rule=Host(`localhost`) && Path(`/bar`)"
|
- "traefik.http.routers.router2.rule=Path(`/bar`)"
|
||||||
- "traefik.http.routers.router2.entrypoints=web"
|
- "traefik.http.routers.router2.entrypoints=web"
|
||||||
- "traefik.http.routers.router2.middlewares=crowdsec2@docker"
|
- "traefik.http.routers.router2.middlewares=crowdsec2@docker"
|
||||||
# Definition of the service
|
# Definition of the service
|
||||||
|
|||||||
Vendored
+1
-1
@@ -86,7 +86,7 @@ func SetDecision(clientIP string, isBanned bool, duration int64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitRedisClient(host string, password string) {
|
func InitRedisClient(host string) {
|
||||||
redisEnabled = true
|
redisEnabled = true
|
||||||
redis.Init(host)
|
redis.Init(host)
|
||||||
logger.Debug("connect to redis")
|
logger.Debug("connect to redis")
|
||||||
|
|||||||
Reference in New Issue
Block a user