Using argument

main
Muhammad Daffa 2021-07-25 18:12:17 +07:00 committed by GitHub
parent b2418c17b5
commit b46e23e9fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 9 deletions

24
main.go
View File

@ -3,12 +3,12 @@ package main
import ( import (
"fmt" "fmt"
"net" "net"
"os"
"strings"
) )
func main() { func main() {
var url string url := os.Args[1]
fmt.Println("Input website")
fmt.Scanln(&url)
cname(url) cname(url)
ip(url) ip(url)
mx(url) mx(url)
@ -22,7 +22,7 @@ func cname(url string) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
fmt.Println(cname) fmt.Printf("\n[CNAME] %s\n", cname)
} }
func ip(url string) { func ip(url string) {
@ -33,8 +33,9 @@ func ip(url string) {
if len(ips) == 0 { if len(ips) == 0 {
fmt.Printf("no record\n") fmt.Printf("no record\n")
} }
fmt.Println()
for _, ip := range ips { for _, ip := range ips {
fmt.Printf("%s\n", ip.String()) fmt.Printf("[IP] %s\n\n", ip)
} }
} }
@ -45,7 +46,7 @@ func mx(url string) {
} }
for _, mx := range mxs { for _, mx := range mxs {
fmt.Printf("%s %v\n", mx.Host, mx.Pref) fmt.Printf("[MX] %s %v\n", mx.Host, mx.Pref)
} }
} }
@ -57,8 +58,9 @@ func ns(url string) {
if len(nss) == 0 { if len(nss) == 0 {
fmt.Printf("no record\n") fmt.Printf("no record\n")
} }
fmt.Println()
for _, ns := range nss { for _, ns := range nss {
fmt.Printf("%s\n", ns.Host) fmt.Printf("[NS] %s\n", ns.Host)
} }
} }
@ -70,8 +72,12 @@ func txt(url string) {
if len(txts) == 0 { if len(txts) == 0 {
fmt.Printf("no record\n") fmt.Printf("no record\n")
} }
fmt.Println()
for _, txt := range txts { for _, txt := range txts {
fmt.Printf("%s\n", txt) if strings.Contains(txt, "v=DMARC1") {
fmt.Printf("[DMARC] %s\n", txt)
break
}
fmt.Printf("[TXT] %s\n", txt)
} }
} }