net

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenPipe

func ListenPipe() *pipeListener

ListenPipe creates a pipeListener that implement net.Listener and Dialer.

The returned Listener and Dialer operate on the same in-memory channel. Calling Dial on the Dialer will return a Conn that can be used to communicate with a Conn accepted from the Listener.

Types

type ContextDialer

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

A ContextDialer dials using a context.

type Dialer

type Dialer interface {
	// Dial connects to the given address
	Dial(network, addr string) (c net.Conn, err error)
}

A Dialer is a means to establish a connection. Custom dialers should also implement ContextDialer.

type Forwarder

type Forwarder interface {
	// Forward() a conn and someone may Accept() it from Listener
	Forward(ctx context.Context, c net.Conn) error
}

type ForwarderFunc

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

func (ForwarderFunc) Forward

func (f ForwarderFunc) Forward(ctx context.Context, c net.Conn) error

type Listener

type Listener net.Listener

type PrefixConn

type PrefixConn struct {
	net.Conn
	Prefix io.Reader
}

PrefixConn will first read Prefix until EOF, and then read the content from Conn.

func (*PrefixConn) Read

func (b *PrefixConn) Read(p []byte) (n int, err error)

type ServeMux

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

ServeMux will forward the connection (Conn) to different Forwarders based on the rules.

func (*ServeMux) Forward

func (r *ServeMux) Forward(ctx context.Context, c net.Conn) error

func (*ServeMux) HandlePrefix

func (r *ServeMux) HandlePrefix(prefix []byte, forwarder Forwarder)

Directories

Path Synopsis
cookiejar
Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar.
Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar.

Jump to

Keyboard shortcuts

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