doh

package
v0.0.0-...-22f0dc9 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

package doh implements dns-over-https

Example:

ctx, cancelFunc := context.WithTimeout(context.Background(), 10*time.Second)
defer cancelFunc()
httpClient := &http.Client{Timeout: time.Second * 10}
resp, err := MakeDohRequest(ctx, httpClient, doh.DnsDomain("cloudflare.com), doh.TypeA)
require.NoError(t, err)
require.NotNil(t, resp)

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeA     = DnsType("A")
	TypeAAAA  = DnsType("AAAA")
	TypeCNAME = DnsType("CNAME")
	TypeMX    = DnsType("MX")
	TypeTXT   = DnsType("TXT")
	TypeSPF   = DnsType("SPF")
	TypeNS    = DnsType("NS")
	TypeSOA   = DnsType("SOA")
	TypePTR   = DnsType("PTR")
	TypeANY   = DnsType("ANY")
)

Functions

This section is empty.

Types

type DnsAnswer

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

type DnsDomain

type DnsDomain string

type DnsQuestion

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

type DnsResponse

type DnsResponse 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 []DnsQuestion `json:"Question"`
	Answer   []DnsAnswer   `json:"Answer"`
	Provider string        `json:"provider"`
}

func MakeDohRequest

func MakeDohRequest(ctx context.Context,
	httpClient *http.Client,
	domain DnsDomain,
	typ DnsType) (*DnsResponse, error)

type DnsType

type DnsType string

Jump to

Keyboard shortcuts

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