Documentation ¶
Index ¶
- Constants
- func QueryAPI(urlAddr string, params map[string]interface{}) ([]byte, error)
- type Answer
- type GoogleDNSRequest
- func (g *GoogleDNSRequest) ClientSubnet(subnet string) *GoogleDNSRequest
- func (g *GoogleDNSRequest) DisableDNSSEC(cd bool) *GoogleDNSRequest
- func (g *GoogleDNSRequest) Query() (*GoogleDNSResponse, error)
- func (g *GoogleDNSRequest) ResolveName(domain string) *GoogleDNSRequest
- func (g *GoogleDNSRequest) ResolveType(qtype uint16) *GoogleDNSRequest
- type GoogleDNSResponse
- type Question
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 ¶
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
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 判断是否成功
Click to show internal directories.
Click to hide internal directories.