doh

package
v1.0.83 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 11 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 NewHttpClient added in v1.0.75

func NewHttpClient(opts ...ClientOption) *http.Client

NewHttpClient creates a new http.Client with the given options

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 ClientOption added in v1.0.75

type ClientOption func(*http.Client)

ClientOption defines a function type for configuring an http.Client

func WithInsecureSkipVerify added in v1.0.75

func WithInsecureSkipVerify() ClientOption

WithInsecureSkipVerify sets the InsecureSkipVerify option for the TLS config

func WithProxy added in v1.0.75

func WithProxy(proxyURL string) ClientOption

WithProxy sets a proxy for the http.Client

func WithTimeout added in v1.0.75

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout sets the timeout for the http.Client

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