diff options
| author | Jeff Carr <[email protected]> | 2023-12-28 09:43:45 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-12-28 09:43:45 -0600 |
| commit | 6fa6d6dfc9e5a88e7dff2ed3c148b3b4271f566c (patch) | |
| tree | f08edaac07ddf1a2e8a7401ef32c53707bdf5537 /dns-https.go | |
| parent | 73b0cee93320bb5b572881cd1a5ba9d878a4ba3a (diff) | |
Detect that a VPN is needed
IPv6() returns true if it's working
display duration
a 'DNS Lookup Status' window
actual dig results
display status and failure counters
count lookup failures and successes
add TCP dns lookup
logic to test if dns is working at all
add DNS over HTTPS
cloudflare new & update kind of working
holy shit, go.wit.com finally works with git mod tidy
working, but cloudflare api stuff is broken
AAAA '(none)' logic detection is better
cloudflare control panel
display the working real AAAA addresses
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'dns-https.go')
| -rw-r--r-- | dns-https.go | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/dns-https.go b/dns-https.go new file mode 100644 index 0000000..00eec82 --- /dev/null +++ b/dns-https.go @@ -0,0 +1,62 @@ +package main + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net/http" +) + +// dnsLookupDoH performs a DNS lookup for AAAA records over HTTPS. +func dnsLookupDoH(domain string) ([]string, error) { + var ipv6Addresses []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=AAAA", domain) + + // Perform the HTTP GET request + resp, err := http.Get(url) + if err != nil { + return nil, fmt.Errorf("error performing DNS-over-HTTPS request: %w", err) + } + defer resp.Body.Close() + + // Read and unmarshal the response body + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("error reading response: %w", err) + } + + var data struct { + Answer []struct { + Data string `json:"data"` + } `json:"Answer"` + } + + if err := json.Unmarshal(body, &data); err != nil { + return nil, fmt.Errorf("error unmarshaling response: %w", err) + } + + // Extract the IPv6 addresses + for _, answer := range data.Answer { + ipv6Addresses = append(ipv6Addresses, answer.Data) + } + + return ipv6Addresses, nil +} + +/* +func main() { + domain := "google.com" + ipv6Addresses, err := dnsLookupDoH(domain) + if err != nil { + fmt.Println("Error:", err) + return + } + + fmt.Printf("IPv6 Addresses for %s:\n", domain) + for _, addr := range ipv6Addresses { + fmt.Println(addr) + } +} +*/ |
