gdns

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GoogleDNSAPI Google DNS over HTTPS
	// ref. https://developers.google.com/speed/public-dns/docs/dns-over-https
	GoogleDNSAPI = "https://dns.google.com/"
	// RequestRetryBackoff default 3
	RequestRetryBackoff = 3
)
View Source
const PluginName = "Google DNS Plugin"

PluginName for g.Name

Variables

View Source
var (
	// HTTPClient used to query Google DNS API
	HTTPClient *http.Client
)

Functions

This section is empty.

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) GetRRHeader

func (a Answer) GetRRHeader() dns.RR_Header

GetRRHeader 获取 rr header reuse code from github.com/oif/proton/gdns/response.go

func (Answer) ToRR

func (a Answer) ToRR() (rr dns.RR)

ToRR convert a google dns anwser to dns.RR @TODO refactor useing reflect feature

type Plugin

type Plugin struct {
	EnableProxy bool
	ProxyAddr   string
}

Plugin implements pkg/plugin/v1

func (*Plugin) AfterResponse

func (p *Plugin) AfterResponse(c *plugin.Context, err error)

AfterResponse implements plugin

func (*Plugin) Initialize

func (p *Plugin) Initialize() error

Initialize Google DNS Plugin

func (*Plugin) Name

func (p *Plugin) Name() string

Name return the name of this plugin

func (*Plugin) Patch

func (p *Plugin) Patch(c *plugin.Context)

Patch the dns pakcage

func (*Plugin) Warmup

func (p *Plugin) Warmup(c *plugin.Context)

Warmup implements plugin

type Question

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

Question part of response

type ResolveRequest

type ResolveRequest struct {
	Name string // string, required
	// The only required parameter.
	// Its length must be between 1 and 253 (ignoring an optional trailing dot if present).
	// All labels (parts of the name separated by dots) must be 1 to 63 bytes long.
	// The API does not support names with escaped or non-ASCII characters, but they are not explicitly rejected.
	// Internationalized domain names must use punycode format (e.g. "xn--qxam" rather than "ελ").
	Type uint16 // string, default: 1
	// RR type can be represented as a number in [1, 65535] or a canonical string (case-insensitive, such as A or aaaa).
	// You can use 255 for 'ANY' queries but be aware that this is not a replacement for sending queries for both
	// A and AAAA or MX records. Authoritative name servers need not return all records for such queries;
	// some do not respond, and others (such as cloudflare.com) return only HINFO.
	CheckingDisabled bool // boolean, default: false
	// The CD (checking disabled) bit. Use cd, cd=1, or cd=true to disable DNSSEC validation;
	// use cd=0, cd=false, or no cd parameter to enable DNSSEC validation.
	EDNSClientSubnet string // string, default: empty
	// The edns0-client-subnet option. Format is an IP address with a subnet mask. Examples: 1.2.3.4/24, 2001:700:300::/48.
	// If you are using DNS-over-HTTPS because of privacy concerns,
	// and do not want any part of your IP address to be sent to authoritative name servers for geographic location accuracy,
	// use edns_client_subnet=0.0.0.0/0. Google Public DNS normally sends approximate network information
	// (usually zeroing out the last part of your IPv4 address).
	RandomPadding string // string, ignored

}

ResolveRequest parse request data to struct

func (*ResolveRequest) Request

func (r *ResolveRequest) Request() (response []byte, statusCode int, err error)

Request Google DNS API

type ResolveResponse

type ResolveResponse struct {
	Status             int           `json:"Status"`             // 0 success, 2 error. Standard DNS response code (32 bit integer)
	Truncated          bool          `json:"TC"`                 // Whether the response is truncated
	RecursionDesired   bool          `json:"RD"`                 // RD, Always true for Google Public DNS
	RecursionAvailable bool          `json:"RA"`                 // RA, Always true for Google Public DNS
	AuthenticatedData  bool          `json:"AD"`                 // AD, Whether all response data was validated with DNSSEC
	CheckingDisabled   bool          `json:"CD"`                 // CD, Whether the client asked to disable DNSSEC
	Question           []Question    `json:"Question"`           // Question
	Answer             []Answer      `json:"Answer"`             // Answer
	Authority          []Answer      `json:"Authority"`          // Authority
	Additional         []interface{} `json:"Additional"`         // Additional response
	EDNSClientSubnet   string        `json:"edns_client_subnet"` // IP address / scope prefix-length, ref. https://tools.ietf.org/html/draft-ietf-dnsop-edns-client-subnet-08#section-6
	Comment            string        `json:"Comment"`            // Comment
}

ResolveResponse from Google DNS API

func BytesToResolveResponse

func BytesToResolveResponse(bytes []byte) (rr *ResolveResponse, err error)

BytesToResolveResponse convert resolve request response(bytes) to ResolveResponse

func (*ResolveResponse) Success

func (r *ResolveResponse) Success() (bool, string)

Success if response status is 0 means success, otherwise will have a comment for failure detail

Jump to

Keyboard shortcuts

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