requester

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUTLSRoundTripper

func NewUTLSRoundTripper(config *utls.Config, id *utls.ClientHelloID, tcpDialContext func(ctx context.Context, network, addr string) (net.Conn, error)) *utlsRoundTripper

NewUTLSRoundTripper creates a utlsRoundTripper with the given TLS configuration and ClientHelloID.

Types

type Config

type Config struct {
	// TransportMethod is the transport method to be used
	TransportMethod TransportMethodType

	// Target is the target addr/url for the recursive DNS server used
	Target string

	// Domain is the base domain for the DNS request that the responder is authoritative for
	BaseDomain string

	// Pubkey is the public key for the listening responder
	Pubkey []byte

	// UtlsDistribution allows utls distribution to be specified for the utls connection used during DoH and DoT
	UtlsDistribution string

	// DialTransport allows for a custom dialer to be used for the underlying TCP/UDP transport
	DialTransport dialFunc
}

type DNSPacketConn

type DNSPacketConn struct {

	// QueuePacketConn is the direct receiver of ReadFrom and WriteTo calls.
	// recvLoop and sendLoop take the messages out of the receive and send
	// queues and actually put them on the network.
	*queuepacketconn.QueuePacketConn
	// contains filtered or unexported fields
}

DNSPacketConn provides a packet-sending and -receiving interface over various forms of DNS. It handles the details of how packets and padding are encoded as a DNS name in the Question section of an upstream query, and as a TXT RR in downstream responses.

DNSPacketConn does not handle the mechanics of actually sending and receiving encoded DNS messages. That is rather the responsibility of some other net.PacketConn such as net.UDPConn, HTTPPacketConn, or TLSPacketConn, one of which must be provided to NewDNSPacketConn.

func NewDNSPacketConn

func NewDNSPacketConn(transport net.Conn, addr net.Addr, domain dns.Name) *DNSPacketConn

NewDNSPacketConn creates a new DNSPacketConn. transport, through its WriteTo and ReadFrom methods, handles the actual sending and receiving the DNS messages encoded by DNSPacketConn. addr is the address to be passed to transport.WriteTo whenever a message needs to be sent.

type HTTPPacketConn

type HTTPPacketConn struct {

	// QueuePacketConn is the direct receiver of ReadFrom and WriteTo calls.
	// sendLoop, via send, removes messages from the outgoing queue that
	// were placed there by WriteTo, and inserts messages into the incoming
	// queue to be returned from ReadFrom.
	*queuepacketconn.QueuePacketConn
	// contains filtered or unexported fields
}

HTTPPacketConn is an HTTP-based transport for DNS messages, used for DNS over HTTPS (DoH). Its WriteTo and ReadFrom methods exchange DNS messages over HTTP requests and responses.

HTTPPacketConn deals only with already formatted DNS messages. It does not handle encoding information into the messages. That is rather the responsibility of DNSPacketConn.

https://tools.ietf.org/html/rfc8484

func NewHTTPPacketConn

func NewHTTPPacketConn(rt http.RoundTripper, urlString string, numSenders int) (*HTTPPacketConn, error)

NewHTTPPacketConn creates a new HTTPPacketConn configured to use the HTTP server at urlString as a DNS over HTTP resolver. client is the http.Client that will be used to make requests. urlString should include any necessary path components; e.g., "/dns-query". numSenders is the number of concurrent sender-receiver goroutines to run.

type Requester

type Requester struct {
	// contains filtered or unexported fields
}

func NewRequester

func NewRequester(config *Config) (*Requester, error)

func (*Requester) Close

func (r *Requester) Close() error

func (*Requester) RequestAndRecv

func (r *Requester) RequestAndRecv(sendBytes []byte) ([]byte, error)

func (*Requester) SetDialer

func (r *Requester) SetDialer(dialer dialFunc) error

SetDialer sets a custom dialer for the underlying TCP/UDP transport

type TLSPacketConn

type TLSPacketConn struct {
	// QueuePacketConn is the direct receiver of ReadFrom and WriteTo calls.
	// recvLoop and sendLoop take the messages out of the receive and send
	// queues and actually put them on the network.
	*queuepacketconn.QueuePacketConn
}

TLSPacketConn is a TLS- and TCP-based transport for DNS messages, used for DNS over TLS (DoT). Its WriteTo and ReadFrom methods exchange DNS messages over a TLS channel, prefixing each message with a two-octet length field as in DNS over TCP.

TLSPacketConn deals only with already formatted DNS messages. It does not handle encoding information into the messages. That is rather the responsibility of DNSPacketConn.

https://tools.ietf.org/html/rfc7858

func NewTLSPacketConn

func NewTLSPacketConn(addr string, dialTLSContext func(ctx context.Context, network, addr string) (net.Conn, error)) (*TLSPacketConn, error)

NewTLSPacketConn creates a new TLSPacketConn configured to use the TLS server at addr as a DNS over TLS resolver. It maintains a TLS connection to the resolver, reconnecting as necessary. It closes the connection if any reconnection attempt fails.

type TransportMethodType

type TransportMethodType int

TransportMethodType declares the transport method to be used

const (
	DoH TransportMethodType = iota
	DoT
	UDP
)

Jump to

Keyboard shortcuts

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