-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
78 lines (73 loc) · 2.08 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"flag"
"fmt"
"net"
"os"
"time"
clients "github.com/careyjames/dns-scout/clients"
constants "github.com/careyjames/dns-scout/constant"
dnsinformation "github.com/careyjames/dns-scout/dns_information"
color "github.com/fatih/color"
"github.com/briandowns/spinner"
"github.com/chzyer/readline"
)
func main() {
// Check "version" argument
args := os.Args[1:]
if len(args) > 0 && args[0] == "version" {
fmt.Println("DNS-Scout version:", constants.Version)
return
}
var apiTokenFlag string
flag.StringVar(&apiTokenFlag, "api-token", "", "IPInfo API token")
flag.Parse()
rl, err := readline.NewEx(&readline.Config{
Prompt: " \033[38;5;8m\033[38;5;4m",
HistoryFile: ".tmp-history",
AutoComplete: nil,
InterruptPrompt: "^C",
EOFPrompt: "exit",
HistorySearchFold: true,
FuncFilterInputRune: nil,
})
if err != nil {
panic(err)
}
defer rl.Close()
apiToken := clients.FetchAPIToken(apiTokenFlag)
s := spinner.New(spinner.CharSets[9], 100*time.Millisecond) // Use the dots character set and update every 100ms
for {
color.New(color.FgWhite).Println(" Enter domain, IP (or 'exit' to quit): ")
fmt.Println("\033[38;5;8m ------------------------------------\033[0m")
input, err := rl.Readline()
if err != nil { // io.EOF, readline.ErrInterrupt
break
}
if input == "exit" {
return
}
s.Start() // Start the spinner
isIP := net.ParseIP(input) != nil
_, _, err = net.ParseCIDR(input)
isCIDR := err == nil
s.Stop() // Stop the spinner
promptRunner(isIP, isCIDR, input, apiToken)
}
}
func promptRunner(isIP bool, isCIDR bool, input string, apiToken string) {
if !isIP {
dnsinformation.GetRegistrarPromt(input, isIP)
dnsinformation.ResolvedIPPrompt(input)
dnsinformation.GetNSPrompt(input)
dnsinformation.GetMXPrompt(input)
dnsinformation.GetTXTPrompt(input)
dnsinformation.GetSPFPrompt(input)
dnsinformation.GetDMARCPrompt(input)
dnsinformation.GetDKIMPrompt(input)
}
dnsinformation.GetPTRPrompt(input, isIP)
if isIP || isCIDR {
dnsinformation.GetASNInfoPrompt(input, apiToken)
}
}