/
main.go
50 lines (47 loc) · 966 Bytes
/
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
package main
import (
"flag"
"sync"
"time"
"github.com/sirupsen/logrus"
)
func main() {
domain := flag.String("d", "", "domain")
debug := flag.Bool("debug", false, "debug")
flag.Parse()
if *domain == "" {
logrus.Error("[-]Please specify a domain")
flag.Usage()
return
}
if *debug {
logrus.SetLevel(logrus.DebugLevel)
logrus.Debug("[+]Debug mode")
}
res := make(map[string]time.Duration)
reslock := sync.RWMutex{}
logrus.Infof("[+]Testing domain %s...", *domain)
iplist := RunLocalCore(*domain, "")
wg := sync.WaitGroup{}
logrus.Info("[+]Testing delay...")
for _, ip := range iplist {
ip0 := ip
wg.Add(1)
go func() {
delay := Delay(*domain, ip0)
logrus.Infof("[+]Delay: %s - %s", ip0, delay)
if delay != time.Duration(-1) {
reslock.Lock()
res[ip0] = delay
reslock.Unlock()
}
wg.Done()
}()
}
wg.Wait()
if len(res) == 0 {
logrus.Error("[-]No result")
return
}
logrus.Info("[+]Results:", res)
}