Skip to content

Commit

Permalink
Use go 1.19 and add prometheus server
Browse files Browse the repository at this point in the history
  • Loading branch information
sbs2001 committed Aug 25, 2022
1 parent a84adfb commit 6810f66
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 236 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-binary-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Build and upload binary package
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
- name: Set up Go 1.19
uses: actions/setup-go@v1
with:
go-version: 1.13
go-version: 1.19
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
- name: Set up Go 1.19
uses: actions/setup-go@v1
with:
go-version: 1.13
go-version: 1.19
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down
45 changes: 26 additions & 19 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,33 @@ import (
"gopkg.in/yaml.v2"
)

type PrometheusConfig struct {
Enabled bool `yaml:"enabled"`
ListenAddress string `yaml:"listen_addr"`
ListenPort string `yaml:"listen_port"`
}

type bouncerConfig struct {
BinPath string `yaml:"bin_path"` // path to binary
PidDir string `yaml:"piddir"`
UpdateFrequency string `yaml:"update_frequency"`
IncludeScenariosContaining []string `yaml:"include_scenarios_containing"`
ExcludeScenariosContaining []string `yaml:"exclude_scenarios_containing"`
OnlyIncludeDecisionsFrom []string `yaml:"only_include_decisions_from"`
Daemon bool `yaml:"daemonize"`
LogMode string `yaml:"log_mode"`
LogDir string `yaml:"log_dir"`
LogLevel log.Level `yaml:"log_level"`
LogMaxSize int `yaml:"log_max_size,omitempty"`
LogMaxFiles int `yaml:"log_max_files,omitempty"`
LogMaxAge int `yaml:"log_max_age,omitempty"`
CompressLogs *bool `yaml:"compress_logs,omitempty"`
APIUrl string `yaml:"api_url"`
APIKey string `yaml:"api_key"`
CacheRetentionDuration time.Duration `yaml:"cache_retention_duration"`
FeedViaStdin bool `yaml:"feed_via_stdin"`
TotalRetries int `yaml:"total_retries"`
BinPath string `yaml:"bin_path"` // path to binary
PidDir string `yaml:"piddir"`
UpdateFrequency string `yaml:"update_frequency"`
IncludeScenariosContaining []string `yaml:"include_scenarios_containing"`
ExcludeScenariosContaining []string `yaml:"exclude_scenarios_containing"`
OnlyIncludeDecisionsFrom []string `yaml:"only_include_decisions_from"`
Daemon bool `yaml:"daemonize"`
LogMode string `yaml:"log_mode"`
LogDir string `yaml:"log_dir"`
LogLevel log.Level `yaml:"log_level"`
LogMaxSize int `yaml:"log_max_size,omitempty"`
LogMaxFiles int `yaml:"log_max_files,omitempty"`
LogMaxAge int `yaml:"log_max_age,omitempty"`
CompressLogs *bool `yaml:"compress_logs,omitempty"`
APIUrl string `yaml:"api_url"`
APIKey string `yaml:"api_key"`
CacheRetentionDuration time.Duration `yaml:"cache_retention_duration"`
FeedViaStdin bool `yaml:"feed_via_stdin"`
TotalRetries int `yaml:"total_retries"`
PrometheusConfig PrometheusConfig `yaml:"prometheus"`
}

func NewConfig(configPath string) (*bouncerConfig, error) {
Expand Down
5 changes: 5 additions & 0 deletions config/crowdsec-custom-bouncer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ log_max_backups: 3
log_max_age: 30
api_url: http://localhost:8080/
api_key: ${API_KEY}

prometheus:
enabled: true
listen_addr: 127.0.0.1
listen_port: 60602
54 changes: 36 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,30 +1,48 @@
module github.com/crowdsecurity/crowdsec-custom-bouncer

go 1.14
go 1.19

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.2.0 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/crowdsecurity/crowdsec v1.4.1
github.com/crowdsecurity/go-cs-bouncer v0.0.0-20220817075151-29237cbe9873
github.com/facebook/ent v0.5.0 // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-openapi/runtime v0.24.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-redis/redis v6.15.5+incompatible // indirect
github.com/jamiealquiza/tachymeter v2.0.0+incompatible // indirect
github.com/jinzhu/gorm v1.9.12 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/logrusorgru/grokky v0.0.0-20180829062225-47edf017d42c // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
github.com/rogpeppe/godef v1.1.2 // indirect
github.com/sevlyar/go-daemon v0.1.5 // indirect
github.com/prometheus/client_golang v1.13.0
github.com/sirupsen/logrus v1.9.0
github.com/vjeantet/grok v1.0.1 // indirect
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c // indirect
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/antonmedv/expr v1.9.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/crowdsecurity/grokky v0.1.0 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/spec v0.20.7 // indirect
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.22.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
go.mongodb.org/mongo-driver v1.10.1 // indirect
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c // indirect
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 6810f66

Please sign in to comment.