Skip to content

Commit

Permalink
Merge pull request crowdsecurity#16 from sbs2001/main
Browse files Browse the repository at this point in the history
Improve logging levels. Imporve config handling in rpm build
  • Loading branch information
buixor authored Jul 1, 2021
2 parents 3595a61 + 20a7e59 commit e5b7f00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ func (c *customBouncer) Add(decision *models.Decision) error {
if err != nil {
return err
}
log.Printf("custom [%s] : add ban on %s for %s sec (%s)", c.path, *decision.Value, strconv.Itoa(int(banDuration.Seconds())), *decision.Scenario)
log.Debugf("custom [%s] : add ban on %s for %s sec (%s)", c.path, *decision.Value, strconv.Itoa(int(banDuration.Seconds())), *decision.Scenario)
str, err := serializeDecision(decision)
if err != nil {
log.Warningf("serialize: %s", err)
}
cmd := exec.Command(c.path, "add", *decision.Value, strconv.Itoa(int(banDuration.Seconds())), *decision.Scenario, str)
if out, err := cmd.CombinedOutput(); err != nil {
log.Infof("Error in 'add' command (%s): %v --> %s", cmd.String(), err, string(out))
log.Errorf("Error in 'add' command (%s): %v --> %s", cmd.String(), err, string(out))
}
c.newDecisionValueSet[decisionToDecisionKey(decision)] = struct{}{}
return nil
Expand All @@ -77,10 +77,10 @@ func (c *customBouncer) Delete(decision *models.Decision) error {
if err != nil {
log.Warningf("serialize: %s", err)
}
log.Printf("custom [%s] : del ban on %s for %s sec (%s)", c.path, *decision.Value, strconv.Itoa(int(banDuration.Seconds())), *decision.Scenario)
log.Debugf("custom [%s] : del ban on %s for %s sec (%s)", c.path, *decision.Value, strconv.Itoa(int(banDuration.Seconds())), *decision.Scenario)
cmd := exec.Command(c.path, "del", *decision.Value, strconv.Itoa(int(banDuration.Seconds())), *decision.Scenario, str)
if out, err := cmd.CombinedOutput(); err != nil {
log.Infof("Error in 'del' command (%s): %v --> %s", cmd.String(), err, string(out))
log.Errorf("Error in 'del' command (%s): %v --> %s", cmd.String(), err, string(out))
}
c.expiredDecisionValueSet[decisionToDecisionKey(decision)] = struct{}{}
return nil
Expand Down
2 changes: 1 addition & 1 deletion rpm/SPECS/crowdsec-custom-bouncer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ rm -rf %{buildroot}
%defattr(-,root,root,-)
/usr/bin/%{name}
%{_unitdir}/%{name}.service
%config /etc/crowdsec/%{name}/%{name}.yaml
%config(noreplace) /etc/crowdsec/%{name}/%{name}.yaml


%post
Expand Down

0 comments on commit e5b7f00

Please sign in to comment.