mirror of
https://github.com/safing/portmaster
synced 2025-09-02 02:29:12 +00:00
Configure update registry user agent
This commit is contained in:
parent
e5bad8f067
commit
b6d69ecddd
2 changed files with 18 additions and 2 deletions
|
@ -63,6 +63,7 @@ func init() {
|
|||
flags := rootCmd.PersistentFlags()
|
||||
{
|
||||
flags.StringVar(&dataDir, "data", "", "Configures the data directory. Alternatively, this can also be set via the environment variable PORTMASTER_DATA.")
|
||||
flags.StringVar(®istry.UserAgent, "update-agent", "Start", "Sets the user agent for requests to the update server")
|
||||
flags.IntVar(&maxRetries, "max-retries", 5, "Maximum number of retries when starting a Portmaster component")
|
||||
flags.BoolVar(&stdinSignals, "input-signals", false, "Emulate signals using stdid.")
|
||||
_ = rootCmd.MarkPersistentFlagDirname("data")
|
||||
|
|
|
@ -2,6 +2,7 @@ package updates
|
|||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
|
@ -45,11 +46,18 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
module *modules.Module
|
||||
registry *updater.ResourceRegistry
|
||||
module *modules.Module
|
||||
registry *updater.ResourceRegistry
|
||||
userAgentFromFlag string
|
||||
|
||||
updateTask *modules.Task
|
||||
updateASAP bool
|
||||
disableTaskSchedule bool
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -62,6 +70,8 @@ func init() {
|
|||
module = modules.Register(ModuleName, prep, start, stop, "base")
|
||||
module.RegisterEvent(VersionUpdateEvent)
|
||||
module.RegisterEvent(ResourceUpdateEvent)
|
||||
|
||||
flag.StringVar(&userAgentFromFlag, "update-agent", "", "Sets the user agent for requests to the update server")
|
||||
}
|
||||
|
||||
func prep() error {
|
||||
|
@ -121,11 +131,16 @@ func start() error {
|
|||
UpdateURLs: []string{
|
||||
"https://updates.safing.io",
|
||||
},
|
||||
UserAgent: UserAgent,
|
||||
MandatoryUpdates: mandatoryUpdates,
|
||||
Beta: releaseChannel() == releaseChannelBeta,
|
||||
DevMode: devMode(),
|
||||
Online: true,
|
||||
}
|
||||
if userAgentFromFlag != "" {
|
||||
// override with flag value
|
||||
registry.UserAgent = userAgentFromFlag
|
||||
}
|
||||
// initialize
|
||||
err := registry.Initialize(dataroot.Root().ChildDir("updates", 0755))
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue