diff --git a/proxy/debug.go b/proxy/debug.go index 3e7c29e..8430d06 100644 --- a/proxy/debug.go +++ b/proxy/debug.go @@ -21,9 +21,14 @@ func mapCmdsToStr(commands []*util.Command) string { func Debug() { proxy, _ := ReadSystemProxy() + proxyServer := proxy.Server + if proxyServer == "" { + proxyServer = "[N/A]" + } + fmt.Println("\nSystem Proxy:") fmt.Printf("Enabled: %t\n", proxy.Enabled) - fmt.Printf("Server: %s\n\n", proxy.Server) + fmt.Printf("Server: %s\n\n", proxyServer) configs, _ := util.ReadConfigs() for _, config := range configs { diff --git a/proxy/util.go b/proxy/util.go index bb74169..59f0e14 100644 --- a/proxy/util.go +++ b/proxy/util.go @@ -88,8 +88,10 @@ func ReadSystemProxy() (*Proxy, error) { } // Use entire value if singular server + proxy := &Proxy{Enabled: enabled, Server: ""} if !strings.ContainsAny(servers, ";=") { - return &Proxy{Enabled: enabled, Server: servers}, nil + proxy.Server = servers + return proxy, nil } // Map proxy servers into dictionary @@ -103,16 +105,18 @@ func ReadSystemProxy() (*Proxy, error) { // Grab HTTP proxy server first if serverDict["http"] != "" { - return &Proxy{Enabled: enabled, Server: serverDict["http"]}, nil + proxy.Server = serverDict["http"] + return proxy, nil } // Grab HTTP proxy server second if serverDict["https"] != "" { - return &Proxy{Enabled: enabled, Server: serverDict["https"]}, nil + proxy.Server = serverDict["https"] + return proxy, nil } - // Throw error on no usable proxy server - return nil, errors.New("You need to configure either HTTP or HTTPS proxy servers to proceed.") + // Return with empty proxy server ("discarded"; not detected) + return proxy, nil } func SetSystemProxy(state bool) error {