From 72c59c0e5223b01b4b5d20a058526de44a9a7778 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 13 Apr 2023 16:28:43 +0200 Subject: [PATCH] Improve user agents --- cmds/portmaster-core/main.go | 6 ++++++ cmds/portmaster-start/main.go | 2 ++ updates/main.go | 7 ++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmds/portmaster-core/main.go b/cmds/portmaster-core/main.go index a6f6cade..3fbc0994 100644 --- a/cmds/portmaster-core/main.go +++ b/cmds/portmaster-core/main.go @@ -2,12 +2,15 @@ package main import ( + "fmt" "os" + "runtime" "github.com/safing/portbase/info" "github.com/safing/portbase/log" "github.com/safing/portbase/metrics" "github.com/safing/portbase/run" + "github.com/safing/portmaster/updates" "github.com/safing/spn/conf" // Include packages here. @@ -29,6 +32,9 @@ func main() { // Configure metrics. _ = metrics.SetNamespace("portmaster") + // Configure user agent. + updates.UserAgent = fmt.Sprintf("Portmaster Core (%s %s)", runtime.GOOS, runtime.GOARCH) + // enable SPN client mode conf.EnableClient(true) diff --git a/cmds/portmaster-start/main.go b/cmds/portmaster-start/main.go index 1de49ec6..5b0ad97c 100644 --- a/cmds/portmaster-start/main.go +++ b/cmds/portmaster-start/main.go @@ -8,6 +8,7 @@ import ( "os" "os/signal" "path/filepath" + "runtime" "strings" "syscall" @@ -34,6 +35,7 @@ var ( UpdateURLs: []string{ "https://updates.safing.io", }, + UserAgent: fmt.Sprintf("Portmaster Start (%s %s)", runtime.GOOS, runtime.GOARCH), Verification: helper.VerificationConfig, DevMode: false, Online: true, // is disabled later based on command diff --git a/updates/main.go b/updates/main.go index 6012b509..8ae81af5 100644 --- a/updates/main.go +++ b/updates/main.go @@ -57,9 +57,10 @@ var ( // UserAgent is an HTTP User-Agent that is used to add // more context to requests made by the registry when // fetching resources from the update server. - UserAgent = "Core" + UserAgent = fmt.Sprintf("Portmaster (%s %s)", runtime.GOOS, runtime.GOARCH) - // Explicitly disables automatic software updates. Used in android. + // DisableSoftwareAutoUpdate specifies whether software updates should be disabled. + // This is used on Android, as it will never require binary updates. DisableSoftwareAutoUpdate = false ) @@ -250,7 +251,7 @@ func checkForUpdates(ctx context.Context) (err error) { } defer func() { - // Resolve any error and and send success notification. + // Resolve any error and send success notification. if err == nil { log.Infof("updates: successfully checked for updates") notifyUpdateSuccess(forcedUpdate)