-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdap.go
50 lines (41 loc) · 839 Bytes
/
rdap.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 (
"github.com/openrdap/rdap/bootstrap"
"net/http"
"time"
)
var (
comApi = rdapApi("google.com")
netApi = rdapApi("create.net")
)
func rdapApi(domain string) string {
question := &bootstrap.Question{
RegistryType: bootstrap.DNS,
Query: domain,
}
b := &bootstrap.Client{}
var answer *bootstrap.Answer
answer, err := b.Lookup(question)
if err == nil {
for _, url := range answer.URLs {
return url.String() + "/domain/"
}
}
return ""
}
func rdapQuery(host, domain string) bool {
client := http.Client{Timeout: 10 * time.Second}
var api string
switch domain {
case ".com":
api = comApi
case ".net":
api = netApi
}
resp, err := client.Get(api + host + domain)
if err != nil {
//fmt.Println(err)
return whois(host + domain)
}
return resp.StatusCode == http.StatusOK
}