/
options.go
72 lines (60 loc) · 1.57 KB
/
options.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
package doh
import (
"fmt"
"net/http"
retryablehttp "github.com/projectdiscovery/retryablehttp-go"
)
type Options struct {
DefaultResolver Resolver
httpClient *retryablehttp.Client
}
type Resolver struct {
Name string
URL string
}
var (
Cloudflare = Resolver{Name: "Cloudflare", URL: "https://cloudflare-dns.com/dns-query"}
Google = Resolver{Name: "Google", URL: "https://dns.google.com/resolve"}
Quad9 = Resolver{Name: "Cloudflare", URL: "https://dns.quad9.net:5053/dns-query"}
PowerDNS = Resolver{Name: "PowerDNS", URL: "https://doh.powerdns.org/dns-query"}
OpenDNS = Resolver{Name: "OpenDNS", URL: "https://doh.opendns.com/dns-query"}
)
type QuestionType string
func (q QuestionType) ToString() string {
return fmt.Sprint(q)
}
const (
A QuestionType = "A"
AAAA QuestionType = "AAAA"
MX QuestionType = "MX"
NS QuestionType = "NS"
SOA QuestionType = "SOA"
PTR QuestionType = "PTR"
CNAME QuestionType = "CNAME"
)
type Response struct {
Status int `json:"Status"`
TC bool `json:"TC"`
RD bool `json:"RD"`
RA bool `json:"RA"`
AD bool `json:"AD"`
CD bool `json:"CD"`
Question []Question `json:"Question"`
Answer []Answer `json:"Answer"`
Comment string
}
type Question struct {
Name string `json:"name"`
Type int `json:"type"`
}
type Answer struct {
Name string `json:"name"`
Type int `json:"type"`
TTL int `json:"TTL"`
Data string `json:"data"`
}
type Method string
const (
MethodGet Method = http.MethodGet
MethodPost Method = http.MethodPost
)