Documentation ¶
Index ¶
- Constants
- Variables
- func CSVtoIPs(csv string) (ips []net.IP, err error)
- type DNSQuestion
- type DNSRR
- type DNSResponse
- type Endpoint
- type Endpoints
- type GDNSOptions
- type GDNSProvider
- type GDNSQuestion
- type GDNSQuestions
- type GDNSRR
- type GDNSRRs
- type GDNSResponse
- type Handler
- type HandlerOptions
- type Provider
- type SimpleDNSClient
Constants ¶
const ( LFATAL = iota LERROR LWARNING LINFO LDEBUG )
Log level for glog
const (
// DNSNameMaxBytes is the maximum number of bytes a DNS name may contain
DNSNameMaxBytes = 253
)
Variables ¶
var ErrFailedParsingIP = errors.New("unable to parse IP from string")
ErrFailedParsingIP is returned when the endpoint string looked valid, but the IP portion of the string was unable to be parsed
var ErrFailedParsingPort = errors.New("unable to parse port from string")
ErrFailedParsingPort is returned when the endpoint string looked valid, but the port portion of the string was unable to be parsed
var ErrInvalidEndpointString = errors.New("invalid endpoint string")
ErrInvalidEndpointString is returned when an endpoint string is in an unexpected format; the string is expected to be in `ip[:port]` format
Functions ¶
Types ¶
type DNSQuestion ¶
type DNSQuestion struct { Name string `json:"name,omitempty"` Type uint16 `json:"type,omitempty"` Subnet *dns.EDNS0_SUBNET `json:"subnet,omitempty"` }
DNSQuestion represents a DNS question to be resolved by a DNS server
type DNSRR ¶
type DNSRR struct { Name string `json:"name,omitempty"` Type uint16 `json:"type,omitempty"` TTL uint32 `json:"TTL,omitempty"` Data string `json:"data,omitempty"` }
DNSRR represents a DNS record, part of a response to a DNSQuestion
type DNSResponse ¶
type DNSResponse struct { Question []DNSQuestion Answer []DNSRR Authority []DNSRR Extra []dns.RR Truncated bool RecursionDesired bool RecursionAvailable bool AuthenticatedData bool CheckingDisabled bool ResponseCode int }
DNSResponse represents a complete DNS server response, to be served by the DNS server handler.
type Endpoint ¶
Endpoint represents a host/port combo
func CSVtoEndpoints ¶
CSVtoEndpoints takes a comma-separated string of endpoints, and parses to a []gdns.Endpoint
func ParseEndpoint ¶
ParseEndpoint parses a string into an Endpoint object, where the endpoint string is in the format of "ip:port". If a port is not present in the string, the defaultPort is used.
type GDNSOptions ¶
type GDNSOptions struct { // Pad specifies if a DNS request should be padded to a fixed length Pad bool // Secure specifies if a DNS request should check ca-certificates Secure bool // EndpointIPs is a list of IPs to be used as the GDNS endpoint, avoiding // DNS lookups in the case where they are provided. One is chosen randomly // for each request. EndpointIPs []net.IP // DNSServers is a list of Endpoints to be used as DNS servers when looking // up the endpoint; if not provided, the system DNS resolver is used. DNSServers Endpoints // Extension mechanisms for DNS EDNS string // PROXY for http get // Support SOCKS5 and SHADOWSOCKS PROXY string }
GDNSOptions is a configuration object for optional GDNSProvider configuration
type GDNSProvider ¶
type GDNSProvider struct {
// contains filtered or unexported fields
}
GDNSProvider is the Google DNS-over-HTTPS provider; it implements the Provider interface.
func NewGDNSProvider ¶
func NewGDNSProvider(endpoint string, opts *GDNSOptions) (*GDNSProvider, error)
NewGDNSProvider creates a GDNSProvider
func (GDNSProvider) Query ¶
func (g GDNSProvider) Query(q DNSQuestion) (*DNSResponse, error)
Query sends a DNS question to Google, and returns the response
type GDNSQuestion ¶
type GDNSQuestion DNSQuestion
GDNSQuestion represents a question response item from Google's DNS service This is currently the same as DNSQuestion, our internal implementation, but since Google's API is in flux, we keep them separate
func (GDNSQuestion) DNSQuestion ¶
func (r GDNSQuestion) DNSQuestion() DNSQuestion
DNSQuestion transforms a GDNSQuestion to a DNSQuestion and returns it.
type GDNSQuestions ¶
type GDNSQuestions []GDNSQuestion
GDNSQuestions is a array of GDNSQuestion objects
func (GDNSQuestions) DNSQuestions ¶
func (rs GDNSQuestions) DNSQuestions() (rqs []DNSQuestion)
DNSQuestions transforms an array of GDNSQuestion objects to an array of DNSQuestion objects
type GDNSRR ¶
type GDNSRR DNSRR
GDNSRR represents a dns response record item from Google's DNS service. This is currently the same as DNSRR, our internal implementation, but since Google's API is in flux, we keep them separate
type GDNSResponse ¶
type GDNSResponse struct { Status int32 `json:"Status"` TC bool `json:"TC"` RD bool `json:"RD"` RA bool `json:"RA"` AD bool `json:"AD"` CD bool `json:"CD"` Question GDNSQuestions `json:"Question,omitempty"` Answer GDNSRRs `json:"Answer,omitempty"` Authority GDNSRRs `json:"Authority,omitempty"` Additional GDNSRRs `json:"Additional,omitempty"` EDNSClientSubnet string `json:"edns_client_subnet,omitempty"` Comment string `json:"Comment,omitempty"` }
GDNSResponse represents a response from the Google DNS-over-HTTPS servers
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler represents a DNS handler
func NewHandler ¶
func NewHandler(provider Provider, options *HandlerOptions) *Handler
NewHandler creates a new Handler
type HandlerOptions ¶
type HandlerOptions struct{}
HandlerOptions specifies options to be used when instantiating a handler
type Provider ¶
type Provider interface {
Query(DNSQuestion) (*DNSResponse, error)
}
Provider is an interface representing a servicer of DNS queries.
type SimpleDNSClient ¶
type SimpleDNSClient struct {
// contains filtered or unexported fields
}
SimpleDNSClient is a DNS client, primarily for internal use in secure operator.
It provides an in-memory cache, but was optimized to look up one address at a time only.
func NewSimpleDNSClient ¶
func NewSimpleDNSClient(servers Endpoints) (*SimpleDNSClient, error)
NewSimpleDNSClient creates a SimpleDNSClient