Skip to content

Commit

Permalink
Merge pull request #20 from sbs2001/main
Browse files Browse the repository at this point in the history
Remove dependency of lapi when running only setup/cleanup
  • Loading branch information
sbs2001 authored Jun 24, 2021
2 parents 410b383 + e907a6e commit 7a46e59
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,8 @@ func main() {
log.Fatal(err)
}

var csLAPI *csbouncer.StreamBouncer
ctx := context.Background()
csLapi := &csbouncer.StreamBouncer{
APIKey: conf.CrowdSecLAPIKey,
APIUrl: conf.CrowdSecLAPIUrl,
TickerInterval: conf.CrowdsecUpdateFrequencyYAML,
}

if err := csLapi.Init(); err != nil {
log.Fatalf(err.Error())
}

zoneLocks := make([]ZoneLock, 0)
for _, account := range conf.CloudflareConfig.Accounts {
Expand Down Expand Up @@ -236,16 +228,26 @@ func main() {
}
}

dispatchTomb.Go(func() error {
go csLapi.Run()
for {
decisions := <-csLapi.Stream
// broadcast decision to each worker
for _, lapiStream := range lapiStreams {
lapiStream <- decisions
}
if !*onlySetup && !*delete {
csLAPI = &csbouncer.StreamBouncer{
APIKey: conf.CrowdSecLAPIKey,
APIUrl: conf.CrowdSecLAPIUrl,
TickerInterval: conf.CrowdsecUpdateFrequencyYAML,
}
})
if err := csLAPI.Init(); err != nil {
log.Fatalf(err.Error())
}
dispatchTomb.Go(func() error {
go csLAPI.Run()
for {
decisions := <-csLAPI.Stream
// broadcast decision to each worker
for _, lapiStream := range lapiStreams {
lapiStream <- decisions
}
}
})
}

stateTomb.Go(func() error {
aliveWorkerCount := len(conf.CloudflareConfig.Accounts)
Expand Down

0 comments on commit 7a46e59

Please sign in to comment.