diff --git a/README.md b/README.md index 3857576..f77581e 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ At each start of synchronisation, the middleware will wait a random number of se - enable the plugin - CrowdsecMode - string - - default: `stream`, expected value are: `none`, `live`, `stream` + - default: `live`, expected value are: `none`, `live`, `stream` - CrowdsecLapiScheme - string - default: `http`, expected value are: `http`, `https` diff --git a/bouncer.go b/bouncer.go index a40f8ee..47406bc 100644 --- a/bouncer.go +++ b/bouncer.go @@ -32,20 +32,20 @@ const ( // Config the plugin configuration. type Config struct { - Enabled bool `json:"enabled,omitempty"` - CrowdsecMode string `json:"crowdsecMode,omitempty"` - CrowdsecLapiScheme string `json:"crowdsecLapiScheme,omitempty"` - CrowdsecLapiHost string `json:"crowdsecLapiHost,omitempty"` - CrowdsecLapiKey string `json:"crowdsecLapiKey,omitempty"` - UpdateIntervalSeconds int64 `json:"updateIntervalSeconds,omitempty"` - DefaultDecisionSeconds int64 `json:"defaultDecisionSeconds,omitempty"` + Enabled bool `json:"enabled,omitempty"` + CrowdsecMode string `json:"crowdsecMode,omitempty"` + CrowdsecLapiScheme string `json:"crowdsecLapiScheme,omitempty"` + CrowdsecLapiHost string `json:"crowdsecLapiHost,omitempty"` + CrowdsecLapiKey string `json:"crowdsecLapiKey,omitempty"` + UpdateIntervalSeconds int64 `json:"updateIntervalSeconds,omitempty"` + DefaultDecisionSeconds int64 `json:"defaultDecisionSeconds,omitempty"` } // CreateConfig creates the default plugin configuration. func CreateConfig() *Config { return &Config{ Enabled: false, - CrowdsecMode: noneMode, + CrowdsecMode: liveMode, CrowdsecLapiScheme: "http", CrowdsecLapiHost: "crowdsec:8080", CrowdsecLapiKey: "", diff --git a/bouncer_test.go b/bouncer_test.go index 1710947..6babd3f 100644 --- a/bouncer_test.go +++ b/bouncer_test.go @@ -1,22 +1,20 @@ -package crowdsec_bouncer_traefik_plugin_test +package crowdsec_bouncer_traefik_plugin import ( "context" "net/http" "net/http/httptest" "testing" - - crowdsec_bouncer_traefik_plugin "github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin" ) func TestCrowdSec(t *testing.T) { - cfg := crowdsec_bouncer_traefik_plugin.CreateConfig() - cfg.CrowdsecLapiKey = "caca" + cfg := CreateConfig() + cfg.CrowdsecLapiKey = "test" ctx := context.Background() next := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {}) - handler, err := crowdsec_bouncer_traefik_plugin.New(ctx, next, cfg, "demo-plugin") + handler, err := New(ctx, next, cfg, "demo-plugin") if err != nil { t.Fatal(err) }