gdns

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DomainName    = "name"               // 解析域名
	RRType        = "type"               // 解析类型
	DisableDNSSEC = "cd"                 // 关闭 DNSSEC
	EDNS          = "edns_client_subnet" // EDNS
)

API request params

View Source
const GoogleDNSAPI = "https://dns.google.com/"

GoogleDNSAPI used in query api

Variables

This section is empty.

Functions

func QueryAPI

func QueryAPI(urlAddr string, params map[string]interface{}) ([]byte, error)

QueryAPI 请求 API [GET]

Types

type Answer

type Answer struct {
	Name string `json:"name"` // Always matches name in the Question section
	Type uint16 `json:"type"` // Standard DNS RR type
	TTL  uint32 `json:"TTL"`  // Record's time-to-live in seconds
	Data string `json:"data"` // IP address as text
}

Answer part of response

func (*Answer) GetAnswer

func (a *Answer) GetAnswer() dns.RR

GetAnswer 获取 anwser

func (*Answer) GetRRHeader

func (a *Answer) GetRRHeader() dns.RR_Header

GetRRHeader 获取 rr header

type GoogleDNSRequest

type GoogleDNSRequest struct {
	Name             string // 解析域名
	Type             uint16 // 解析类型
	CD               bool   // 关闭 DNSSEC,默认关闭
	EDNSClientSubnet string // EDNS 子网
}

GoogleDNSRequest parse request data to struct

func NewGoogleDNSRequest

func NewGoogleDNSRequest() *GoogleDNSRequest

NewGoogleDNSRequest will return a GoogleDNSRequest isntance with default value

func (*GoogleDNSRequest) ClientSubnet

func (g *GoogleDNSRequest) ClientSubnet(subnet string) *GoogleDNSRequest

ClientSubnet 设置子网

func (*GoogleDNSRequest) DisableDNSSEC

func (g *GoogleDNSRequest) DisableDNSSEC(cd bool) *GoogleDNSRequest

DisableDNSSEC DNSSEC 开关

func (*GoogleDNSRequest) Query

func (g *GoogleDNSRequest) Query() (*GoogleDNSResponse, error)

Query 请求 Google DNS

func (*GoogleDNSRequest) ResolveName

func (g *GoogleDNSRequest) ResolveName(domain string) *GoogleDNSRequest

ResolveName 设置解析域名

func (*GoogleDNSRequest) ResolveType

func (g *GoogleDNSRequest) ResolveType(qtype uint16) *GoogleDNSRequest

ResolveType 设置解析类型

type GoogleDNSResponse

type GoogleDNSResponse struct {
	Status           int           `json:"Status"`             // 0 success, 2 fail
	TC               bool          `json:"TC"`                 // Whether the response is truncated
	RD               bool          `json:"RD"`                 // Always true for Google Public DNS
	RA               bool          `json:"RA"`                 // Always true for Google Public DNS
	AD               bool          `json:"AD"`                 // Whether all response data was validated with DNSSEC
	CD               bool          `json:"CD"`                 // Whether the client asked to disable DNSSEC
	Question         []Question    `json:"Question"`           // Question
	Answer           []Answer      `json:"Answer"`             // Answer
	Additional       []interface{} `json:"Additional"`         // Additional response
	EdnsClientSubnet string        `json:"edns_client_subnet"` // IP address / scope prefix-length
	Comment          string        `json:"Comment"`            // comment
}

GoogleDNSResponse Google DNS API response struct

func BytesToGoogleDNSResponse

func BytesToGoogleDNSResponse(resp []byte) (*GoogleDNSResponse, error)

BytesToGoogleDNSResponse parse response to struct

func (*GoogleDNSResponse) Success

func (g *GoogleDNSResponse) Success() (bool, string)

Success 判断是否成功

type Question

type Question struct {
	Name string `json:"name"` // FQDN with trailing dot
	Type uint32 `json:"type"` // Standard DNS RR type
}

Question part of response

Jump to

Keyboard shortcuts

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