network

package
v0.2.0-dev.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionStateTrackerLogger logr.Logger = logr.Discard()
View Source
var ErrInvalidCertificate = errors.New("invalid tls certificate")

Functions

func ConnectionStateHolderToContext

func ConnectionStateHolderToContext(ctx context.Context, holder ConnectionStateHolder) context.Context

func ConnectionStateToContext

func ConnectionStateToContext(ctx context.Context, state ConnectionState) context.Context

ConnectionStateToContext creates a new context object with the provided ConnectionState object added to it as a value using the connectionStateContextKey constant as the key.

func ConnectionStateToContextFromNetConn

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

func CreateTLSClientConn

func CreateTLSClientConn(conn net.Conn, tlsConfig *tls.Config) *tls.Conn

func CreateTLSConn

func CreateTLSConn(conn net.Conn, tlsConfig *tls.Config, f func(net.Conn, *tls.Config) *tls.Conn) *tls.Conn

func CreateTLSServerConn

func CreateTLSServerConn(conn net.Conn, tlsConfig *tls.Config) *tls.Conn

func NewConnectionStateHolderToContext

func NewConnectionStateHolderToContext(ctx context.Context) context.Context

NewConnectionStateHolderToContext creates a new connectionStateHolder object with a new UUID string as the ID and adds it to the provided context using the connectionStateContextKey constant as the key.

func WrapConnection

func WrapConnection(conn net.Conn, opts ...ConnectionOption) net.Conn

func WrapHTTPTransport

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

func WrapTLSConfig

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

func WrappedConnectionListener

func WrappedConnectionListener(l net.Listener) net.Listener

Types

type Certificate

type Certificate interface {
	GetCertificate() *x509.Certificate
	GetSHA256Digest() string
	GetSubject() string
	GetFirstURI() string
	GetFirstDNSName() string
	GetFirstIP() string
	String() 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 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 ConnectionOption

type ConnectionOption func(*connection)

func ConnectionWithCloserWrapper

func ConnectionWithCloserWrapper(closeWrapper ConnectionCloseWrapper) ConnectionOption

func ConnectionWithOriginalAddress

func ConnectionWithOriginalAddress(address string) ConnectionOption

func ConnectionWithState

func ConnectionWithState(state ConnectionState) ConnectionOption

type ConnectionState

type ConnectionState interface {
	GetTimeToFirstByte() time.Time
	SetTimeToFirstByte(time.Time)
	ResetTimeToFirstByte()
	GetLocalCertificate() Certificate
	SetLocalCertificate(cert tls.Certificate)
	GetPeerCertificate() Certificate
	GetTLSConnectionState() tls.ConnectionState
	SetTLSConnectionState(tls.ConnectionState)
	SetTLSConnectionStateAsync(func() tls.ConnectionState)
	LocalAddr() net.Addr
	SetLocalAddr(net.Addr)
	RemoteAddr() net.Addr
	SetRemoteAddr(net.Addr)
	GetOriginalAddress() string
	ID() string
}

func ConnectionStateFromContext

func ConnectionStateFromContext(ctx context.Context) (ConnectionState, bool)

ConnectionStateFromContext extracts the ConnectionState object from the provided context and returns it, along with a boolean indicating whether the extraction was successful. If the ConnectionState object is not found in the context or is nil, the function returns false.

func ConnectionStateFromHTTPRequest

func ConnectionStateFromHTTPRequest(req *http.Request) (ConnectionState, bool)

func ConnectionStateFromNetConn

func ConnectionStateFromNetConn(conn net.Conn) (ConnectionState, bool)

func NewConnectionState

func NewConnectionState() ConnectionState

func NewConnectionStateWithID

func NewConnectionStateWithID(id string) ConnectionState

type ConnectionStateGetter

type ConnectionStateGetter interface {
	GetConnectionState() ConnectionState
}

type ConnectionStateHolder

type ConnectionStateHolder interface {
	Get() ConnectionState
	Set(ConnectionState)
	ID() string
}

func ConnectionStateHolderFromContext

func ConnectionStateHolderFromContext(ctx context.Context) (ConnectionStateHolder, 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 DialerWithConnectionOptions

func DialerWithConnectionOptions(opts ...ConnectionOption) DialerOption

func DialerWithDialerWrapper

func DialerWithDialerWrapper(w DialWrapper) DialerOption

type Server

type Server interface {
	GetUnifiedListener() listener.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

Directories

Path Synopsis
tunnel
api

Jump to

Keyboard shortcuts

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