query

package
v0.0.0-...-74176d5 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_BACKOFF_TIME time.Duration = 2500 * time.Millisecond
View Source
const DEFAULT_DNS_PORT = 53
View Source
const DEFAULT_DOH_PARAM = "dns"
View Source
const DEFAULT_DOH_PATH = "/dns-query{?dns}"
View Source
const DEFAULT_DOH_PORT = 443
View Source
const DEFAULT_DOH_TIMEOUT = 5000 * time.Millisecond
View Source
const DEFAULT_DOQ_PORT = 853

see https://www.rfc-editor.org/rfc/rfc9250.html#section-4.1.1

View Source
const DEFAULT_DOQ_TIMEOUT time.Duration = 5000 * time.Millisecond
View Source
const DEFAULT_DOT_PORT = 853
View Source
const DEFAULT_DOT_TIMEOUT time.Duration = 5000 * time.Millisecond
View Source
const DEFAULT_RECURSIVE_RESOLVER = "8.8.8.8"
View Source
const DEFAULT_TCP_RETRIES = 1
View Source
const DEFAULT_TCP_TIMEOUT time.Duration = 2500 * time.Millisecond
View Source
const DEFAULT_TLS_PORT = 443
View Source
const DEFAULT_TLS_TIMEOUT time.Duration = 2500 * time.Millisecond
View Source
const DEFAULT_UDP_RETRIES = 3
View Source
const DEFAULT_UDP_TIMEOUT time.Duration = 2500 * time.Millisecond
View Source
const DNS_DOT_PROTOCOL = "tcp-tls"
View Source
const DNS_TCP = "tcp"
View Source
const DNS_UDP = "udp"
View Source
const DOH_MEDIA_TYPE = "application/dns-message"
View Source
const HTTP_GET = "GET"
View Source
const HTTP_POST = "POST"
View Source
const HTTP_VERSION_1 = "HTTP/1.1"
View Source
const HTTP_VERSION_2 = "HTTP2"
View Source
const HTTP_VERSION_3 = "HTTP3"
View Source
const MAX_URI_LENGTH = 2048
View Source
const TLS_PROTOCOL_TCP = "tcp"
View Source
const TLS_PROTOCOL_UDP = "udp"

Variables

View Source
var DOQ_TLS_PROTOCOLS = []string{"doq", "dq"}

nolint: gochecknoglobals

Functions

func AddQuicPrefix

func AddQuicPrefix(b []byte) (m []byte)

AddQuicPrefix adds a 2-byte prefix with the DNS message length. see https://datatracker.ietf.org/doc/html/rfc9250#section-4.2-4

func GetPathParamFromDoHPath

func GetPathParamFromDoHPath(uri string) (path string, param string, err *custom_errors.DoEError)

Types

type CertificateQuery

type CertificateQuery struct {
	// Host is the host for the dialer (required)
	Host string `json:"host"`
	// Port is the port for the dialer (default: 443)
	Port int `json:"port"`
	// Protocol is the protocol for the dialer (default: "tcp")
	Protocol string `json:"protocol"`
	// Timeout is the timeout in ms (default: 2500)
	Timeout time.Duration `json:"timeout"`
	// SNI
	SNI string `json:"sni"`
	// ALPN protocol
	ALPN []string `json:"alpn"`
}

func NewCertificateQuery

func NewCertificateQuery() (q *CertificateQuery)

func (*CertificateQuery) Check

func (cq *CertificateQuery) Check() (err custom_errors.DoEErrors)

type CertificateQueryHandler

type CertificateQueryHandler struct {
	QueryHandler DialHandler
}

func NewCertificateQueryHandler

func NewCertificateQueryHandler() (qh *CertificateQueryHandler)

func (*CertificateQueryHandler) Query

type CertificateResponse

type CertificateResponse struct {
	// Certificate is the certificate
	Certificates []*x509.Certificate `json:"certificates"`

	RetryWithoutCertificateVerification bool `json:"retry_without_certificate_verification"`
}

type Conn

