Get certificate info in parallel
This commit is contained in:
parent
d80e324241
commit
0a11acd998
10
utils.go
10
utils.go
@ -9,6 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/jedib0t/go-pretty/table"
|
"github.com/jedib0t/go-pretty/table"
|
||||||
"github.com/jedib0t/go-pretty/text"
|
"github.com/jedib0t/go-pretty/text"
|
||||||
@ -57,7 +58,8 @@ func getPeerCertificates(h string, port int) ([]*x509.Certificate, error) {
|
|||||||
return conn.ConnectionState().PeerCertificates, nil
|
return conn.ConnectionState().PeerCertificates, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCells(t table.Writer, host string, port int) {
|
func getCells(t table.Writer, host string, port int, wg *sync.WaitGroup) {
|
||||||
|
defer wg.Done()
|
||||||
certs, err := getPeerCertificates(host, port)
|
certs, err := getPeerCertificates(host, port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("err: %s\n", err)
|
fmt.Printf("err: %s\n", err)
|
||||||
@ -99,6 +101,8 @@ func prettyPrintCertsInfo(config string) {
|
|||||||
"Issuer",
|
"Issuer",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
for _, target := range rc.Hosts {
|
for _, target := range rc.Hosts {
|
||||||
p := defaultPort
|
p := defaultPort
|
||||||
ts := strings.Split(target, ":")
|
ts := strings.Split(target, ":")
|
||||||
@ -110,9 +114,11 @@ func prettyPrintCertsInfo(config string) {
|
|||||||
p = tp
|
p = tp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
wg.Add(1)
|
||||||
|
|
||||||
getCells(t, ts[0], p)
|
go getCells(t, ts[0], p, &wg)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
t.Style().Format.Header = text.FormatDefault
|
t.Style().Format.Header = text.FormatDefault
|
||||||
t.Render()
|
t.Render()
|
||||||
|
Loading…
Reference in New Issue
Block a user