transport

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 4 Imported by: 48

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeNetAddr

func MakeNetAddr(network, address string) (net.Addr, error)

MakeNetAddr returns a net.Addr based on the network and address. This is a helper for code that needs to return or provide a net.Addr. The address must be in "host:port" format with the host being a domain name, IPv4 or IPv6. The network must be "tcp" or "udp". For IP hosts, the returned address will be of type *net.TCPAddr or *net.UDPAddr, based on the network argument. This is important because some of the standard library functions inspect the type of the address and might return an "invalid argument" error if the type is not the correct one.

Types

type FuncPacketDialer added in v0.0.11

type FuncPacketDialer func(ctx context.Context, addr string) (net.Conn, error)

FuncPacketDialer is a PacketDialer that uses the given function to dial.

func (FuncPacketDialer) Dial added in v0.0.11

func (f FuncPacketDialer) Dial(ctx context.Context, addr string) (net.Conn, error)

Dial implements the PacketDialer interface.

type FuncPacketEndpoint added in v0.0.11

type FuncPacketEndpoint func(ctx context.Context) (net.Conn, error)

FuncPacketEndpoint is a PacketEndpoint that uses the given function to connect.

func (FuncPacketEndpoint) Connect added in v0.0.11

func (f FuncPacketEndpoint) Connect(ctx context.Context) (net.Conn, error)

Connect implements the PacketEndpoint interface.

type FuncStreamDialer added in v0.0.11

type FuncStreamDialer func(ctx context.Context, addr string) (StreamConn, error)

FuncStreamDialer is a StreamDialer that uses the given function to dial.

func (FuncStreamDialer) Dial added in v0.0.11

func (f FuncStreamDialer) Dial(ctx context.Context, addr string) (StreamConn, error)

Dial implements the StreamDialer interface.

type FuncStreamEndpoint added in v0.0.11

type FuncStreamEndpoint func(ctx context.Context) (StreamConn, error)

FuncStreamEndpoint is a StreamEndpoint that uses the given function to connect.

func (FuncStreamEndpoint) Connect added in v0.0.11

Connect implements the StreamEndpoint interface.

type PacketDialer

type PacketDialer interface {
	// Dial connects to `addr`.
	// `addr` has the form "host:port", where "host" can be a domain name or IP address.
	Dial(ctx context.Context, addr string) (net.Conn, error)
}

PacketDialer provides a way to dial a destination and establish datagram connections.

type PacketDialerEndpoint

type PacketDialerEndpoint struct {
	Dialer  PacketDialer
	Address string
}

PacketDialerEndpoint is a PacketEndpoint that connects to the given address using the specified PacketDialer.

func (*PacketDialerEndpoint) Connect

func (e *PacketDialerEndpoint) Connect(ctx context.Context) (net.Conn, error)

Connect implements PacketEndpoint.Connect.

type PacketEndpoint

type PacketEndpoint interface {
	// Connect creates a connection bound to an endpoint, returning the connection.
	Connect(ctx context.Context) (net.Conn, error)
}

PacketEndpoint represents an endpoint that can be used to establish packet connections (like UDP) to a fixed destination.

type PacketListener

type PacketListener interface {
	// ListenPacket creates a PacketConn that can be used to relay packets (such as UDP) through a proxy.
	ListenPacket(ctx context.Context) (net.PacketConn, error)
}

PacketListener provides a way to create a local unbound packet connection to send packets to different destinations.

type PacketListenerDialer

type PacketListenerDialer struct {
	// The PacketListener that is used to create the net.PacketConn to bind on Dial. Must be non nil.
	Listener PacketListener
}

PacketListenerDialer is a PacketDialer that connects to the destination using the specified PacketListener.

func (PacketListenerDialer) Dial

func (e PacketListenerDialer) Dial(ctx context.Context, address string) (net.Conn, error)

Dial implements PacketDialer.Dial. The address is in "host:port" format and the host must be either a full IP address (not "[::]") or a domain. The address must be supported by the WriteTo call of the net.PacketConn returned by the PacketListener. For example, a net.UDPConn only supports IP addresses, not domain names. If the host is a domain name, consider pre-resolving it to avoid resolution calls.

type StreamConn

type StreamConn interface {
	net.Conn
	// Closes the Read end of the connection, allowing for the release of resources.
	// No more reads should happen.
	CloseRead() error
	// Closes the Write end of the connection. An EOF or FIN signal can be
	// sent to the connection target.
	CloseWrite() error
}

StreamConn is a net.Conn that allows for closing only the reader or writer end of it, supporting half-open state.

func WrapConn

func WrapConn(c StreamConn, r io.Reader, w io.Writer) StreamConn

WrapConn wraps an existing StreamConn with a new io.Reader and io.Writer, but preserves the original StreamConn.CloseRead and StreamConn.CloseWrite.

type StreamDialer

type StreamDialer interface {
	// Dial connects to `raddr`.
	// `raddr` has the form "host:port", where "host" can be a domain name or IP address.
	Dial(ctx context.Context, raddr string) (StreamConn, error)
}

StreamDialer provides a way to dial a destination and establish stream connections.

type StreamDialerEndpoint

type StreamDialerEndpoint struct {
	Dialer  StreamDialer
	Address string
}

StreamDialerEndpoint is a StreamEndpoint that connects to the specified address using the specified StreamDialer.

func (*StreamDialerEndpoint) Connect

Connect implements StreamEndpoint.Connect.

type StreamEndpoint

type StreamEndpoint interface {
	// Connect establishes a connection with the endpoint, returning the connection.
	Connect(ctx context.Context) (StreamConn, error)
}

StreamEndpoint represents an endpoint that can be used to establish stream connections (like TCP) to a fixed destination.

type TCPEndpoint

type TCPEndpoint struct {
	// The Dialer used to create the net.Conn on Connect().
	Dialer net.Dialer
	// The endpoint address (host:port) to pass to Dial.
	// If the host is a domain name, consider pre-resolving it to avoid resolution calls.
	Address string
}

TCPEndpoint is a StreamEndpoint that connects to the specified address using the specified StreamDialer.

func (*TCPEndpoint) Connect

func (e *TCPEndpoint) Connect(ctx context.Context) (StreamConn, error)

Connect implements StreamEndpoint.Connect.

type TCPStreamDialer

type TCPStreamDialer struct {
	Dialer net.Dialer
}

TCPStreamDialer is a StreamDialer that uses the standard net.Dialer to dial. It provides a convenient way to use a net.Dialer when you need a StreamDialer.

func (*TCPStreamDialer) Dial

func (d *TCPStreamDialer) Dial(ctx context.Context, addr string) (StreamConn, error)

type UDPEndpoint

type UDPEndpoint struct {
	// The Dialer used to create the net.Conn on Connect().
	Dialer net.Dialer
	// The endpoint address ("host:port") to pass to Dial.
	// If the host is a domain name, consider pre-resolving it to avoid resolution calls.
	Address string
}

UDPEndpoint is a PacketEndpoint that connects to the specified address using UDP.

func (UDPEndpoint) Connect

func (e UDPEndpoint) Connect(ctx context.Context) (net.Conn, error)

Connect implements PacketEndpoint.Connect.

type UDPPacketDialer

type UDPPacketDialer struct {
	Dialer net.Dialer
}

UDPPacketDialer is a PacketDialer that uses the standard net.Dialer to dial. It provides a convenient way to use a net.Dialer when you need a PacketDialer.

func (*UDPPacketDialer) Dial

func (d *UDPPacketDialer) Dial(ctx context.Context, addr string) (net.Conn, error)

Dial implements PacketDialer.Dial.

type UDPPacketListener

type UDPPacketListener struct {
	net.ListenConfig
	// The local address to bind to, as specified in [net.ListenPacket].
	Address string
}

UDPPacketListener is a PacketListener that uses the standard net.ListenConfig.ListenPacket to listen.

func (UDPPacketListener) ListenPacket

func (l UDPPacketListener) ListenPacket(ctx context.Context) (net.PacketConn, error)

ListenPacket implements PacketListener.ListenPacket

Directories

Path Synopsis
Package tls provides the TLS transport.
Package tls provides the TLS transport.
Package tlsfrag provides tools to split the [TLS handshake record] containing the [Client Hello message] into multiple [TLS records].
Package tlsfrag provides tools to split the [TLS handshake record] containing the [Client Hello message] into multiple [TLS records].

Jump to

Keyboard shortcuts

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