Unverified Commit 38ee95cc authored by Cristian Maglie's avatar Cristian Maglie Committed by GitHub

[skip-changelog] Try to whitelist CI for Cloudflare spam-check filters (#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.
parent 6ac5f7a3
...@@ -84,6 +84,9 @@ jobs: ...@@ -84,6 +84,9 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
env:
ARDUINO_CLI_USER_AGENT_EXTENSION: ${{ secrets.CLOUDFLARE_SPAMCHECK_BYPASS_TOKEN }}
steps: steps:
# By default, actions/checkout converts the repo's LF line endings to CRLF on the Windows runner. # By default, actions/checkout converts the repo's LF line endings to CRLF on the Windows runner.
- name: Disable EOL conversions - name: Disable EOL conversions
......
...@@ -18,6 +18,7 @@ package configuration ...@@ -18,6 +18,7 @@ package configuration
import ( import (
"fmt" "fmt"
"net/url" "net/url"
"os"
"runtime" "runtime"
"github.com/arduino/arduino-cli/cli/globals" "github.com/arduino/arduino-cli/cli/globals"
...@@ -34,12 +35,18 @@ func UserAgent(settings *viper.Viper) string { ...@@ -34,12 +35,18 @@ func UserAgent(settings *viper.Viper) string {
subComponent = " " + subComponent 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.Application,
globals.VersionInfo.VersionString, globals.VersionInfo.VersionString,
subComponent, subComponent,
runtime.GOARCH, runtime.GOOS, runtime.Version(), runtime.GOARCH, runtime.GOOS, runtime.Version(),
globals.VersionInfo.Commit) globals.VersionInfo.Commit,
extendedUA)
} }
// NetworkProxy returns the proxy configuration (mainly used by HTTP clients) // NetworkProxy returns the proxy configuration (mainly used by HTTP clients)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment