Documentation ¶
Overview ¶
Package netx contains OONI's net extensions.
Index ¶
- func ChainResolvers(primary, secondary modelx.DNSResolver) modelx.DNSResolver
- func NewResolver(network, address string) (modelx.DNSResolver, error)
- type Dialer
- func (d *Dialer) ConfigureDNS(network, address string) error
- func (d *Dialer) Dial(network, address string) (net.Conn, error)
- func (d *Dialer) DialContext(ctx context.Context, network, address string) (conn net.Conn, err error)
- func (d *Dialer) DialTLS(network, address string) (net.Conn, error)
- func (d *Dialer) DialTLSContext(ctx context.Context, network, address string) (net.Conn, error)
- func (d *Dialer) ForceSkipVerify() error
- func (d *Dialer) ForceSpecificSNI(sni string) error
- func (d *Dialer) SetCABundle(path string) error
- func (d *Dialer) SetResolver(r modelx.DNSResolver)
- type EmitterConn
- type EmitterDialer
- type HTTPClient
- func (c *HTTPClient) CloseIdleConnections()
- func (c *HTTPClient) ConfigureDNS(network, address string) error
- func (c *HTTPClient) ForceSkipVerify() error
- func (c *HTTPClient) ForceSpecificSNI(sni string) error
- func (c *HTTPClient) SetCABundle(path string) error
- func (c *HTTPClient) SetResolver(r modelx.DNSResolver)
- type HTTPTransport
- func (t *HTTPTransport) CloseIdleConnections()
- func (t *HTTPTransport) ConfigureDNS(network, address string) error
- func (t *HTTPTransport) ForceSkipVerify() error
- func (t *HTTPTransport) ForceSpecificSNI(sni string) error
- func (t *HTTPTransport) RoundTrip(req *http.Request) (resp *http.Response, err error)
- func (t *HTTPTransport) SetCABundle(path string) error
- func (t *HTTPTransport) SetResolver(r modelx.DNSResolver)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChainResolvers ¶
func ChainResolvers(primary, secondary modelx.DNSResolver) modelx.DNSResolver
ChainResolvers chains a primary and a secondary resolver such that we can fallback to the secondary if primary is broken.
func NewResolver ¶
func NewResolver(network, address string) (modelx.DNSResolver, error)
NewResolver creates a standalone Resolver
Types ¶
type Dialer ¶
type Dialer struct { Beginning time.Time Handler modelx.Handler Resolver modelx.DNSResolver TLSConfig *tls.Config }
Dialer performs measurements while dialing.
func (*Dialer) ConfigureDNS ¶
ConfigureDNS configures the DNS resolver. The network argument selects the type of resolver. The address argument indicates the resolver address and depends on the network.
This functionality is not goroutine safe. You should only change the DNS settings before starting to use the Dialer.
The following is a list of all the possible network values:
- "": behaves exactly like "system"
- "system": this indicates that Go should use the system resolver and prevents us from seeing any DNS packet. The value of the address parameter is ignored when using "system". If you do not ConfigureDNS, this is the default resolver used.
- "udp": indicates that we should send queries using UDP. In this case the address is a host, port UDP endpoint.
- "tcp": like "udp" but we use TCP.
- "dot": we use DNS over TLS (DoT). In this case the address is the domain name of the DoT server.
- "doh": we use DNS over HTTPS (DoH). In this case the address is the URL of the DoH server.
For example:
d.ConfigureDNS("system", "") d.ConfigureDNS("udp", "8.8.8.8:53") d.ConfigureDNS("tcp", "8.8.8.8:53") d.ConfigureDNS("dot", "dns.quad9.net") d.ConfigureDNS("doh", "https://cloudflare-dns.com/dns-query")
func (*Dialer) DialContext ¶
func (d *Dialer) DialContext( ctx context.Context, network, address string, ) (conn net.Conn, err error)
DialContext is like Dial but the context allows to interrupt a pending connection attempt at any time.
func (*Dialer) DialTLSContext ¶
DialTLSContext is like DialTLS, but with context
func (*Dialer) ForceSkipVerify ¶
ForceSkipVerify forces to skip certificate verification
func (*Dialer) ForceSpecificSNI ¶
ForceSpecificSNI forces using a specific SNI.
func (*Dialer) SetCABundle ¶
SetCABundle configures the dialer to use a specific CA bundle. This function is not goroutine safe. Make sure you call it before starting to use this specific dialer.
func (*Dialer) SetResolver ¶
func (d *Dialer) SetResolver(r modelx.DNSResolver)
SetResolver is a more flexible way of configuring a resolver that should perhaps be used instead of ConfigureDNS.
type EmitterConn ¶ added in v3.13.0
EmitterConn is a net.Conn used to emit events
func (EmitterConn) Close ¶ added in v3.13.0
func (c EmitterConn) Close() (err error)
Close implements net.Conn.Close
type EmitterDialer ¶ added in v3.13.0
EmitterDialer is a Dialer that emits events
func (EmitterDialer) DialContext ¶ added in v3.13.0
DialContext implements Dialer.DialContext
type HTTPClient ¶
type HTTPClient struct { // HTTPClient is the underlying client. Pass this client to existing code // that expects an *http.HTTPClient. For this reason we can't embed it. HTTPClient *http.Client // Transport is the transport configured by NewClient to be used // by the HTTPClient field. Transport *HTTPTransport }
HTTPClient is a replacement for http.HTTPClient.
func NewHTTPClientWithProxyFunc ¶
NewHTTPClientWithProxyFunc creates a new client using the specified proxyFunc for handling proxying.
func NewHTTPClientWithoutProxy ¶
func NewHTTPClientWithoutProxy() *HTTPClient
NewHTTPClientWithoutProxy creates a new client instance that does not use any kind of proxy.
func (*HTTPClient) CloseIdleConnections ¶
func (c *HTTPClient) CloseIdleConnections()
CloseIdleConnections closes the idle connections.
func (*HTTPClient) ConfigureDNS ¶
func (c *HTTPClient) ConfigureDNS(network, address string) error
ConfigureDNS internally calls netx.Dialer.ConfigureDNS and therefore it has the same caveats and limitations.
func (*HTTPClient) ForceSkipVerify ¶
func (c *HTTPClient) ForceSkipVerify() error
ForceSkipVerify forces to skip certificate verification
func (*HTTPClient) ForceSpecificSNI ¶
func (c *HTTPClient) ForceSpecificSNI(sni string) error
ForceSpecificSNI forces using a specific SNI.
func (*HTTPClient) SetCABundle ¶
func (c *HTTPClient) SetCABundle(path string) error
SetCABundle internally calls netx.Dialer.SetCABundle and therefore it has the same caveats and limitations.
func (*HTTPClient) SetResolver ¶
func (c *HTTPClient) SetResolver(r modelx.DNSResolver)
SetResolver internally calls netx.Dialer.SetResolver
type HTTPTransport ¶
type HTTPTransport struct { Beginning time.Time Dialer *Dialer Handler modelx.Handler Transport *http.Transport // contains filtered or unexported fields }
HTTPTransport performs single HTTP transactions and emits measurement events as they happen.
func NewHTTPTransport ¶
func NewHTTPTransport() *HTTPTransport
NewHTTPTransport creates a new HTTP transport.
func NewHTTPTransportWithProxyFunc ¶
func NewHTTPTransportWithProxyFunc( proxyFunc func(*http.Request) (*url.URL, error), ) *HTTPTransport
NewHTTPTransportWithProxyFunc creates a transport without any handler attached using the specified proxy func.
func (*HTTPTransport) CloseIdleConnections ¶
func (t *HTTPTransport) CloseIdleConnections()
CloseIdleConnections closes the idle connections.
func (*HTTPTransport) ConfigureDNS ¶
func (t *HTTPTransport) ConfigureDNS(network, address string) error
ConfigureDNS is exactly like netx.Dialer.ConfigureDNS.
func (*HTTPTransport) ForceSkipVerify ¶
func (t *HTTPTransport) ForceSkipVerify() error
ForceSkipVerify forces to skip certificate verification
func (*HTTPTransport) ForceSpecificSNI ¶
func (t *HTTPTransport) ForceSpecificSNI(sni string) error
ForceSpecificSNI forces using a specific SNI.
func (*HTTPTransport) RoundTrip ¶
RoundTrip executes a single HTTP transaction, returning a Response for the provided Request.
func (*HTTPTransport) SetCABundle ¶
func (t *HTTPTransport) SetCABundle(path string) error
SetCABundle internally calls netx.Dialer.SetCABundle and therefore it has the same caveats and limitations.
func (*HTTPTransport) SetResolver ¶
func (t *HTTPTransport) SetResolver(r modelx.DNSResolver)
SetResolver is exactly like netx.Dialer.SetResolver.
Directories ¶
Path | Synopsis |
---|---|
Package handlers contains default modelx.Handler handlers.
|
Package handlers contains default modelx.Handler handlers. |
Package modelx contains the data modelx.
|
Package modelx contains the data modelx. |
Package oldhttptransport contains HTTP transport extensions.
|
Package oldhttptransport contains HTTP transport extensions. |