diff options
Diffstat (limited to 'cmd/dns.go')
| -rw-r--r-- | cmd/dns.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/cmd/dns.go b/cmd/dns.go new file mode 100644 index 0000000..71a0d83 --- /dev/null +++ b/cmd/dns.go @@ -0,0 +1,57 @@ +package cmd + +import ( + "encoding/json" + "fmt" + + "git.db.org.ai/dborg/internal/client" + "git.db.org.ai/dborg/internal/config" + "git.db.org.ai/dborg/internal/models" + "github.com/spf13/cobra" +) + +var dnsCmd = &cobra.Command{ + Use: "dns", + Short: "DNS operations", + Long: "DNS-related operations for domain checking", +} + +var dnsTLDCmd = &cobra.Command{ + Use: "tld [term]", + Short: "Check NXDOMAIN for custom term against all TLDs", + Long: "Streams NDJSON results checking each TLD. For NXDOMAIN domains, returns status. For existing domains, runs httpx to get page title and tech stack.", + Args: cobra.ExactArgs(1), + RunE: runDNSTLDCheck, +} + +func runDNSTLDCheck(cmd *cobra.Command, args []string) error { + term := args[0] + + cfg := config.New() + c, err := client.New(cfg) + if err != nil { + return fmt.Errorf("failed to create client: %w", err) + } + + params := &models.DNSTLDParams{ + Term: term, + } + + fmt.Printf("Checking TLDs for term: %s\n\n", term) + + err = c.CheckDNSTLDStream(params, func(result json.RawMessage) error { + fmt.Println(string(result)) + return nil + }) + + if err != nil { + return fmt.Errorf("TLD check failed: %w", err) + } + + return nil +} + +func init() { + rootCmd.AddCommand(dnsCmd) + dnsCmd.AddCommand(dnsTLDCmd) +} |
