netx

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	Handle(ctx context.Context, conn net.Conn)
}

type HandlerFunc

type HandlerFunc func(context.Context, net.Conn)

func (HandlerFunc) Handle

func (f HandlerFunc) Handle(ctx context.Context, conn net.Conn)

type LoggingConn

type LoggingConn struct {
	net.Conn

	// RW is full conversation log.
	RW bytes.Buffer

	// R is read data.
	R bytes.Buffer

	// W is written data.
	W bytes.Buffer

	// onClose is called when connection is closed.
	// Must be used to get final conversation log.
	OnClose func()
	// contains filtered or unexported fields
}

LoggingConn wraps net.Conn to save conversation log.

func NewLoggingConn

func NewLoggingConn(conn net.Conn) *LoggingConn

NewLoggingConn wraps net.Conn and adds logging.

func (*LoggingConn) Close

func (c *LoggingConn) Close() error

Close overwrites net.Conn Close method to call onClose function.

func (*LoggingConn) Read

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

Read overwrites net.Conn Read method to be able to save data to log.

func (*LoggingConn) Write

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

Write overwrites net.Conn Write method to be able to save data to log.

type LoggingListener

type LoggingListener struct {
	net.Listener
}

LoggingListener is net.Listener wrapper that returns wraps net.Conn with LoggingConn.

func (*LoggingListener) Accept

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

type MaxBytesConn

type MaxBytesConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*MaxBytesConn) Read

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

type MaxBytesListener

type MaxBytesListener struct {
	net.Listener
	MaxBytes int64
}

func (*MaxBytesListener) Accept

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

type Server

type Server struct {
	Addr              string
	TLSConfig         *tls.Config
	NotifyStartedFunc func()
	ListenerWrapper   func(net.Listener) net.Listener // TODO: replace with handler
	Handler
}

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

type TimeoutConn

type TimeoutConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*TimeoutConn) Read

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

func (*TimeoutConn) Write

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

type TimeoutListener

type TimeoutListener struct {
	net.Listener
	IdleTimeout time.Duration
}

func (*TimeoutListener) Accept

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

Jump to

Keyboard shortcuts

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