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:
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
......
......@@ -18,6 +18,7 @@ package configuration
import (
"fmt"
"net/url"
"os"
"runtime"
"github.com/arduino/arduino-cli/cli/globals"
......@@ -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)
......
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