Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make some configurations resilient to empty settings
  • Loading branch information
cmaglie committed May 20, 2022
commit bc0d42ab5202087580b8313b5e76382f39571ac6
7 changes: 5 additions & 2 deletions configuration/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import (

// UserAgent returns the user agent (mainly used by HTTP clients)
func UserAgent(settings *viper.Viper) string {
subComponent := settings.GetString("network.user_agent_ext")
subComponent := ""
if settings != nil {
subComponent = settings.GetString("network.user_agent_ext")
}
if subComponent != "" {
subComponent = " " + subComponent
}
Expand All @@ -41,7 +44,7 @@ func UserAgent(settings *viper.Viper) string {

// NetworkProxy returns the proxy configuration (mainly used by HTTP clients)
func NetworkProxy(settings *viper.Viper) (*url.URL, error) {
if !settings.IsSet("network.proxy") {
if settings == nil || !settings.IsSet("network.proxy") {
return nil, nil
}
if proxyConfig := settings.GetString("network.proxy"); proxyConfig == "" {
Expand Down