diff options
| author | Jeff Carr <[email protected]> | 2023-12-29 01:36:10 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-12-29 01:36:10 -0600 |
| commit | 1258be9beff2e45c94ba5f7c29db65be02a1e2d4 (patch) | |
| tree | c1b6bc4e9a648835ec243140fd29689db1cf0bf1 /dns-https.go | |
| parent | 8afc73da048204f4245e0c850436c1e3e70055a5 (diff) | |
add digital ocean & DNS state windows
lists digital ocean droplets
create a new digital ocean droplet
knows what needs to be done to get IPv4 and IPv6 to work
update windows on Show()
make a window for the state of DNS specific to the hostname
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'dns-https.go')
| -rw-r--r-- | dns-https.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/dns-https.go b/dns-https.go index c61aa2f..6579903 100644 --- a/dns-https.go +++ b/dns-https.go @@ -63,3 +63,46 @@ func dnsAAAAlookupDoH(domain string) ([]string, error) { return ipv6Addresses, nil } + +// dnsLookupDoH performs a DNS lookup for AAAA records over HTTPS. +func lookupDoH(hostname string, rrType string) []string { + var values []string + + // Construct the URL for a DNS query with Google's DNS-over-HTTPS API + url := fmt.Sprintf("https://dns.google/resolve?name=%s&type=%s", hostname, rrType) + + log.Println("curl", url) + + // Perform the HTTP GET request + resp, err := http.Get(url) + if err != nil { + log.Error(err, "error performing DNS-over-HTTPS request") + return nil + } + defer resp.Body.Close() + + // Read and unmarshal the response body + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + log.Error(fmt.Errorf("error reading response: %w", err)) + return nil + } + + var data struct { + Answer []struct { + Data string `json:"data"` + } `json:"Answer"` + } + + if err := json.Unmarshal(body, &data); err != nil { + log.Error(fmt.Errorf("error unmarshaling response: %w", err)) + return nil + } + + // Extract the IPv6 addresses + for _, answer := range data.Answer { + values = append(values, answer.Data) + } + + return values +} |
