Skip to content

Commit

Permalink
Add proxy config to hostinfo
Browse files Browse the repository at this point in the history
Add logging of HTTP / HTTPS_PROXY env
Add proxy output to info_test
  • Loading branch information
F-X64 committed Aug 28, 2024
1 parent 1459866 commit a0f0ed3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hostinfo/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package hostinfo

import (
"fmt"
"os"
"strings"
)

Expand Down Expand Up @@ -55,12 +56,23 @@ func LoadHostInfo() (*HostInfo, error) {
}

func (hi *HostInfo) String() string {
httpProxy := os.Getenv("HTTP_PROXY")
httpsProxy := os.Getenv("HTTPS_PROXY")

proxyInfo := "No proxy set"
if httpProxy != "" {
proxyInfo = fmt.Sprintf("HTTP_PROXY: %s", httpProxy)
} else if httpsProxy != "" {
proxyInfo = fmt.Sprintf("HTTPS_PROXY: %s", httpsProxy)
}

return strings.Join(
[]string{
"HostInfo:",
fmt.Sprintf("| CpuCount: %d", hi.CpuCount),
fmt.Sprintf("| HostName: %s", hi.HostName),
fmt.Sprintf("| HostId: %s", hi.HostId),
fmt.Sprintf("| Proxy: %s", proxyInfo),
fmt.Sprintf("| ExternalOrganization: %s", hi.ExternalOrganization),
fmt.Sprintf("| SocketCount: %s", hi.SocketCount),
fmt.Sprintf("| Product: %s", hi.Product),
Expand Down
1 change: 1 addition & 0 deletions hostinfo/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestHostInfo(t *testing.T) {
"| CpuCount: 64\n" +
"| HostName: host.mock.test\n" +
"| HostId: 01234567-89ab-cdef-0123-456789abcdef\n" +
"| Proxy: No proxy set\n" +
"| ExternalOrganization: 12345678\n" +
"| SocketCount: 3\n" +
"| Product: [394 69]\n" +
Expand Down

0 comments on commit a0f0ed3

Please sign in to comment.