shogo/internal/shodan/count.go
perp 07c61c1b1c 🎉 Beginning
First push for beginning of project
2023-08-01 23:35:47 +01:00

31 lines
575 B
Go

package shodan
import (
"context"
"fmt"
"os"
"github.com/ns3777k/go-shodan/v4/shodan"
"git.tcp.direct/perp/shogo/internal/utils"
)
// Return your query result count
func Count(query string) {
// Setup query
options := &shodan.HostQueryOptions{
Query: query,
}
// Get results
results, err := utils.Client.GetHostsCountForQuery(context.Background(), options)
if err != nil {
fmt.Printf("%s: %s\n", utils.Red("Error"), err.Error())
os.Exit(1)
}
// Print results
utils.Title.Printf("Count: %s\n", query)
fmt.Printf("%s\n", utils.Blue(results.Total))
}