dns_resolver

package
v0.0.0-...-e613796 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package dns_resolver is a simple dns resolver based on miekg/dns

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DnsResolver

type DnsResolver struct {
	Servers    []string
	RetryTimes int

	DohServer *string
	// contains filtered or unexported fields
}

DnsResolver represents a dns resolver

func New

func New(servers []string, dohServer *string) *DnsResolver

New initializes DnsResolver.

func NewFromResolvConf

func NewFromResolvConf(path string) (*DnsResolver, error)

NewFromResolvConf initializes DnsResolver from resolv.conf like file.

func (*DnsResolver) LookupHost

func (r *DnsResolver) LookupHost(host string, requestType uint16) (*DnsResult, error)

LookupHost returns IP addresses of provided host. In case of timeout retries query RetryTimes times.

func (*DnsResolver) LookupHostDoh

func (r *DnsResolver) LookupHostDoh(host string, recordType string) *DnsResult

type DnsResult

type DnsResult struct {
	Ips    []Ip
	Server string
}

type DohAnswer

type DohAnswer struct {
	Name string `json:"name"`
	Type uint16 `json:"type"`
	TTL  uint32 `json:"TTL"`
	Data string `json:"data"`
}

type DohQuestion

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

type DohResponse

type DohResponse 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 []DohQuestion `json:"Question"`
	Answer   []DohAnswer   `json:"Answer"`
}

type Ip

type Ip struct {
	Address string
	Ttl     uint32
	Type    uint16
	Name    string
}

Jump to

Keyboard shortcuts

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