From f2b5dd649f5dfb2a01bc73d5e4ca1ec589c08212 Mon Sep 17 00:00:00 2001 From: Carey Balboa Date: Fri, 13 Oct 2023 22:52:23 -0500 Subject: [PATCH] update --- main.go | 70 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/main.go b/main.go index 761b391..111c5ef 100644 --- a/main.go +++ b/main.go @@ -314,36 +314,13 @@ func main() { } if !isIP { - ips, _ := net.LookupIP(input) - if len(ips) > 0 { - fmt.Printf("\033[38;5;39m Resolved IPs: \033[38;5;78m%s\033[0m\n", strings.Join(ipsToStrings(ips), ", ")) - } + resolvedIPPrompt(input) - ns, _ := getNS(input) - if len(ns) > 0 { - fmt.Printf("\033[38;5;39m Name Servers: \033[38;5;78m%s\033[0m\n", strings.Join(ns, ", ")) - } else { - fmt.Printf("\033[38;5;39m Name Servers: \033[0m\033[38;5;88mNone\033[0m\n") - } + getNSPrompt(input) - mx, _ := getMX(input) - if len(mx) > 0 { - fmt.Printf("\033[38;5;39m MX Records: \033[38;5;78m%s\033[0m\n", strings.Join(mx, ", ")) - } else { - fmt.Printf("\033[38;5;39m MX Records: \033[0m\033[38;5;88mNo MX, No email.\033[0m\n") - } + getMXPrompt(input) - txt, _ := getTXT(input) - if len(txt) > 0 { - fmt.Printf("\033[38;5;39m TXT Records:\033[0m\n") - for _, record := range txt { - isValidSPF := strings.HasPrefix(record, "v=spf1") - coloredRecord := colorCodeSPFRecord(record, isValidSPF) - fmt.Printf(" %s\n", coloredRecord) - } - } else { - fmt.Printf("\033[38;5;39m TXT Records: \033[0m\033[38;5;88mNone\033[0m\n") - } + getTXTPrompt(input) dmarc, _ := getDMARC(input) if dmarc != "" { @@ -407,3 +384,42 @@ func main() { } } } + +func resolvedIPPrompt(input string) { + ips, _ := net.LookupIP(input) + if len(ips) > 0 { + fmt.Printf("\033[38;5;39m Resolved IPs: \033[38;5;78m%s\033[0m\n", strings.Join(ipsToStrings(ips), ", ")) + } +} + +func getNSPrompt(input string) { + ns, _ := getNS(input) + if len(ns) > 0 { + fmt.Printf("\033[38;5;39m Name Servers: \033[38;5;78m%s\033[0m\n", strings.Join(ns, ", ")) + } else { + fmt.Printf("\033[38;5;39m Name Servers: \033[0m\033[38;5;88mNone\033[0m\n") + } +} + +func getMXPrompt(input string) { + mx, _ := getMX(input) + if len(mx) > 0 { + fmt.Printf("\033[38;5;39m MX Records: \033[38;5;78m%s\033[0m\n", strings.Join(mx, ", ")) + } else { + fmt.Printf("\033[38;5;39m MX Records: \033[0m\033[38;5;88mNo MX, No email.\033[0m\n") + } +} + +func getTXTPrompt(input string) { + txt, _ := getTXT(input) + if len(txt) > 0 { + fmt.Printf("\033[38;5;39m TXT Records:\033[0m\n") + for _, record := range txt { + isValidSPF := strings.HasPrefix(record, "v=spf1") + coloredRecord := colorCodeSPFRecord(record, isValidSPF) + fmt.Printf(" %s\n", coloredRecord) + } + } else { + fmt.Printf("\033[38;5;39m TXT Records: \033[0m\033[38;5;88mNone\033[0m\n") + } +}