-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (43 loc) · 889 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
51
52
package main
import (
"fmt"
"os"
"sync"
"github.com/kenjoe41/netdomain/pkg/config"
"github.com/kenjoe41/netdomain/pkg/netlas"
"github.com/kenjoe41/netdomain/pkg/output"
)
func main() {
cfg, err := config.Parse()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
netClient := netlas.NewClient(cfg.APIKey)
var subdomains []string
outputCh := make(chan string)
var outputWG sync.WaitGroup
outputWG.Add(1)
go func() {
defer outputWG.Done()
for subdomain := range outputCh {
subdomains = append(subdomains, subdomain)
if cfg.OutputFile != "" && cfg.Silent {
continue
}
fmt.Println(subdomain)
}
}()
err = netlas.GetAllSubdomains(netClient, cfg.Domain, &outputCh)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if cfg.OutputFile != "" {
err = output.WriteToFile(subdomains, cfg)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
}