Skip to content

Commit

Permalink
Merge pull request #27 from sbs2001/main
Browse files Browse the repository at this point in the history
fix issues #22, #23, #24, #25, #26
  • Loading branch information
sbs2001 authored Jun 28, 2021
2 parents 7e8adc6 + 722bc5e commit 7cda6bd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ systemctl status cs-cloudflare-bouncer

## From source

:warning: requires go >= 1.13
:warning: requires go >= 1.16

```bash
make release
Expand Down
12 changes: 7 additions & 5 deletions cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,15 @@ func (worker *CloudflareWorker) insertDecision(decision *models.Decision, decisi
worker.Logger.Debugf("ignored new decision with scope=%s, type=%s, value=%s", *decision.Scope, *decision.Type, *decision.Value)
return
}
decisionStatus := "new"
if decisionIsExpired {
decisionStatus = "expired"
}
worker.Logger.Infof("found %s decision with value=%s, scope=%s, type=%s", decisionStatus, *decision.Value, *decision.Scope, *decision.Type)
*container = append(*container, decision)
}

func (worker *CloudflareWorker) CollectLAPIStream(streamDecision *models.DecisionsStreamResponse) {
worker.Logger.Infof("received %d decisions, %d are new , %d are expired",
len(streamDecision.New)+len(streamDecision.Deleted), len(streamDecision.New), len(streamDecision.Deleted),
)
for _, decision := range streamDecision.New {
worker.insertDecision(decision, false)
}
Expand Down Expand Up @@ -689,7 +691,7 @@ func (worker *CloudflareWorker) UpdateRules() error {
for action, state := range worker.CFStateByAction {
if !worker.CFStateByAction[action].UpdateExpr() {
// expression is still same, why bother.
worker.Logger.Infof("rule for %s action is unchanged", action)
worker.Logger.Debugf("rule for %s action is unchanged", action)
continue
}
stateIsNew = true
Expand Down Expand Up @@ -758,7 +760,7 @@ func (worker *CloudflareWorker) Run() error {
}

case decisions := <-worker.LAPIStream:
worker.Logger.Info("collecting decisions from LAPI")
worker.Logger.Debug("collecting decisions from LAPI")
worker.CollectLAPIStream(decisions)

}
Expand Down
1 change: 0 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func NewConfig(configPath string) (*bouncerConfig, error) {
zoneIdSet[zone.ID] = true

}

}
/*Configure logging*/
if err = types.SetDefaultLoggerConfig(config.LogMode, config.LogDir, config.LogLevel); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func main() {
log.Fatal(err)
}

if *delete || *onlySetup {
log.SetOutput(os.Stdout)
}

var csLAPI *csbouncer.StreamBouncer
ctx := context.Background()

Expand Down
22 changes: 4 additions & 18 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,7 @@ if ! [ $(id -u) = 0 ]; then
exit 1
fi

if [[ $# -eq 0 ]]; then
install_bouncer
${EDITOR:-vi} "${CONFIG_DIR}cs-cloudflare-bouncer.yaml"
start_service
exit 0
else
key="${1}"

if [[ ${key} == "--unattended" ]]; then
install_bouncer
echo "Please provide your Cloudflare credentials at ${CONFIG_DIR}cs-cloudflare-bouncer.yaml"
echo "After configuration run the command 'systemctl start cs-cloudflare-bouncer.service' to start the bouncer"
elif [[ ${key} == "-h" ]]; then
show_help
else
echo "Unknown argument ${key}."
fi
fi
install_bouncer
echo "Please configure '${CONFIG_DIR}cs-cloudflare-bouncer.yaml'."
echo "Configuration can be autogenerated using /usr/local/bin/cs-cloudflare-bouncer -g <CF_TOKEN_1>,<CF_TOKEN_2> "
echo "After configuration run the command 'systemctl start cs-cloudflare-bouncer.service' to start the bouncer"

0 comments on commit 7cda6bd

Please sign in to comment.