diff --git a/README.md b/README.md index a338d2b6..fbd3106c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config.go b/config.go index d26d340b..5c44e17f 100644 --- a/config.go +++ b/config.go @@ -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"` @@ -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 == "" { diff --git a/config/cs-firewall-bouncer.yaml b/config/cs-firewall-bouncer.yaml index 824605b5..ab29fdb0 100644 --- a/config/cs-firewall-bouncer.yaml +++ b/config/cs-firewall-bouncer.yaml @@ -1,5 +1,5 @@ mode: ${BACKEND} -piddir: /var/run/ +pid_dir: /var/run/ update_frequency: 10s daemonize: true log_mode: file