Skip to content

Commit 6810f66

Browse files
committed
Use go 1.19 and add prometheus server
1 parent a84adfb commit 6810f66

File tree

7 files changed

+95
-236
lines changed

7 files changed

+95
-236
lines changed

.github/workflows/build-binary-package.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
name: Build and upload binary package
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Set up Go 1.13
13+
- name: Set up Go 1.19
1414
uses: actions/setup-go@v1
1515
with:
16-
go-version: 1.13
16+
go-version: 1.19
1717
id: go
1818
- name: Check out code into the Go module directory
1919
uses: actions/checkout@v2

.github/workflows/go.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
name: Build
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Set up Go 1.13
15+
- name: Set up Go 1.19
1616
uses: actions/setup-go@v1
1717
with:
18-
go-version: 1.13
18+
go-version: 1.19
1919
id: go
2020
- name: Check out code into the Go module directory
2121
uses: actions/checkout@v2

config.go

+26-19
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,33 @@ import (
1313
"gopkg.in/yaml.v2"
1414
)
1515

16+
type PrometheusConfig struct {
17+
Enabled bool `yaml:"enabled"`
18+
ListenAddress string `yaml:"listen_addr"`
19+
ListenPort string `yaml:"listen_port"`
20+
}
21+
1622
type bouncerConfig struct {
17-
BinPath string `yaml:"bin_path"` // path to binary
18-
PidDir string `yaml:"piddir"`
19-
UpdateFrequency string `yaml:"update_frequency"`
20-
IncludeScenariosContaining []string `yaml:"include_scenarios_containing"`
21-
ExcludeScenariosContaining []string `yaml:"exclude_scenarios_containing"`
22-
OnlyIncludeDecisionsFrom []string `yaml:"only_include_decisions_from"`
23-
Daemon bool `yaml:"daemonize"`
24-
LogMode string `yaml:"log_mode"`
25-
LogDir string `yaml:"log_dir"`
26-
LogLevel log.Level `yaml:"log_level"`
27-
LogMaxSize int `yaml:"log_max_size,omitempty"`
28-
LogMaxFiles int `yaml:"log_max_files,omitempty"`
29-
LogMaxAge int `yaml:"log_max_age,omitempty"`
30-
CompressLogs *bool `yaml:"compress_logs,omitempty"`
31-
APIUrl string `yaml:"api_url"`
32-
APIKey string `yaml:"api_key"`
33-
CacheRetentionDuration time.Duration `yaml:"cache_retention_duration"`
34-
FeedViaStdin bool `yaml:"feed_via_stdin"`
35-
TotalRetries int `yaml:"total_retries"`
23+
BinPath string `yaml:"bin_path"` // path to binary
24+
PidDir string `yaml:"piddir"`
25+
UpdateFrequency string `yaml:"update_frequency"`
26+
IncludeScenariosContaining []string `yaml:"include_scenarios_containing"`
27+
ExcludeScenariosContaining []string `yaml:"exclude_scenarios_containing"`
28+
OnlyIncludeDecisionsFrom []string `yaml:"only_include_decisions_from"`
29+
Daemon bool `yaml:"daemonize"`
30+
LogMode string `yaml:"log_mode"`
31+
LogDir string `yaml:"log_dir"`
32+
LogLevel log.Level `yaml:"log_level"`
33+
LogMaxSize int `yaml:"log_max_size,omitempty"`
34+
LogMaxFiles int `yaml:"log_max_files,omitempty"`
35+
LogMaxAge int `yaml:"log_max_age,omitempty"`
36+
CompressLogs *bool `yaml:"compress_logs,omitempty"`
37+
APIUrl string `yaml:"api_url"`
38+
APIKey string `yaml:"api_key"`
39+
CacheRetentionDuration time.Duration `yaml:"cache_retention_duration"`
40+
FeedViaStdin bool `yaml:"feed_via_stdin"`
41+
TotalRetries int `yaml:"total_retries"`
42+
PrometheusConfig PrometheusConfig `yaml:"prometheus"`
3643
}
3744

