summaryrefslogtreecommitdiffstats
path: root/cmd/dns.go
diff options
context:
space:
mode:
authors <[email protected]>2025-11-07 11:50:47 -0500
committers <[email protected]>2025-11-07 11:50:47 -0500
commit7d63867f365163f149db5d768c71f518f9eaf711 (patch)
treef3f4856cf82f57286dee5bec23fae0c5f70bd1ee /cmd/dns.go
parent5821aaa32e7ff2a2b2935bee712c2684907a3451 (diff)
downloaddborg-7d63867f365163f149db5d768c71f518f9eaf711.tar.gz
dborg-7d63867f365163f149db5d768c71f518f9eaf711.zip
refactor: extract json output formatting to utils.PrintJSON and add colorized json output with new dns tld command
Diffstat (limited to 'cmd/dns.go')
-rw-r--r--cmd/dns.go57
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)
+}