mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
Added temporary solution for creating new clients
This commit is contained in:
parent
9991f02631
commit
874d750dde
1 changed files with 28 additions and 4 deletions
|
|
@ -2,8 +2,12 @@
|
||||||
package magellan
|
package magellan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"crypto/x509"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
@ -58,12 +62,32 @@ func CollectInventory(assets *[]RemoteAsset, params *CollectParams) error {
|
||||||
done = make(chan struct{}, params.Concurrency+1)
|
done = make(chan struct{}, params.Concurrency+1)
|
||||||
chanAssets = make(chan RemoteAsset, params.Concurrency+1)
|
chanAssets = make(chan RemoteAsset, params.Concurrency+1)
|
||||||
outputPath = path.Clean(params.OutputPath)
|
outputPath = path.Clean(params.OutputPath)
|
||||||
smdClient = client.NewClient(
|
smdClient = &client.SmdClient{Client: &http.Client{}}
|
||||||
client.WithSecureTLS[*client.SmdClient](params.CaCertPath),
|
|
||||||
)
|
)
|
||||||
)
|
// set the client's params from CLI
|
||||||
// set the client's host from the CLI param
|
// NOTE: temporary solution until client.NewClient() is fixed
|
||||||
smdClient.URI = params.URI
|
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)
|
wg.Add(params.Concurrency)
|
||||||
for i := 0; i < params.Concurrency; i++ {
|
for i := 0; i < params.Concurrency; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue