netx

package
v0.0.0-...-bd88772 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package netx contains OONI's net extensions.

Index

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 NewDialer

func NewDialer() *Dialer

NewDialer creates a new Dialer instance.

func (*Dialer) ConfigureDNS

func (d *Dialer) ConfigureDNS(network, address string) error

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) Dial

func (d *Dialer) Dial(network, address string) (net.Conn, error)

Dial creates a TCP or UDP connection. See net.Dial docs.

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) DialTLS

func (d *Dialer) DialTLS(network, address string) (net.Conn, error)

DialTLS is like Dial, but creates TLS connections.

func (*Dialer) DialTLSContext

func (d *Dialer) DialTLSContext(
	ctx context.Context, network, address string,
) (net.Conn, error)

DialTLSContext is like DialTLS, but with context

func (*Dialer) ForceSkipVerify

func (d *Dialer) ForceSkipVerify() error

ForceSkipVerify forces to skip certificate verification

func (*Dialer) ForceSpecificSNI

func (d *Dialer) ForceSpecificSNI(sni string) error

ForceSpecificSNI forces using a specific SNI.

func (*Dialer) SetCABundle

func (d *Dialer) SetCABundle(path string) error

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 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 NewHTTPClient

func NewHTTPClient() *HTTPClient

NewHTTPClient creates a new client instance.

func NewHTTPClientWithProxyFunc

func NewHTTPClientWithProxyFunc(
	proxyFunc func(*http.Request) (*url.URL, error),
) *HTTPClient

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

func (t *HTTPTransport) RoundTrip(
	req *http.Request,
) (resp *http.Response, err error)

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 connid contains code to generate the connectionID
Package connid contains code to generate the connectionID
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.
Package transactionid contains code to share the transactionID
Package transactionid contains code to share the transactionID

Jump to

Keyboard shortcuts

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