Skip to content

Commit

Permalink
🔧 Add conf variable: CrowdsecStreamTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuHa committed Aug 18, 2023
1 parent 13c209b commit fd1afe4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type Bouncer struct {
crowdsecScenarios []string
updateInterval int64
defaultDecisionTimeout int64
CrowdsecStreamTimeout int64
customHeader string
crowdsecStreamRoute string
crowdsecHeader string
Expand All @@ -83,6 +84,10 @@ func New(ctx context.Context, next http.Handler, config *configuration.Config, n
var tlsConfig *tls.Config
crowdsecStreamRoute := ""
crowdsecHeader := ""
// here we have GetVariable which returns a string
crowdsecStreamTimeoutStr, _ := configuration.GetVariable(config, "CrowdsecStreamTimeout")
// I would had a test that the value can be converted to int
fmt.Sscan(crowdsecStreamTimeoutStr, &config.CrowdsecStreamTimeout)
if config.CrowdsecMode == configuration.AloneMode {
config.CrowdsecCapiMachineID, _ = configuration.GetVariable(config, "CrowdsecCapiMachineID")
config.CrowdsecCapiPassword, _ = configuration.GetVariable(config, "CrowdsecCapiPassword")
Expand Down
2 changes: 2 additions & 0 deletions pkg/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Config struct {
CrowdsecCapiPassword string `json:"crowdsecCapiPassword,omitempty"`
CrowdsecCapiPasswordFile string `json:"crowdsecCapiPasswordFile,omitempty"`
CrowdsecCapiScenarios []string `json:"crowdsecCapiScenarios,omitempty"`
CrowdsecStreamTimeout int64 `json:"crowdsecStreamTimeout,omitempty"`
UpdateIntervalSeconds int64 `json:"updateIntervalSeconds,omitempty"`
DefaultDecisionSeconds int64 `json:"defaultDecisionSeconds,omitempty"`
ForwardedHeadersCustomName string `json:"forwardedheaderscustomheader,omitempty"`
Expand Down Expand Up @@ -79,6 +80,7 @@ func New() *Config {
CrowdsecLapiHost: "crowdsec:8080",
CrowdsecLapiKey: "",
CrowdsecLapiTLSInsecureVerify: false,
CrowdsecStreamTimeout: 10,
UpdateIntervalSeconds: 60,
DefaultDecisionSeconds: 60,
ForwardedHeadersCustomName: "X-Forwarded-For",
Expand Down

0 comments on commit fd1afe4

Please sign in to comment.