type Conn interface {
	Close() error
	ConnectionState() tls.ConnectionState
}

type ConventionalDNSQuery

type ConventionalDNSQuery struct {
	DNSQuery

	// protocol to use (default: udp)
	Protocol string `json:"protocol"`
	// maximum number of UDP retries (default: 3)
	MaxUDPRetries int `json:"max_udp_retries"`
	// fallback to TCP if UDP fails (default: true)
	AutoFallbackTCP bool `json:"auto_fallback_tcp"`
	// maximum number of TCP retries (default: 1)
	MaxTCPRetries int `json:"max_tcp_retries"`
	// timeout in ms for UDP (default: 2500)
	//
	// if Timeout is set, it will overwrite this value
	TimeoutUDP time.Duration `json:"timeout_udp"`
	// timeout in ms for TCP (default: 2500)
	//
	// if Timeout is set, it will overwrite this value
	TimeoutTCP time.Duration `json:"timeout_tcp"`
	// maximum backoff time in ms (default: 2500)
	MaxBackoffTime time.Duration `json:"max_backoff_time"`
}

func NewConventionalQuery

func NewConventionalQuery() *ConventionalDNSQuery

func NewDDRQuery

func NewDDRQuery() *ConventionalDNSQuery

type ConventionalDNSQueryHandler

type ConventionalDNSQueryHandler struct {
	ConventionalDNSQueryHandlerI

	Sleeper      sleeper
	QueryHandler QueryHandlerDNS
}

func NewConventionalDNSQueryHandler

func NewConventionalDNSQueryHandler() *ConventionalDNSQueryHandler

func NewDDRQueryHandler

func NewDDRQueryHandler() *ConventionalDNSQueryHandler

func NewPTRQueryHandler

func NewPTRQueryHandler() (qh *ConventionalDNSQueryHandler)

func (*ConventionalDNSQueryHandler) Query

type ConventionalDNSQueryHandlerI

type ConventionalDNSQueryHandlerI interface {
	Query(query *ConventionalDNSQuery) (res *ConventionalDNSResponse, err custom_errors.DoEErrors)
}

type ConventionalDNSResponse

type ConventionalDNSResponse struct {
	Response      *DNSResponse `json:"response"`
	UDPAttempts   int          `json:"udp_attempts"`
	TCPAttempts   int          `json:"tcp_attempts"`
	AttemptErrors []string     `json:"attempt_errors"`
}

type DNSQuery

type DNSQuery struct {
	// Host is the nameserver to query
	Host string `json:"host"`
	// QueryMsg is the DNS message to send
	QueryMsg *dns.Msg `json:"query_msg"`
	// Port is the port number (default: 443)
	Port int `json:"port"`
	// Timeout is the timeout in ms (default: 5000)
	Timeout time.Duration `json:"timeout"`
}

func (*DNSQuery) Check

func (q *DNSQuery) Check(checkForTimeout bool) (err custom_errors.DoEErrors)

type DNSResponse

type DNSResponse struct {
	// Response is the DNS response
	ResponseMsg *dns.Msg `json:"response"`
	// RTT is the round-trip time
	RTT time.Duration `json:"rtt"`
}

type DefaultQueryHandlerDNS

type DefaultQueryHandlerDNS struct{}

func NewDefaultQueryHandler

func NewDefaultQueryHandler() *DefaultQueryHandlerDNS

func (*DefaultQueryHandlerDNS) Query

func (df *DefaultQueryHandlerDNS) Query(host string, query *dns.Msg, protocol string, timeout time.Duration, tlsConfig *tls.Config) (answer *dns.Msg, rtt time.Duration, err error)

type DefaultQuicDialHandler

type DefaultQuicDialHandler struct{}

func (*DefaultQuicDialHandler) DialAddr

func (d *DefaultQuicDialHandler) DialAddr(ctx context.Context, addr string, tlsConf *tls.Config, conf *quic.Config) (QuicConn, error)

type DialHandler

