network

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilRead  = errors.New("cannot read from nilConn")
	ErrNilWrite = errors.New("cannot write to nilConn")
)
View Source
var ConnectionTrackerLogger logr.Logger = logr.Discard()
View Source
var ErrInvalidCertificate = errors.New("invalid tls certificate")

Functions

func NewConnectionToContext

func NewConnectionToContext(ctx context.Context) context.Context

func NewNilConn

func NewNilConn() net.Conn

func NewWrappedListener

func NewWrappedListener(l net.Listener) net.Listener

func SetConnectionToContextConnectionHolder

func SetConnectionToContextConnectionHolder(ctx context.Context, conn net.Conn) bool

func WrapHTTPTransport

func WrapHTTPTransport(rt http.RoundTripper, dialer ConnectionDialer) http.RoundTripper

func WrapTLSConfig

func WrapTLSConfig(config *tls.Config) *tls.Config

func WrappedConnectionToContext

func WrappedConnectionToContext(ctx context.Context, conn net.Conn) context.Context

Types

type Certificate

type Certificate interface {
	GetCertificate() *x509.Certificate
	GetSHA256Digest() string
	GetSubject() string
	GetFirstURI() string
	GetFirstDNSName() string
	GetFirstIP() string
}

func NewCertificate

func NewCertificate(cert *x509.Certificate) Certificate

func ParseTLSCertificate

func ParseTLSCertificate(cert *tls.Certificate) (Certificate, error)

type ConnWithTLSConnectionState

type ConnWithTLSConnectionState interface {
	ConnectionState() tls.ConnectionState
}

type Connection

type Connection interface {
	net.Conn

	NetConn() net.Conn
	SetNetConn(net.Conn)
	GetTimeToFirstByte() time.Time
	GetLocalCertificate() Certificate
	GetPeerCertificate() Certificate
	SetLocalCertificate(cert *tls.Certificate)
	GetConnectionState() *tls.ConnectionState
	SetConnWithTLSConnectionState(ConnWithTLSConnectionState)
	SetOptions(opts ...WrappedConnectionOption)
	GetOriginalAddress() string
}

func NewWrappedConnection

func NewWrappedConnection(conn net.Conn, opts ...WrappedConnectionOption) Connection

func WrappedConnectionFromContext

func WrappedConnectionFromContext(ctx context.Context) (Connection, bool)

func WrappedConnectionFromNetConn

func WrappedConnectionFromNetConn(conn net.Conn) (Connection, bool)

type ConnectionCloseWrapper

type ConnectionCloseWrapper interface {
	AddParentCloseWrapper(ConnectionCloseWrapper)
	BeforeClose(net.Conn) error
	AfterClose(net.Conn) error
}

type ConnectionDialer

type ConnectionDialer interface {
	DialTLSContext(ctx context.Context, network, address string) (net.Conn, error)
	// contains filtered or unexported methods
}

func NewDialer

func NewDialer(opts ...DialerOption) ConnectionDialer

func NewDialerWithTLS

func NewDialerWithTLS(certFile, keyFile string, insecure bool, opts ...DialerOption) (ConnectionDialer, error)

func NewDialerWithTLSConfig

func NewDialerWithTLSConfig(config *tls.Config, opts ...DialerOption) ConnectionDialer

type ConnectionHolder

type ConnectionHolder interface {
	SetConn(net.Conn)
	NetConn() net.Conn
}

func ConnectionHolderFromContext

func ConnectionHolderFromContext(ctx context.Context) (ConnectionHolder, bool)

type DialWrapper

type DialWrapper interface {
	AddParentDialerWrapper(DialWrapper)
	BeforeDial(ctx context.Context, network, addr string) error
	AfterDial(ctx context.Context, conn net.Conn, network, addr string) error
}

type DialerOption

type DialerOption func(*dialer)

func DialerWithDialerWrapper

func DialerWithDialerWrapper(w DialWrapper) DialerOption

func DialerWithWrappedConnectionOptions

func DialerWithWrappedConnectionOptions(opts ...WrappedConnectionOption) DialerOption

type Server

type Server interface {
	GetUnifiedListener() ltls.UnifiedListener
	Serve(l net.Listener) error
	ServeTLS(l net.Listener, certFile, keyFile string) error
	ServeWithTLSConfig(l net.Listener, config *tls.Config) error
	GetHTTPServer() *http.Server
}

func WrapHTTPServer

func WrapHTTPServer(srv *http.Server) Server

type WrappedConnectionOption

type WrappedConnectionOption func(*wrappedConn)

func WrappedConnectionWithCloserWrapper

func WrappedConnectionWithCloserWrapper(closeWrapper ConnectionCloseWrapper) WrappedConnectionOption

func WrappedConnectionWithOriginalAddress

func WrappedConnectionWithOriginalAddress(address string) WrappedConnectionOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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