Documentation
¶
Index ¶
- Variables
- func FromURL(u *url.URL, forward proxy.Dialer) (proxy.Dialer, error)
- type SocksClient
- func (c *SocksClient) Dial(proxyUri *url.URL, address string) (conn *dns.Conn, err error)
- func (c *SocksClient) DialContext(ctx context.Context, proxyUri *url.URL, address string) (conn *dns.Conn, err error)
- func (c *SocksClient) Exchange(m *dns.Msg, proxyUri *url.URL, address string) (*dns.Msg, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultTimeout = 10 * time.Second
DefaultTimeout is the fallback timeout applied to DNS exchanges (and to the dial to the SOCKS proxy) when a SocksClient does not set its own Timeout. It is configurable at startup via the --dns-timeout flag. miekg/dns defaults to a 2s read deadline, which is too short once a proxy adds latency, so we raise the effective default here.
Functions ¶
Types ¶
type SocksClient ¶
type SocksClient struct {
Client *dns.Client
// Timeout overrides DefaultTimeout for this client when greater than zero.
Timeout time.Duration
}
func (*SocksClient) DialContext ¶
func (c *SocksClient) DialContext(ctx context.Context, proxyUri *url.URL, address string) (conn *dns.Conn, err error)
DialContext connects to the address on the named network, with a context.Context.
func (*SocksClient) Exchange ¶
Exchange performs a synchronous query. It sends the message m to the address contained in a and waits for a reply. Basic use pattern with a *dns.Client:
c := new(dns.Client) in, rtt, err := c.Exchange(message, "127.0.0.1:53")
Exchange does not retry a failed query, nor will it fall back to TCP in case of truncation. It is up to the caller to create a message that allows for larger responses to be returned. Specifically this means adding an EDNS0 OPT RR that will advertise a larger buffer, see SetEdns0. Messages without an OPT RR will fallback to the historic limit of 512 bytes To specify a local address or a timeout, the caller has to set the `Client.Dialer` attribute appropriately