doh

package
v1.0.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Cloudflare = Resolver{Name: "Cloudflare", URL: "https://cloudflare-dns.com/dns-query"}
	Google     = Resolver{Name: "Google", URL: "https://dns.google.com/resolve"}
	Quad9      = Resolver{Name: "Cloudflare", URL: "https://dns.quad9.net:5053/dns-query"}
	PowerDNS   = Resolver{Name: "PowerDNS", URL: "https://doh.powerdns.org/dns-query"}
	OpenDNS    = Resolver{Name: "OpenDNS", URL: "https://doh.opendns.com/dns-query"}
)
View Source
var DefaultTimeout = 5 * time.Second

Functions

func NewHttpClientWithTimeout added in v1.0.31

func NewHttpClientWithTimeout(timeout time.Duration) *http.Client

Types

type Answer

type Answer struct {
	Name string `json:"name"`
	Type int    `json:"type"`
	TTL  int    `json:"TTL"`
	Data string `json:"data"`
}

type Client

type Client struct {
	DefaultResolver Resolver
	// contains filtered or unexported fields
}

func New

func New() *Client

func NewWithOptions

func NewWithOptions(options Options) *Client

func (*Client) Query

func (c *Client) Query(name string, question QuestionType) (*Response, error)

func (*Client) QueryWithDOH

func (c *Client) QueryWithDOH(method Method, r Resolver, name string, question uint16) (*dns.Msg, error)

func (*Client) QueryWithDOHMsg

func (c *Client) QueryWithDOHMsg(method Method, r Resolver, msg *dns.Msg) (*dns.Msg, error)

func (*Client) QueryWithJsonAPI

func (c *Client) QueryWithJsonAPI(r Resolver, name string, question QuestionType) (*Response, error)

func (*Client) QueryWithResolver

func (c *Client) QueryWithResolver(r Resolver, name string, question QuestionType) (*Response, error)

type Method

type Method string
const (
	MethodGet  Method = http.MethodGet
	MethodPost Method = http.MethodPost
)

type Options

type Options struct {
	DefaultResolver Resolver
	HttpClient      *http.Client
}

type Question

type Question struct {
	Name string `json:"name"`
	Type int    `json:"type"`
}

type QuestionType

type QuestionType string
const (
	A     QuestionType = "A"
	AAAA  QuestionType = "AAAA"
	MX    QuestionType = "MX"
	NS    QuestionType = "NS"
	SOA   QuestionType = "SOA"
	PTR   QuestionType = "PTR"
	ANY   QuestionType = "ANY"
	CNAME QuestionType = "CNAME"
)

func (QuestionType) ToString

func (q QuestionType) ToString() string

type Resolver

type Resolver struct {
	Name string
	URL  string
}

type Response

type Response struct {
	Status   int        `json:"Status"`
	TC       bool       `json:"TC"`
	RD       bool       `json:"RD"`
	RA       bool       `json:"RA"`
	AD       bool       `json:"AD"`
	CD       bool       `json:"CD"`
	Question []Question `json:"Question"`
	Answer   []Answer   `json:"Answer"`
	Comment  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL