Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.

Commit 62d27e9

Browse files
authored
Merge pull request #32 from philips-software/feature/proxy-support
Detect and use environment set proxies
2 parents cf4bb13 + 168c0b4 commit 62d27e9

File tree

8 files changed

+38
-15
lines changed

8 files changed

+38
-15
lines changed

audit/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ func newClient(httpClient *http.Client, config *Config) (*Client, error) {
6969
var err error
7070

7171
if httpClient == nil {
72-
httpClient = apmhttp.WrapClient(http.DefaultClient)
72+
c := &http.Client{
73+
Transport: &http.Transport{
74+
Proxy: http.ProxyFromEnvironment,
75+
},
76+
}
77+
httpClient = apmhttp.WrapClient(c)
7378
}
7479

7580
c := &Client{httpClient: httpClient, config: config, UserAgent: userAgent}

cartel/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ func doAutoconf(config *Config) {
9595
func NewClient(httpClient *http.Client, config *Config) (*Client, error) {
9696
if httpClient == nil {
9797
httpClient = &http.Client{}
98-
tr := &http.Transport{}
98+
tr := &http.Transport{
99+
Proxy: http.ProxyFromEnvironment,
100+
}
99101
if config.SkipVerify {
100102
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
101103
} else {
@@ -151,7 +153,7 @@ func configDebug(cartel *Client) {
151153
func (c *Client) do(req *http.Request, v interface{}) (*Response, error) {
152154
if c.debugFile != nil {
153155
dumped, _ := httputil.DumpRequest(req, true)
154-
fmt.Fprintf(c.debugFile, "REQUEST: %s\n", string(dumped))
156+
_, _ = fmt.Fprintf(c.debugFile, "REQUEST: %s\n", string(dumped))
155157
}
156158
resp, err := c.httpClient.Do(req)
157159
if err != nil {

console/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ func NewClient(httpClient *http.Client, config *Config) (*Client, error) {
142142

143143
func newClient(httpClient *http.Client, config *Config) (*Client, error) {
144144
if httpClient == nil {
145-
httpClient = http.DefaultClient
145+
httpClient = &http.Client{
146+
Transport: &http.Transport{
147+
Proxy: http.ProxyFromEnvironment,
148+
},
149+
}
146150
}
147151
if config.UAAURL == "" && config.BaseConsoleURL == "" {
148152
doAutoconf(config)

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ github.com/google/fhir/go v0.0.0-20201203001644-a2580b6ea022 h1:/3ks4F+11G41fl8Z
217217
github.com/google/fhir/go v0.0.0-20201203001644-a2580b6ea022/go.mod h1:WF6g9QjYPqcQed319oPaRT5IcYWIRz610X3mxIt5TgU=
218218
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
219219
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
220-
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
221220
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
222221
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
223222
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
@@ -309,7 +308,6 @@ github.com/klauspost/pgzip v1.2.4/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQ
309308
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
310309
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
311310
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
312-
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
313311
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
314312
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
315313
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
@@ -390,7 +388,6 @@ github.com/philips-software/go-hsdp-signer v1.3.0 h1:Si1voDE/GHzthmxpasPdntbu8aU
390388
github.com/philips-software/go-hsdp-signer v1.3.0/go.mod h1:/QehZ/+Aks2t1TFpjhF/7ZSB8PJIIJHzLc03rOqwLw0=
391389
github.com/pires/go-proxyproto v0.0.0-20191211124218-517ecdf5bb2b/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY=
392390
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
393-
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
394391
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
395392
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
396393
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -415,7 +412,6 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
415412
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
416413
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
417414
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
418-
github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE=
419415
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
420416
github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8=
421417
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
@@ -548,7 +544,6 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn
548544
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
549545
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
550546
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
551-
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
552547
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
553548
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
554549
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -680,7 +675,6 @@ gopkg.in/DataDog/dd-trace-go.v1 v1.17.0/go.mod h1:DVp8HmDh8PuTu2Z0fVVlBsyWaC++fz
680675
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
681676
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw=
682677
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
683-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
684678
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
685679
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
686680
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

iam/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ func NewClient(httpClient *http.Client, config *Config) (*Client, error) {
105105

106106
func newClient(httpClient *http.Client, config *Config) (*Client, error) {
107107
if httpClient == nil {
108-
httpClient = http.DefaultClient
108+
httpClient = &http.Client{
109+
Transport: &http.Transport{
110+
Proxy: http.ProxyFromEnvironment,
111+
},
112+
}
109113
}
110114
doAutoconf(config)
111115
c := &Client{client: httpClient, config: config, UserAgent: userAgent}

iron/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ func NewClient(config *Config) (*Client, error) {
7474
}
7575

7676
func newClient(config *Config) (*Client, error) {
77-
c := &Client{config: config, UserAgent: userAgent, client: http.DefaultClient}
77+
httpClient := &http.Client{
78+
Transport: &http.Transport{
79+
Proxy: http.ProxyFromEnvironment,
80+
},
81+
}
82+
c := &Client{config: config, UserAgent: userAgent, client: httpClient}
7883
useURL := IronBaseURL
7984
if config.BaseURL != "" {
8085
useURL = config.BaseURL

logging/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ type CustomIndexBody []struct {
102102
// NewClient returns an instance of the logger client with the given Config
103103
func NewClient(httpClient *http.Client, config *Config) (*Client, error) {
104104
if httpClient == nil {
105-
httpClient = apmhttp.WrapClient(http.DefaultClient)
105+
c := &http.Client{
106+
Transport: &http.Transport{
107+
Proxy: http.ProxyFromEnvironment,
108+
},
109+
}
110+
httpClient = apmhttp.WrapClient(c)
106111
}
107112
// Autoconfig
108113
if config.Region != "" && config.Environment != "" {

tpns/client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ func NewClient(httpClient *http.Client, config *Config) (*Client, error) {
6060

6161
func newClient(httpClient *http.Client, config *Config) (*Client, error) {
6262
if httpClient == nil {
63-
httpClient = http.DefaultClient
63+
httpClient = &http.Client{
64+
Transport: &http.Transport{
65+
Proxy: http.ProxyFromEnvironment,
66+
},
67+
}
6468
}
6569
c := &Client{client: httpClient, config: config, UserAgent: userAgent}
6670
if err := c.SetBaseTPNSURL(c.config.TPNSURL); err != nil {
@@ -82,7 +86,7 @@ func newClient(httpClient *http.Client, config *Config) (*Client, error) {
8286
// Close releases allocated resources of clients
8387
func (c *Client) Close() {
8488
if c.debugFile != nil {
85-
c.debugFile.Close()
89+
_ = c.debugFile.Close()
8690
c.debugFile = nil
8791
}
8892
}

0 commit comments

Comments
 (0)