3845
func NewConfig(configPath string) (*bouncerConfig, error) {

config/crowdsec-custom-bouncer.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ log_max_backups: 3
1515
log_max_age: 30
1616
api_url: http://localhost:8080/
1717
api_key: ${API_KEY}
18+
19+
prometheus:
20+
enabled: true
21+
listen_addr: 127.0.0.1
22+
listen_port: 60602

go.mod

+36-18
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,48 @@
11
module github.com/crowdsecurity/crowdsec-custom-bouncer
22

3-
go 1.14
3+
go 1.19
44

55
require (
6-
github.com/KyleBanks/depth v1.2.1 // indirect
7-
github.com/PuerkitoBio/purell v1.2.0 // indirect
86
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
97
github.com/crowdsecurity/crowdsec v1.4.1
108
github.com/crowdsecurity/go-cs-bouncer v0.0.0-20220817075151-29237cbe9873
11-
github.com/facebook/ent v0.5.0 // indirect
12-
github.com/go-kit/kit v0.10.0 // indirect
13-
github.com/go-openapi/runtime v0.24.1 // indirect
14-
github.com/go-openapi/swag v0.22.3 // indirect
15-
github.com/go-redis/redis v6.15.5+incompatible // indirect
16-
github.com/jamiealquiza/tachymeter v2.0.0+incompatible // indirect
17-
github.com/jinzhu/gorm v1.9.12 // indirect
18-
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
19-
github.com/logrusorgru/grokky v0.0.0-20180829062225-47edf017d42c // indirect
20-
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
21-
github.com/rogpeppe/godef v1.1.2 // indirect
22-
github.com/sevlyar/go-daemon v0.1.5 // indirect
9+
github.com/prometheus/client_golang v1.13.0
2310
github.com/sirupsen/logrus v1.9.0
24-
github.com/vjeantet/grok v1.0.1 // indirect
25-
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c // indirect
26-
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
2711
gopkg.in/natefinch/lumberjack.v2 v2.0.0
2812
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637
2913
gopkg.in/yaml.v2 v2.4.0
3014
)
15+
16+
require (
17+
github.com/antonmedv/expr v1.9.0 // indirect
18+
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
19+
github.com/beorn7/perks v1.0.1 // indirect
20+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
21+
github.com/crowdsecurity/grokky v0.1.0 // indirect
22+
github.com/go-openapi/analysis v0.21.4 // indirect
23+
github.com/go-openapi/errors v0.20.3 // indirect
24+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
25+
github.com/go-openapi/jsonreference v0.20.0 // indirect
26+
github.com/go-openapi/loads v0.21.2 // indirect
27+
github.com/go-openapi/spec v0.20.7 // indirect
28+
github.com/go-openapi/strfmt v0.21.3 // indirect
29+
github.com/go-openapi/swag v0.22.3 // indirect
30+
github.com/go-openapi/validate v0.22.0 // indirect
31+
github.com/golang/protobuf v1.5.2 // indirect
32+
github.com/google/go-querystring v1.1.0 // indirect
33+
github.com/hashicorp/go-version v1.6.0 // indirect
34+
github.com/josharian/intern v1.0.0 // indirect
35+
github.com/mailru/easyjson v0.7.7 // indirect
36+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
37+
github.com/mitchellh/mapstructure v1.5.0 // indirect
38+
github.com/oklog/ulid v1.3.1 // indirect
39+
github.com/pkg/errors v0.9.1 // indirect
40+
github.com/prometheus/client_model v0.2.0 // indirect
41+
github.com/prometheus/common v0.37.0 // indirect
42+
github.com/prometheus/procfs v0.8.0 // indirect
43+
go.mongodb.org/mongo-driver v1.10.1 // indirect
44+
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c // indirect
45+
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
46+
google.golang.org/protobuf v1.28.1 // indirect
47+
gopkg.in/yaml.v3 v3.0.1 // indirect
48+
)

0 commit comments

Comments
 (0)