type DialHandler interface {
	DialWithDialer(dialer *net.Dialer, network string, port string, tlsConf *tls.Config) (Conn, error)
}

type DoEQuery

type DoEQuery struct {
	DNSQuery

	SkipCertificateVerify bool   `json:"skip_certificate_verify"`
	SNI                   string `json:"sni"`
}

type DoEResponse

type DoEResponse struct {
	DNSResponse

	CertificateVerified bool `json:"certificate_verified"`
	CertificateValid    bool `json:"certificate_valid"`
}

type DoHQuery

type DoHQuery struct {
	DoEQuery

	// the URI path for the DoH query, usually /dns-query{?dns}
	URI string `json:"uri"`

	// the full URI including the query param
	FullEndpointURI string `json:"full_endpoint_uri"`

	// HTTP method, either GET or POST
	Method string `json:"method"`

	// fallback to POST request if GET request is too long for URI (default: true)
	POSTFallback bool `json:"post_fallback"`

	// HTTP1, HTTP2 or HTTP3 support (default:HTTP2)
	HTTPVersion string `json:"http_version"`
}

func NewDoHQuery

func NewDoHQuery() (q *DoHQuery)

type DoHQueryHandler

type DoHQueryHandler struct {
	// QueryHandler is an interface to execute HTTP requests
	QueryHandler HttpHandler
}

func NewDoHQueryHandler

func NewDoHQueryHandler() (qh *DoHQueryHandler)

func (*DoHQueryHandler) Query

type DoHResponse

type DoHResponse struct {
	DoEResponse
}

type DoQQuery

type DoQQuery struct {
	DoEQuery
}

func NewDoQQuery

func NewDoQQuery() (q *DoQQuery)

type DoQQueryHandler

type DoQQueryHandler struct {
	// QueryHandler is the QUIC dial handler (defaults to quic.DialAddr)
	QueryHandler QuicDialHandler
}

func NewDoQQueryHandler

func NewDoQQueryHandler() (qh *DoQQueryHandler)

func (*DoQQueryHandler) Query

This DoQ implementation is inspired by the q library, see https://github.com/natesales/q/blob/main/transport/quic.go

type DoQResponse

type DoQResponse struct {
	DoEResponse
}

type DoTQuery

type DoTQuery struct {
	DoEQuery
}

func NewDoTQuery

func NewDoTQuery() (q *DoTQuery)

type DoTQueryHandler

type DoTQueryHandler struct {
	QueryHandler QueryHandlerDNS
}

func NewDoTQueryHandler

func NewDoTQueryHandler() (h *DoTQueryHandler)

func (*DoTQueryHandler) Query

type DoTResponse

type DoTResponse struct {
	DoEResponse
}

type HttpHandler

type HttpHandler interface {
	Do(req *http.Request) (*http.Response, error)
	SetTransport(t http.RoundTripper)
	SetTimeout(timeout time.Duration)
}

type PTRQuery

type PTRQuery struct {
	ConventionalDNSQuery
}

func NewPTRQuery

func NewPTRQuery() *PTRQuery

func (*PTRQuery) SetQueryMsg

func (p *PTRQuery) SetQueryMsg(resolveIp string) custom_errors.DoEErrors

type QueryHandler

type QueryHandler interface {
	Query(query *DNSQuery) (res *QueryResponse, err error)
}

type QueryHandlerDNS

type QueryHandlerDNS interface {
	Query(host string, query *dns.Msg, protocol string, timeout time.Duration, tlsConfig *tls.Config) (answer *dns.Msg, rtt time.Duration, err error)
}

type QueryResponse

type QueryResponse struct {
	DNSResponse
}

type QuicConn

type QuicConn interface {
	CloseWithError(quic.ApplicationErrorCode, string) error
	OpenStream() (quic.Stream, error)
}

type QuicDialHandler

type QuicDialHandler interface {
	DialAddr(ctx context.Context, addr string, tlsConf *tls.Config, conf *quic.Config) (QuicConn, error)
}

Jump to

Keyboard shortcuts

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