Skip to content

Commit 1b49ccd

Browse files
authored
Add cert auth support (#32)
1 parent 731a8ae commit 1b49ccd

File tree

4 files changed

+1246
-182
lines changed

4 files changed

+1246
-182
lines changed

config.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ type bouncerConfig struct {
2121
LogMode string `yaml:"log_mode"`
2222
LogDir string `yaml:"log_dir"`
2323
LogLevel log.Level `yaml:"log_level"`
24-
APIUrl string `yaml:"api_url"`
25-
APIKey string `yaml:"api_key"`
24+
CompressLogs *bool `yaml:"compress_logs,omitempty"`
25+
LogMaxSize int `yaml:"log_max_size,omitempty"`
26+
LogMaxFiles int `yaml:"log_max_files,omitempty"`
27+
LogMaxAge int `yaml:"log_max_age,omitempty"`
2628
CacheRetentionDuration time.Duration `yaml:"cache_retention_duration"`
2729
}
2830

@@ -36,13 +38,16 @@ func NewConfig(configPath string) (*bouncerConfig, error) {
3638
return &bouncerConfig{}, fmt.Errorf("failed to read %s : %v", configPath, err)
3739
}
3840

39-
err = yaml.UnmarshalStrict(configBuff, &config)
41+
err = yaml.Unmarshal(configBuff, &config)
4042
if err != nil {
4143
return &bouncerConfig{}, fmt.Errorf("failed to unmarshal %s : %v", configPath, err)
4244
}
4345

44-
if config.BinPath == "" || config.LogMode == "" {
45-
return &bouncerConfig{}, fmt.Errorf("invalid configuration in %s", configPath)
46+
if config.BinPath == "" {
47+
return &bouncerConfig{}, fmt.Errorf("bin_path is not set")
48+
}
49+
if config.LogMode == "" {
50+
return &bouncerConfig{}, fmt.Errorf("log_mode is not net")
4651
}
4752

4853
_, err = os.Stat(config.BinPath)
@@ -51,7 +56,7 @@ func NewConfig(configPath string) (*bouncerConfig, error) {
5156
}
5257

5358
/*Configure logging*/
54-
if err = types.SetDefaultLoggerConfig(config.LogMode, config.LogDir, config.LogLevel); err != nil {
59+
if err = types.SetDefaultLoggerConfig(config.LogMode, config.LogDir, config.LogLevel, config.LogMaxSize, config.LogMaxFiles, config.LogMaxAge, config.CompressLogs, false); err != nil {
5560
log.Fatal(err.Error())
5661
}
5762
if config.LogMode == "file" {

go.mod

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ module github.com/crowdsecurity/crowdsec-custom-bouncer
33
go 1.14
44

55
require (
6-
github.com/ahmetb/dlog v0.0.0-20170105205344-4fb5f8204f26 // indirect
6+
github.com/antonmedv/expr v1.9.0 // indirect
77
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
8-
github.com/crowdsecurity/crowdsec v1.2.2
9-
github.com/crowdsecurity/go-cs-bouncer v0.0.0-20211102140123-4cf1e1b3f89b
10-
github.com/sirupsen/logrus v1.8.1
8+
github.com/crowdsecurity/crowdsec v1.4.0
9+
github.com/crowdsecurity/go-cs-bouncer v0.0.0-20220720081100-22bbe2d6856f
10+
github.com/crowdsecurity/grokky v0.1.0 // indirect
11+
github.com/go-openapi/spec v0.20.6 // indirect
12+
github.com/go-openapi/strfmt v0.21.3 // indirect
13+
github.com/hashicorp/go-version v1.6.0 // indirect
14+
github.com/sirupsen/logrus v1.9.0
15+
golang.org/x/net v0.0.0-20220708220712-1185a9018129 // indirect
1116
gopkg.in/natefinch/lumberjack.v2 v2.0.0
1217
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637
1318
gopkg.in/yaml.v2 v2.4.0

0 commit comments

Comments
 (0)