handler

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

README

Connection Handler

Connection Handler listens for incoming connections (net.Conn), copy the stream (as net.Conns) and feed them into all protocol filters, get the filtering result and forward the connection to the corresponding target.

Documentation

Index

Constants

View Source
const (
	DEFAULT_TIMEOUT = 5 * time.Second
)

Variables

View Source
var (
	ErrServerStopped = errors.New("server stopped")
	ErrUnknownAction = errors.New("unknown action")
)

Functions

This section is empty.

Types

type Server

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

func NewServer

func NewServer(serverAddr config.ServerAddr, protocolManager *protocol.ProtocolManager, mode ServerMode) *Server

Required parameters will be provided from the main function

func (*Server) HandleNextConn

func (s *Server) HandleNextConn(ctx context.Context) error

HandleNextConn() will block until a connection is available then call handleConn() to handle the connection upon it. Or it will return an error if the context is cancelled.

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

type ServerMode

type ServerMode uint8
const (
	SERVER_MODE_WORKER    ServerMode = iota // HandleNextConn() to be called by an external worker
	SERVER_MODE_UNLIMITED                   // unlimited number of connections will be handled
)

Jump to

Keyboard shortcuts

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