Skip to content

Commit

Permalink
[skip-changelog] Try to whitelist CI for Cloudflare spam-check filters (
Browse files Browse the repository at this point in the history
#1796)

* Provide a way to define extra UserAgent fields via env vars

* Add secret token to User Agent

This will allow to possibly bypass spam-checks on the server side
reducing the jobs failures due to rate limiting.
  • Loading branch information
cmaglie authored Jul 11, 2022
1 parent 6ac5f7a commit 38ee95c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-go-integration-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ jobs:

runs-on: ${{ matrix.operating-system }}

env:
ARDUINO_CLI_USER_AGENT_EXTENSION: ${{ secrets.CLOUDFLARE_SPAMCHECK_BYPASS_TOKEN }}

steps:
# By default, actions/checkout converts the repo's LF line endings to CRLF on the Windows runner.
- name: Disable EOL conversions
Expand Down
11 changes: 9 additions & 2 deletions configuration/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package configuration
import (
"fmt"
"net/url"
"os"
"runtime"

"github.com/arduino/arduino-cli/cli/globals"
Expand All @@ -34,12 +35,18 @@ func UserAgent(settings *viper.Viper) string {
subComponent = " " + subComponent
}

return fmt.Sprintf("%s/%s%s (%s; %s; %s) Commit:%s",
extendedUA := os.Getenv("ARDUINO_CLI_USER_AGENT_EXTENSION")
if extendedUA != "" {
extendedUA = " " + extendedUA
}

return fmt.Sprintf("%s/%s%s (%s; %s; %s) Commit:%s%s",
globals.VersionInfo.Application,
globals.VersionInfo.VersionString,
subComponent,
runtime.GOARCH, runtime.GOOS, runtime.Version(),
globals.VersionInfo.Commit)
globals.VersionInfo.Commit,
extendedUA)
}

// NetworkProxy returns the proxy configuration (mainly used by HTTP clients)
Expand Down

0 comments on commit 38ee95c

Please sign in to comment.