Skip to content

Commit

Permalink
Merge pull request #38 from crowdsecurity/fix_piddir_directive
Browse files Browse the repository at this point in the history
update piddir to pid_dir in configuration
  • Loading branch information
registergoofy authored Apr 15, 2021
2 parents 58744a1 + 269c628 commit 1c94ce7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $ vim /etc/crowdsec/cs-firewall-bouncer/cs-firewall-bouncer.yaml

```yaml
mode: iptables
piddir: /var/run/
pid_dir: /var/run/
update_frequency: 10s
daemonize: true
log_mode: file
Expand Down
11 changes: 8 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

type bouncerConfig struct {
Mode string `yaml:"mode"` //ipset,iptables,tc
PidDir string `yaml:"piddir"`
PidDir string `yaml:"pid_dir"`
UpdateFrequency string `yaml:"update_frequency"`
Daemon bool `yaml:"daemonize"`
LogMode string `yaml:"log_mode"`
Expand All @@ -39,12 +39,17 @@ func NewConfig(configPath string) (*bouncerConfig, error) {
return &bouncerConfig{}, fmt.Errorf("failed to read %s : %v", configPath, err)
}

err = yaml.UnmarshalStrict(configBuff, &config)
err = yaml.Unmarshal(configBuff, &config)
if err != nil {
return &bouncerConfig{}, fmt.Errorf("failed to unmarshal %s : %v", configPath, err)
}

if config.Mode == "" || config.PidDir == "" || config.LogMode == "" {
if config.PidDir == "" {
log.Warningf("missing 'pid_dir' directive in '%s', using default: '/var/run/'", configPath)
config.PidDir = "/var/run/"
}

if config.Mode == "" || config.LogMode == "" {
return &bouncerConfig{}, fmt.Errorf("invalid configuration in %s", configPath)
}
if config.DenyLog && config.DenyLogPrefix == "" {
Expand Down
2 changes: 1 addition & 1 deletion config/cs-firewall-bouncer.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mode: ${BACKEND}
piddir: /var/run/
pid_dir: /var/run/
update_frequency: 10s
daemonize: true
log_mode: file
Expand Down

0 comments on commit 1c94ce7

Please sign in to comment.