transport

package
v0.9.13 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 38

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConnected = errors.New("client is not connected")
)

Functions

func DialContext added in v0.8.0

func DialContext(ctx context.Context, c Config, network, address string) (net.Conn, error)

func DialWith

func DialWith(
	ctx context.Context,
	dialer Dialer,
	network, host string,
	addresses []string,
	port string,
) (c net.Conn, err error)

DialWith randomly dials one of a number of addresses with a given dialer.

Use this to select and dial one IP being known for one host name.

Types

type Client

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

func NewClient

func NewClient(c Config, network, host string, defaultPort int) (*Client, error)

func NewClientWithDialer

func NewClientWithDialer(d Dialer, c Config, network, host string, defaultPort int) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) ConnectContext added in v0.8.0

func (c *Client) ConnectContext(ctx context.Context) error

func (*Client) Host

func (c *Client) Host() string

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) LocalAddr

func (c *Client) LocalAddr() net.Addr

func (*Client) Read

func (c *Client) Read(b []byte) (int, error)

func (*Client) RemoteAddr

func (c *Client) RemoteAddr() net.Addr

func (*Client) SetDeadline

func (c *Client) SetDeadline(t time.Time) error

func (*Client) SetReadDeadline

func (c *Client) SetReadDeadline(t time.Time) error

func (*Client) SetWriteDeadline

func (c *Client) SetWriteDeadline(t time.Time) error

func (*Client) String

func (c *Client) String() string

func (*Client) Test

func (c *Client) Test(d testing.Driver)

func (*Client) Write

func (c *Client) Write(b []byte) (int, error)

type Config

type Config struct {
	Proxy   *ProxyConfig
	TLS     *tlscommon.TLSConfig
	Timeout time.Duration
	Stats   IOStatser
}

type Dialer

type Dialer interface {
	Dial(network, address string) (net.Conn, error)
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

func ConnWrapper

func ConnWrapper(d Dialer, w func(net.Conn) net.Conn) Dialer

func LoggingDialer

func LoggingDialer(d Dialer, logger *logp.Logger) Dialer

func MakeDialer

func MakeDialer(c Config) (Dialer, error)

func NetDialer

func NetDialer(timeout time.Duration) Dialer

func ProxyDialer

func ProxyDialer(log *logp.Logger, config *ProxyConfig, forward Dialer) (Dialer, error)

func StatsDialer

func StatsDialer(d Dialer, s IOStatser) Dialer

func TLSDialer

func TLSDialer(forward Dialer, config *tlscommon.TLSConfig, timeout time.Duration) Dialer

func TestNetDialer

func TestNetDialer(d testing.Driver, timeout time.Duration) Dialer

func TestTLSDialer

func TestTLSDialer(
	d testing.Driver,
	forward Dialer,
	config *tlscommon.TLSConfig,
	timeout time.Duration,
) Dialer

func TestUnixDialer

func TestUnixDialer(d testing.Driver, timeout time.Duration, sockFile string) Dialer

TestUnixDialer creates a Test Unix Dialer when using domain socket.

func UnixDialer

func UnixDialer(timeout time.Duration, sockFile string) Dialer

UnixDialer creates a Unix Dialer when using unix domain socket.

type DialerFunc

type DialerFunc func(ctx context.Context, network, address string) (net.Conn, error)

func (DialerFunc) Dial

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

func (DialerFunc) DialContext added in v0.8.0

func (d DialerFunc) DialContext(ctx context.Context, network, address string) (net.Conn, error)

type DialerFuncH2

type DialerFuncH2 func(ctx context.Context, network, address string, cfg *tls.Config) (net.Conn, error)

func (DialerFuncH2) DialContext added in v0.8.0

func (d DialerFuncH2) DialContext(ctx context.Context, network, address string, cfg *tls.Config) (net.Conn, error)

type DialerH2

type DialerH2 interface {
	DialContext(ctx context.Context, network, address string, cfg *tls.Config) (net.Conn, error)
}

func TLSDialerH2

func TLSDialerH2(forward Dialer, config *tlscommon.TLSConfig, timeout time.Duration) (DialerH2, error)

func TestTLSDialerH2

func TestTLSDialerH2(
	d testing.Driver,
	forward Dialer,
	config *tlscommon.TLSConfig,
	timeout time.Duration,
) (DialerH2, error)

type IOStatser

type IOStatser interface {
	WriteError(err error)
	WriteBytes(int)

	ReadError(err error)
	ReadBytes(int)
}

type PipeListener

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

PipeListener is a net.PipeListener that uses net.Pipe It is only relevant for the APM Server instrumentation of itself

func NewPipeListener

func NewPipeListener() *PipeListener

NewPipeListener returns a new PipeListener.

func (*PipeListener) Accept

func (l *PipeListener) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener. This is part of the net.listener address.

func (*PipeListener) Addr

func (l *PipeListener) Addr() net.Addr

Addr returns the listener's network address. This is part of the net.listener interface.

The returned address's network and value are always both "pipe", the same as the addresses returned by net.Pipe connections.

func (*PipeListener) Close

func (l *PipeListener) Close() error

Close closes the listener. This is part of the net.PipeListener interface.

func (*PipeListener) DialContext

func (l *PipeListener) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

DialContext dials a connection to the listener, blocking until a paired Accept call is made, the listener is closed, or the context is canceled/expired.

type ProxyConfig

type ProxyConfig struct {
	// URL of the SOCKS proxy. Scheme must be socks5. Username and password can be
	// embedded in the URL.
	URL string `config:"proxy_url"`

	// Resolve names locally instead of on the SOCKS server.
	LocalResolve bool `config:"proxy_use_local_resolver"`
}

ProxyConfig holds the configuration information required to proxy connections through a SOCKS5 proxy server.

func (*ProxyConfig) Validate

func (c *ProxyConfig) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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