Add RDAP URL support
List of RDAP URLs comes from IANA
Chris Killpack
3 years ago
53 | 53 |
updateWhois := flag.Bool("update-whois", false, "query whois-servers.net for whois servers")
|
54 | 54 |
updateIANA := flag.Bool("update-iana", false, "query IANA for metadata")
|
55 | 55 |
updateIDN := flag.Bool("update-idn", false, "query IANA for IDN tables")
|
|
56 |
updateRDAP := flag.Bool("update-rdap", false, "query IANA for RDAP hosts")
|
56 | 57 |
updateAll := flag.Bool("update", false, "update all (root zone, whois, IANA data, IDN tables)")
|
57 | 58 |
|
58 | 59 |
// Write operations
|
|
229 | 230 |
}
|
230 | 231 |
}
|
231 | 232 |
|
|
233 |
if *updateRDAP || *updateAll {
|
|
234 |
err := build.FetchRDAPFromIANA(workZones)
|
|
235 |
if err != nil {
|
|
236 |
errs = append(errs, err)
|
|
237 |
build.LogError(err)
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
232 | 241 |
if *removeTags != "" {
|
233 | 242 |
tags := strings.Split(*removeTags, ",")
|
234 | 243 |
build.RemoveTags(workZones, tags)
|
|
0 |
package build
|
|
1 |
|
|
2 |
import (
|
|
3 |
"encoding/json"
|
|
4 |
)
|
|
5 |
|
|
6 |
const (
|
|
7 |
ianaRdapURL = "https://data.iana.org/rdap/dns.json"
|
|
8 |
)
|
|
9 |
|
|
10 |
// FetchRDAPFromIANA retrieves the map of zones to RDAP service endpoints from IANA.
|
|
11 |
func FetchRDAPFromIANA(zones map[string]*Zone) error {
|
|
12 |
res, err := Fetch(ianaRdapURL)
|
|
13 |
if err != nil {
|
|
14 |
return err
|
|
15 |
}
|
|
16 |
defer res.Body.Close()
|
|
17 |
|
|
18 |
x := struct {
|
|
19 |
Services [][][]string // I'm screaming at this schema
|
|
20 |
}{}
|
|
21 |
d := json.NewDecoder(res.Body)
|
|
22 |
err = d.Decode(&x)
|
|
23 |
if err != nil {
|
|
24 |
return err
|
|
25 |
}
|
|
26 |
for _, svc := range x.Services {
|
|
27 |
tlds := svc[0]
|
|
28 |
|
|
29 |
for _, tld := range tlds {
|
|
30 |
z, ok := zones[tld]
|
|
31 |
if !ok {
|
|
32 |
continue
|
|
33 |
}
|
|
34 |
|
|
35 |
z.RdapURLs = []string{}
|
|
36 |
for _, rdapURL := range svc[1] {
|
|
37 |
normURL := NormalizeURL(rdapURL)
|
|
38 |
if normURL == "" {
|
|
39 |
Trace("@{r}invalid RDAP URL %q\n", rdapURL)
|
|
40 |
continue
|
|
41 |
}
|
|
42 |
z.RdapURLs = append(z.RdapURLs, normURL)
|
|
43 |
}
|
|
44 |
}
|
|
45 |
}
|
|
46 |
|
|
47 |
return nil
|
|
48 |
}
|
22 | 22 |
Languages []string `json:"languages,omitempty"`
|
23 | 23 |
Tags []string `json:"tags,omitempty"`
|
24 | 24 |
Policies []Policy `json:"policies,omitempty"`
|
|
25 |
RdapURLs []string `json:"rdapURLs,omitempty"`
|
25 | 26 |
|
26 | 27 |
// Internal
|
27 | 28 |
subdomains []string
|