From db78235ecd278c786526c131587c57db6ed2215e Mon Sep 17 00:00:00 2001 From: Sam Therapy Date: Thu, 23 Jun 2022 23:18:54 +0200 Subject: [PATCH] hehe off-by-one Signed-off-by: Sam Therapy --- cli.go | 2 +- util/dns.go | 47 ----------------------------------------------- 2 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 util/dns.go diff --git a/cli.go b/cli.go index 76945a4..f59b880 100644 --- a/cli.go +++ b/cli.go @@ -186,7 +186,7 @@ func parseArgs(args []string) (util.Answers, error) { // TODO: Actually find where windows stuffs its dns resolvers resp.Answers.Server = "8.8.4.4" } else { - resp.Answers.Server = resolv.Servers[rand.Intn(len(resolv.Servers)-1)] + resp.Answers.Server = resolv.Servers[rand.Intn(len(resolv.Servers))] } } diff --git a/util/dns.go b/util/dns.go deleted file mode 100644 index 35c3b9b..0000000 --- a/util/dns.go +++ /dev/null @@ -1,47 +0,0 @@ -package util - -import ( - "encoding/base64" - "fmt" - "io" - "net/http" - - "github.com/miekg/dns" -) - -func ResolveHTTPS(msg *dns.Msg, server string) (*dns.Msg, error) { - httpR := &http.Client{} - buf, err := msg.Pack() - if err != nil { - return nil, err - } - query := server + "?dns=" + base64.RawURLEncoding.EncodeToString(buf) - req, err := http.NewRequest("GET", query, nil) - if err != nil { - return nil, err - } - req.Header.Set("Accept", "application/dns-message") - - res, err := httpR.Do(req) - if err != nil { - return nil, err - } - defer res.Body.Close() - - if res.StatusCode != http.StatusOK { - return nil, fmt.Errorf("bad HTTP Request: %d", res.StatusCode) - } - - fullRes, err := io.ReadAll(res.Body) - if err != nil { - return nil, err - } - response := dns.Msg{} - err = response.Unpack(fullRes) - if err != nil { - return nil, err - } - - return &response, nil - -}