-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (37 loc) · 880 Bytes
/
main.go
File metadata and controls
41 lines (37 loc) · 880 Bytes
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
package main
import (
"bytes"
"fmt"
"github.com/coredns/coredns/core/dnsserver"
_ "github.com/coredns/coredns/core/plugin"
"github.com/coredns/coredns/coremain"
_ "hackforward/plugin/hackforward"
"os/exec"
"time"
)
func init() {
dnsserver.Directives = []string{
"hack_forward",
}
}
func main() {
//reqs := []string{"seznam.cz"}
reqs := []string{"seznam.cz", "google.com", "atlas.cz", "example.com", "zive.cz"}
time.AfterFunc(1000*time.Millisecond, func() {
for _, req := range reqs {
cmd := exec.Command("dig", "@localhost", req)
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
fmt.Println(fmt.Sprint(err) + ": " + stderr.String())
return
}
//fmt.Println("Command output:\n", out.String())
time.Sleep(1000 * time.Millisecond)
}
})
coremain.Run()
}