-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (36 loc) · 803 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
package main
import (
"github.com/enesusta/bdns/dns"
"github.com/enesusta/bdns/model"
"github.com/enesusta/bdns/parser"
"github.com/enesusta/bdns/udp"
"io/ioutil"
"log"
)
var records = map[string]string{
"amazon.com": "176.32.103.205",
"any.google.com": "10.0.0.1",
"babel.enesusta.net": "185.199.110.153",
}
func main() {
content, err := ioutil.ReadFile("config.json")
if err != nil {
log.Fatal(err)
}
config, err := parser.ParseEntities(content)
entities := make(map[string]model.DnsEntity)
for _, each := range config {
entities[each.Domain] = each
}
udpConf := udp.UdpConfiguration{
Host: "127.0.0.1",
Port: 8080,
}
u := udp.InitializeUdpSocket(&udpConf)
entity := dns.DnsConfiguration{
Entities: entities,
}
for {
dns.ServeDns(u, &entity)
}
}