netmanager

package module
v0.0.0-...-c04e8b8 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: MIT Imports: 11 Imported by: 0

README

net-manager

A Go library using Job concurrency pattern for handling network connections

Documentation

Index

Constants

View Source
const (
	FieldFd    = "fd"
	FieldPfd   = "pfd"
	FieldSysfd = "Sysfd"
)
View Source
const (
	DefaultReadBufLen = 4096
)

Variables

This section is empty.

Functions

func NewNetworkManager

func NewNetworkManager() *netManager

func NewProxyConn

func NewProxyConn(upstreamServer *ServerNet, downstream Stream) *proxyConn

func ReadTask

func ReadTask(j job.Job) (job.Init, job.Run, job.Finalize)

func WriteTask

func WriteTask(j job.Job) (job.Init, job.Run, job.Finalize)

Types

type ConnManager

type ConnManager interface {
	ConnectTask(job.Job) (job.Init, job.Run, job.Finalize)
	AcceptTask(job.Job) (job.Init, job.Run, job.Finalize)
	GetBytesSent() uint64
	GetBytesReceived() uint64
	GetNetworkManager() NetManager
	GetConnTotalCount(state StreamState, typ ConnType) int
	GetInboundLimit() int
}

type ConnManagerOptions

type ConnManagerOptions struct {
	InboundLimit int
	ReadbufLen   int
}

type ConnType

type ConnType int
const (
	Inbound ConnType = iota
	Outbound
)

func (ConnType) String

func (s ConnType) String() string

type DataKind

type DataKind int
const (
	DataFrameKind DataKind = iota
	DataRawKind
)

type NetManager

type NetManager interface {
}

type ProxyConn

type ProxyConn interface {
	Upstream() *stream
	Downstream() *stream
	ProxyReadUpstreamTask(j job.Job) (job.Init, job.Run, job.Finalize)
	ProxyReadDownstreamTask(j job.Job) (job.Init, job.Run, job.Finalize)
	ProxyWriteUpstreamTask(j job.Job) (job.Init, job.Run, job.Finalize)
	ProxyWriteDownstreamTask(j job.Job) (job.Init, job.Run, job.Finalize)
}

type Server

type Server struct {
	Host     string
	Weight   uint8
	MaxConns uint16
}

type ServerNet

type ServerNet struct {
	Server  *Server
	TcpAddr *net.TCPAddr
}

type Stream

type Stream interface {
	//Read() <-chan interface{}
	Write() chan<- interface{}
	WriteSync() int
	RecvDataFrame() <-chan netdataframe.DataFrame
	RecvDataFrameSync()
	RecvRaw() <-chan []byte
	RecvRawSync()
	NewConn() <-chan struct{}

	GetConnManager() ConnManager
	Key() string
	String() string
	GetState() StreamState
	CanBeReused() bool
	IsConnected() bool
	Refresh()
	CloseWithReuse()
	Close()
}

type StreamOptions

type StreamOptions struct {
	DataKind DataKind
}

func DefaultStreamOptions

func DefaultStreamOptions() *StreamOptions

type StreamState

type StreamState int
const (
	InUseConn StreamState = iota
	IdleConn
)

func (StreamState) String

func (s StreamState) String() string

Jump to

Keyboard shortcuts

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