From 589b13320a33db42a3813bdd5a620a7de39152cf Mon Sep 17 00:00:00 2001 From: grumbulon Date: Thu, 23 Jun 2022 07:29:06 +0000 Subject: [PATCH] Cannot defined things twice in same package (#5) Co-authored-by: grumbulon Co-committed-by: grumbulon --- util/dns.go | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/util/dns.go b/util/dns.go index 56f511b..35c3b9b 100644 --- a/util/dns.go +++ b/util/dns.go @@ -2,55 +2,13 @@ package util import ( "encoding/base64" - "errors" "fmt" "io" - "net" "net/http" - "strings" - "time" - "github.com/c-robinson/iplib" "github.com/miekg/dns" ) -type Response struct { - Answers Answers `json:"Response"` // -} - -// The Answers struct is the basic structure of a DNS request -// to be returned to the user upon making a request -type Answers struct { - Server string `json:"Server"` // The server to make the DNS request from - Request uint16 `json:"Request"` // The type of request - Name string `json:"Name"` // The domain name to make a DNS request for - RTT time.Duration `json:"RTT"` // When AWL was ran -} - -func ReverseDNS(dom string, q string) (string, error) { - if q == "PTR" { - if strings.Contains(dom, ".") { - // It's an IPv4 address - ip := net.ParseIP(dom) - if ip != nil { - return iplib.IP4ToARPA(ip), nil - } else { - return "", errors.New("error: Could not parse IPv4 address") - } - - } else if strings.Contains(dom, ":") { - // It's an IPv6 address - ip := net.ParseIP(dom) - if ip != nil { - return iplib.IP6ToARPA(ip), nil - } else { - return "", errors.New("error: Could not parse IPv6 address") - } - } - } - return "", errors.New("error: -x flag given but no IP found") -} - func ResolveHTTPS(msg *dns.Msg, server string) (*dns.Msg, error) { httpR := &http.Client{} buf, err := msg.Pack()