Skip to content

Commit

Permalink
Added temporary solution for creating new clients
Browse files Browse the repository at this point in the history
  • Loading branch information
davidallendj committed Aug 27, 2024
1 parent 9991f02 commit 874d750
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions internal/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
package magellan

import (
"crypto/tls"
"crypto/x509"
"encoding/json"
"fmt"
"net"
"net/http"
"os"
"path"
"sync"
Expand Down Expand Up @@ -58,12 +62,32 @@ func CollectInventory(assets *[]RemoteAsset, params *CollectParams) error {
done = make(chan struct{}, params.Concurrency+1)
chanAssets = make(chan RemoteAsset, params.Concurrency+1)
outputPath = path.Clean(params.OutputPath)
smdClient = client.NewClient(
client.WithSecureTLS[*client.SmdClient](params.CaCertPath),
)
smdClient = &client.SmdClient{Client: &http.Client{}}
)
// set the client's host from the CLI param
// set the client's params from CLI
// NOTE: temporary solution until client.NewClient() is fixed
smdClient.URI = params.URI
if params.CaCertPath != "" {
cacert, err := os.ReadFile(params.CaCertPath)
if err != nil {
return fmt.Errorf("failed to read CA cert path: %w", err)
}
certPool := x509.NewCertPool()
certPool.AppendCertsFromPEM(cacert)
smdClient.Client.Transport = &http.Transport{
TLSClientConfig: &tls.Config{
RootCAs: certPool,
InsecureSkipVerify: true,
},
DisableKeepAlives: true,
Dial: (&net.Dialer{
Timeout: 120 * time.Second,
KeepAlive: 120 * time.Second,
}).Dial,
TLSHandshakeTimeout: 120 * time.Second,
ResponseHeaderTimeout: 120 * time.Second,
}
}
wg.Add(params.Concurrency)
for i := 0; i < params.Concurrency; i++ {
go func() {
Expand Down

0 comments on commit 874d750

Please sign in to comment.